Posted by Michael Fesser on 07/14/07 19:27
..oO(Robbo)
>PHP - I'm trying to create a MySQL table like an existing MySql table.
>
>My PHP code is
>
>$query = "CREATE TABLE '".$new_db."'.'".$new_name."' LIKE '".
>$old_db."'.'".$old_name."'";
>echo mysql_error()."<br>";
>
>When I run in the browser I get -
>
>You have an error in your SQL syntax near
>''forest_client_XXX000001'.'accounts' LIKE
>'forest_client_fds000003'.'accounts'' at line 1
Why don't you use the double-quotes in the way they are meant for?
And drop the single quotes - table names are not quoted.
$query = "CREATE TABLE $new_db.$new_name LIKE $old_db.$old_name";
Micha
[Back to original message]
|