arn_php Posted March 7, 2008 Share Posted March 7, 2008 I am moving a website to a new server which has a different setting here: New server: FreeBSD (linux?), PHP4.4.7, MySQL 4.1.21 Old server: Ms. Windows, PHP4.3.9, MySQL 3.23.49 On both I have the register_globals ON but then this is the error I am gettingeach time I tried to login into the admin area Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /admin/functions.php on line 40 On the functions.php line 40, the coding $result = mysql_query("SELECT * FROM Users WHERE login='".addslashes($username)."' AND password='".addslashes($password)."'"); if (mysql_num_rows($result)>0) { $clSession=new Session(0,$username); return $clSession->seshid; } return 0; I actually do not change any coding on the script while doing the transfer so far because I am expecting the site would be working just fine. Is there any configuration on mysql and php that I miss here? Thanks, any help is welcome. Quote Link to comment Share on other sites More sharing options...
phpSensei Posted March 7, 2008 Share Posted March 7, 2008 try $result = mysql_query("SELECT * FROM Users WHERE login='".addslashes($username)."' AND password='".addslashes($password)."'") or die(mysql_error()); Make sure the username and password are correct, maybe some field names arent right or got changed during the transfer or something. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted March 7, 2008 Share Posted March 7, 2008 Your code is not checking if the mysql_query() worked or not before blindly accessing the result resource. Change your query to the following to get php/mysql to tell you why it is not working - see the code in phpSensei's post above[code] [/code] Quote Link to comment Share on other sites More sharing options...
arn_php Posted March 7, 2008 Author Share Posted March 7, 2008 to phpSensei : That is right, I notice the table's name is users into the DB but then into the code it is Users. So I changed the table's name from within the phpmyadmin to Users. And then the page is working, only now it takes me back to login page with this message: SESSION EXPIRED. Any other suggestion on this? Quote Link to comment Share on other sites More sharing options...
phpSensei Posted March 7, 2008 Share Posted March 7, 2008 The lifetime of your sessions is defined in your php.ini file, you may want to look into that or search it up on google, because shared hosting is different. Also make sure you have session_start() on every page... post where you are setting the sessions also please. Quote Link to comment 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.