PDA

View Full Version : SQL syntax error


chump2877
02-07-2005, 04:57 AM
Can you find the SQL syntax error in this PHP code:

<?


$dbcon = mysql_connect("localhost","username","password");

mysql_select_db("MyDatabase",$dbcon);



// Reset index number to zero.

$queryK = "UPDATE user_information SET index_no='0' WHERE username LIKE '%".$_SESSION['username']."%'";
$resultK = mysql_query($queryK);
if (mysql_errno())
{
die("<br>" . mysql_errno() . ": " . mysql_error() . "<br>");
}


// Drop table $username.

$queryB = "DROP TABLE ".$_SESSION['username']."";
$resultB = mysql_query($queryB);
if (mysql_errno())
{
die("<br>" . mysql_errno() . ": " . mysql_error() . "<br>");
}



?>


I believe the error is somewhere around this line:

$queryK = "UPDATE user_information SET index_no='0' WHERE username LIKE '%".$_SESSION['username']."%'";

Thanks for any help....

Brandoe85
02-07-2005, 08:46 AM
echo out $_SESSION['username'] make sure it has a value. I'm thinking it's with your drop table query.