dragzai Posted July 6, 2010 Share Posted July 6, 2010 Hi guys. This is my first post. I've been speed reading through the net for a few days now trying to figure out my problem. I'm relatively new to PHP so if any of my code besides my existing problem seems unorthodox that is probably why Okay first things first. The following code works on a hosted php4 debian server and a php5 apache server. It does not work on a hosted php5 debian server. It also does not work on my localhost WAMP server which has php5.3. I don't actually get any php or mysql errors with the code - the page either never loads or says the connection has reset (in firefox3) I did however read that there was a WAMP error log and in it I get this error: mysql_num_rows() expects parameter 1 to be resource, boolean given its pretty simple code just a side project I've been working on. Here it is: include("scripts/connect.php"); //Grab cookie values $username_cookie = $_COOKIE['username']; $password_cookie = $_COOKIE['password']; //Cross check cookie values to database values $query = "SELECT * FROM users WHERE username='$username_cookie' and password='$password_cookie'"; $result = mysql_query($query); if (mysql_num_rows($result) != 1) { //Make sure username and password exist on the same table row //login here } else { //welcome! } I'm sure some one will ask so I'll go ahead and say now that the connect.php file actually works without error If you need anything else from me let me know. Any and all help is greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/206916-login-cookies-and-php4-vs-php5/ Share on other sites More sharing options...
PFMaBiSmAd Posted July 6, 2010 Share Posted July 6, 2010 The error means that your query failed due to an error (this is NOT the result of a query that executed but matched zero rows.) If you echo mysql_error(); on the next line after the line with your mysql_query() statement, it will tell you why the query failed. Quote Link to comment https://forums.phpfreaks.com/topic/206916-login-cookies-and-php4-vs-php5/#findComment-1082046 Share on other sites More sharing options...
dragzai Posted July 6, 2010 Author Share Posted July 6, 2010 Thanks! I changed the code to look like this: include("scripts/connect.php"); //Grab cookie values $username_cookie = $_COOKIE['username']; $password_cookie = $_COOKIE['password']; //Cross check cookie values to database values $query = "SELECT * FROM users WHERE username='$username_cookie' and password='$password_cookie'"; $result = mysql_query($query); echo mysql_error(); if (mysql_num_rows($result) != 1) { //Make sure username and password exist on the same table row //login here } else { //welcome! } I added the highlighted and ran it on my WAMP php5.3 and it came back: The connection was reset The connection to the server was reset while the page was loading. To make sure that this wasnt an issue with file path or anything I stripped the if statement that contains the mysql_num_rows restraint and just displayed the content as if I were logged in and it displays fine in WAMP. I read somewhere that connection reset could mean that my code is stuck in an infinite loop. However I'm not sure what that means entirely. Hopefully this useless information helps Quote Link to comment https://forums.phpfreaks.com/topic/206916-login-cookies-and-php4-vs-php5/#findComment-1082057 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.