blink359 Posted November 8, 2010 Share Posted November 8, 2010 Hi i followed a guid to create a login area to my site however i believe its a little outdated and therefore not working, i have done a little bit but being quite new i cannot find all the problems at the moment i have: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/a9855336/public_html/checklogin.php on line 12 here is my script line 12 is marked <?php $host="*************"; // Host name $username="a9855**6_root"; // Mysql username $password="************"; // Mysql password $db_name="****3***36_mail; // Database name // Connect to server and select databse. mysql_connect($host, $username, $password) mysql_select_db($db_name); // username and password sent from form $myusername=$_POST['myusername']; // line 12 $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); // encrypt password $encrypted_mypassword=md5($mypassword); $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$encrypted_mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("myusername"); session_register("mypassword"); header("location:login_success.php"); } else { echo "Wrong Username or Password"; } ?> if you help please tell me the error so i can learn to debug scripts myself in the future thanks blink359 Quote Link to comment https://forums.phpfreaks.com/topic/218139-lots-of-php-errors-with-a-login-script/ Share on other sites More sharing options...
snowman15 Posted November 8, 2010 Share Posted November 8, 2010 your missing a quotation mark on this line: $db_name="****3***36_mail; // Database name cheers! Quote Link to comment https://forums.phpfreaks.com/topic/218139-lots-of-php-errors-with-a-login-script/#findComment-1131942 Share on other sites More sharing options...
blink359 Posted November 8, 2010 Author Share Posted November 8, 2010 Thanks thats seem to fix a lot its now just Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/a9855336/public_html/checklogin.php on line 28 // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row Thanks Blink359 Quote Link to comment https://forums.phpfreaks.com/topic/218139-lots-of-php-errors-with-a-login-script/#findComment-1131953 Share on other sites More sharing options...
snowman15 Posted November 8, 2010 Share Posted November 8, 2010 I'm pretty sure that error would be thrown if your result doesn't match anything. I suggest var_dump($result); to see if it is actually returning anything, then you'll know for sure. Quote Link to comment https://forums.phpfreaks.com/topic/218139-lots-of-php-errors-with-a-login-script/#findComment-1131961 Share on other sites More sharing options...
blink359 Posted November 8, 2010 Author Share Posted November 8, 2010 Im entering the correct info and its coming back "bool(false)" :S Quote Link to comment https://forums.phpfreaks.com/topic/218139-lots-of-php-errors-with-a-login-script/#findComment-1131966 Share on other sites More sharing options...
snowman15 Posted November 8, 2010 Share Posted November 8, 2010 that would suggest that your query isn't working for some reason. try to echo the mysql_connect and the mysql_select_db lines to see if they come back as true or false. if you echo everything, you can tell that the first thing that comes back false is probably the weak link in the chain. Quote Link to comment https://forums.phpfreaks.com/topic/218139-lots-of-php-errors-with-a-login-script/#findComment-1131969 Share on other sites More sharing options...
blink359 Posted November 8, 2010 Author Share Posted November 8, 2010 ahh dont worry had a typo on the table name, but its not redirecting to the last page if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("myusername"); session_register("mypassword"); header("location:login_success.php"); Quote Link to comment https://forums.phpfreaks.com/topic/218139-lots-of-php-errors-with-a-login-script/#findComment-1131970 Share on other sites More sharing options...
blink359 Posted November 8, 2010 Author Share Posted November 8, 2010 Dont worry, sorted, thank you ever so much for your help Blink359 Quote Link to comment https://forums.phpfreaks.com/topic/218139-lots-of-php-errors-with-a-login-script/#findComment-1131974 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.