sonehs Posted April 14, 2009 Share Posted April 14, 2009 I cant fix this... please help.... I get error Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/tritusco/public_html/includes/checklogin.php on line 29 Wrong Username or Password <?php //session_start(); ob_start(); $host="localhost"; // Host name $username="****"; // Mysql username $pass="*****"; // Mysql password $db_name="tritusco_members"; // Database name $tbl_name="user_register"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$pass")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from form $email=$_POST['email']; $pass=$_POST['pass']; // To protect MySQL injection (more detail about MySQL injection) $email = stripslashes($email); $pass = stripslashes($pass); $email = mysql_real_escape_string($email); $pass = mysql_real_escape_string($pass); $sql="SELECT * FROM $tbl_name WHERE username='$email' and password='$pass'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count = mysql_num_rows($result); // LINE 29 // If result matched $email and $pass, table row must be 1 row if($count==0){ // Register $email, $pass and redirect to file "login_success.php" echo "Wrong Username or Password";} else { session_register("email"); session_register("pass"); header("location:login_success.php"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/154109-help-needed/ Share on other sites More sharing options...
Maq Posted April 14, 2009 Share Posted April 14, 2009 Your query is failing replace this line with: $result=mysql_query($sql) or die(mysql_error()); And please use tags around code. Quote Link to comment https://forums.phpfreaks.com/topic/154109-help-needed/#findComment-810094 Share on other sites More sharing options...
sonehs Posted April 14, 2009 Author Share Posted April 14, 2009 thx hmm its now saying wrong name and password, but its right... maybe its not picking up the column? anychance u see something? im new and i know that the stupidest little thing can be holding me back.. .thx for ur help Quote Link to comment https://forums.phpfreaks.com/topic/154109-help-needed/#findComment-810104 Share on other sites More sharing options...
Maq Posted April 14, 2009 Share Posted April 14, 2009 Are your passwords encrypted with anything before you insert them in the database? Have you actually looked inside the database to see if what you expect to happen should occur? What's the exact error/problem? Quote Link to comment https://forums.phpfreaks.com/topic/154109-help-needed/#findComment-810115 Share on other sites More sharing options...
sonehs Posted April 14, 2009 Author Share Posted April 14, 2009 Your query is failing replace this line with: $result=mysql_query($sql) or die(mysql_error()); And please use tags around code. Quote Link to comment https://forums.phpfreaks.com/topic/154109-help-needed/#findComment-810117 Share on other sites More sharing options...
sonehs Posted April 14, 2009 Author Share Posted April 14, 2009 heh yea i looked in the database, and no the passwords are not encrypted.... Im trying to make it check email and password from database and login... go try register and login.... and dont criticize me plz im noob with php and its a day old site :-X hah www.tritusco.com if u got aim maybe u could aim me? Atticus504 Quote Link to comment https://forums.phpfreaks.com/topic/154109-help-needed/#findComment-810118 Share on other sites More sharing options...
mrMarcus Posted April 14, 2009 Share Posted April 14, 2009 it's not returning any results, so check and make sure all your data is correct .. make sure the username and password in the db are exactly as you are typing them. and you'd better lose the session_register() as it's set to be removed come the newest version of PHP. Quote Link to comment https://forums.phpfreaks.com/topic/154109-help-needed/#findComment-810126 Share on other sites More sharing options...
Maq Posted April 14, 2009 Share Posted April 14, 2009 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/tritusco/public_html/includes/checklogin.php on line 29 This usually means that the query is failing. What exactly does it say when you put the or die statement at the end of the query call? Quote Link to comment https://forums.phpfreaks.com/topic/154109-help-needed/#findComment-810131 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.