...

View Full Version : SQL Sintax Error



barkermn01
01-14-2008, 09:38 PM
$query = mysql_query("SELECT * FROM `Users` WHERE `Username` = '$_POST[user]' AND `Password` = '$pass'");
while($row = mysql_fetch_array($query))
{
$_SESSION['Username'] = $row['username'];
$_SESSION['UserID'] = $row['ID'];
}

returns this error

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home1/barkersm/public_html/irc/login.php on line 44

Inigoesdr
01-14-2008, 09:41 PM
mysql_query() is returning false because your query is failing. Change your query to this to get more info:


$query = mysql_query("SELECT * FROM `Users` WHERE `Username` = '{$_POST['user']}' AND `Password` = '$pass'") or die(mysql_error());

And make sure you pass all user input through mysql_real_escape_string() before using it in a query.

ahallicks
01-14-2008, 09:48 PM
And 'sintax' is actually spelt 'syntax' :p

(sorry, felt the need to add that in there)

barkermn01
01-14-2008, 10:18 PM
thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum