Renaming table name
<p>I am trying to rename a table's name from a specific database. I have tried with both of the query given below, but it shows the same error message. I can't understand my mistakes.</p>

<p>The query</p>

<p>1st one :</p>

<pre><code>  &lt;?php
$id = $_POST['id'];
$department = $_POST['department'];
$dept_id = $_POST['dept_id'];
$olddept_id = $_SESSION['olddept_id'];

if(isset($_POST['submit']))
{
$order = "UPDATE department SET department='$_POST[department]', dept_id='$_POST[dept_id]' WHERE id='$_POST[id]'";
mysql_query($order) or die (mysql_error());
mysql_query("RENAME TABLE $olddept_id TO $dept_id;") or die (mysql_error());

}
</code></pre>

<p>and</p>

<p>2nd one :</p>

<pre><code>  &lt;?php
$id = $_POST['id'];
$department = $_POST['department'];
$dept_id = $_POST['dept_id'];
$olddept_id = $_SESSION['olddept_id'];

if(isset($_POST['submit']))
{
$order = "UPDATE department SET department='$_POST[department]', dept_id='$_POST[dept_id]' WHERE id='$_POST[id]'";
mysql_query($order) or die (mysql_error());
mysql_query("ALTER TABLE $olddept_id RENAME $dept_id;") or die (mysql_error());

}
</code></pre>

<p>The error message is :
    "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TO CSEE' at line 1"</p>

<p>The table names which i want to edit, are also stored in a table, named "department". This is done successfully, but the table doesn't renaming.</p>

<p>-thank you</p>
