Error help.
Posted by: edocphp (208.250.63.---)
Date: April 03, 2008 07:57PM

Session start in Index.php. This is part of php.inc. Cannot figure out why I get the error on the query. I would appreciate any help.


<?php

$con = mysql_connect("localhost", "user", "password"winking smiley or die('Could not connect to server');
mysql_select_db("table", $con) or die('Could not connect to database');

$userid = ($_POST['userid']);
$password = md5($_POST['password']);

$query = "SELECT users WHERE userid = '$userid' AND password = '$password' ";
$result = mysql_query($query) or die("Unable to verify user because:" . mysql_error());

if (mysql_num_rows($result) > 0)
{
$_SESSION['valid_user'] = $userid;
echo "Your user account has been validated\n";
echo "<a href=\"index.php\">Home</a>\n";
}
?>

Options: ReplyQuote
Re: Error help.
Posted by: yfastud (Moderator)
Date: April 03, 2008 08:03PM


Options: ReplyQuote
Re: Error help.
Posted by: edocphp (208.250.63.---)
Date: April 03, 2008 08:18PM

Added Session start to this page. I believe, this was your point of reference.

New error: Parse error: syntax error, unexpected T_VARIABLE in line 4.

This is the $con line. Does not seem right.

Options: ReplyQuote
Re: Error help.
Posted by: yfastud (Moderator)
Date: April 03, 2008 08:52PM

Do you forget the ; in the line before that line?

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides

Options: ReplyQuote
Re: Error help.
Posted by: edocphp (208.250.63.---)
Date: April 03, 2008 09:31PM

You are correct. New error however.

Unable to verify user because: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 'WHERE userid = 'user' AND password = ...very long password encypted string.

Options: ReplyQuote
Re: Error help.
Posted by: yfastud (Moderator)
Date: April 03, 2008 09:48PM

$con = mysql_connect("localhost", "user", "password"winking smiley
Did you put in the correct user and password here? In other word, did you create the db account for your script yet? If not, check Setup Database guide on my personal website

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides

Options: ReplyQuote


Sorry, only registered users may post in this forum.