Mysql – How to rename a thesql table in php

MySQLPHPrenamesqlxampp

I have tried all sorts of things to get a table renamed from php, including mysqli (code below) and mysql_connect/mysql_query. I have tried rename table and alter table.
In the example below there are no errors when I execute it. However, when I go look, the 'trac' table is still there with no '2' at the end.

$link = mysqli_connect("lamp1", "user", "pw", "db");

/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}
if ($stmt = mysqli_prepare($link, "rename table trac to trac2")) {
 mysqli_stmt_execute($stmt);
}
else
 echo "error";

This is xampp (recent version) on a Windows Server 2008 machine. Mysql 5.0.7, php 5.3.4.

I can rename the table with no issue through phpMyAdmin!

What can I check / try? Is there a log file I can turn on / look at to see whats happening from the mysql side?

Best Answer

Use mysqli_stmt_error($stmt) to figure out the error that is being returned, and then act on that.