View Full Version : Cannot get my query

05-29-2011, 05:19 AM
I've been working on this for awhile, and I cannot not seem to find where my problem lies. For some reason or another I always seem to get a query fail.

mysql_connect("localhost", "root", "rootpw") or die("Could not connect to database");
mysql_select_db("user") or die("Could not select database");
$query = "SELECT userid, password FROM signup WHERE userid=$_POST[userid]";
$result = mysql_query($query) or die("Query failed");
$logininfo = mysql_fetch_array($result, MYSQL_ASSOC);

if(($_POST[userid] == $logininfo[userid]) && ($_POST[password] == $logininfo[password]))
header("Location: success.html");
header("Location: fail.html");

can someone spot an error in my coding?

05-29-2011, 10:22 AM
Looks like you just need to do some Basic Debugging 101 (http://www.codingforums.com/showthread.php?p=1082858#post1082858) to find your error.

As a start echo out the actual query being run and make sure the values passed to it and the syntax are correct.

$query = "SELECT userid, password FROM signup WHERE userid=$_POST[userid]";
echo $query; die();