mariam Posted May 24, 2011 Share Posted May 24, 2011 hi i am a php noop. i used a logon script and ran it on xampp and it worked just fine. now when i have used a free web hosting site (000webhost.com) created the same database there the following error occurs: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/a3907930/public_html/checklogin.php on line 18 Wrong Username or Password following is the code for my check login page: (in xampp i used $username="root" and $password= "" it worked fine) the username and password in the below code was generated when the database was created in www.000webhost.com <?php $host="xxxxxx"; // Host name $username="xxxxxx"; // Mysql username $password="xxxxxx"; // Mysql password $db_name="xxxxxx"; // Database name $tbl_name="xxxxxx"; // Table name // Connect to server and select databse. mysql_connect($host, $username, $password)or die("cannot connect"); mysql_select_db($db_name)or die("cannot select DB"); // username and password sent from form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$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"; } ?> please help Link to comment https://forums.phpfreaks.com/topic/237311-script-not-working-when-hosted/ Share on other sites More sharing options...
mariam Posted May 25, 2011 Author Share Posted May 25, 2011 Nevermind it all worked when i imported the same database from xampp to www.000webhost.com. instead of recreating it dierctly in the hosting site Link to comment https://forums.phpfreaks.com/topic/237311-script-not-working-when-hosted/#findComment-1219972 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.