Foser Posted August 6, 2007 Share Posted August 6, 2007 <?php // Includes! require_once('includes/mysql.php'); session_start();?> <?php if (isset($_POST['login_submit'])){ $login_username = mysql_real_escape_string($_POST['login_user']); $login_pw = md5($_POST['login_pass']); $check_query = mysql_query("SELECT * FROM user_info WHERE username = {$login_username} and WHERE password = {$login_pw}"); if (mysql_num_rows($check_query) > 0){ //Line 9! $find_info = mysql_fetch_assoc($check_query); $_SESSION['LOGGEDIN'] = TRUE; $_SESSION['USERNAME'] = $find_info['username']; $_SESSION['EMAIL'] = $find_info['email']; echo "You are now Logged in as {$_SESSION[username]}."; } else { echo "You have entered false data";} } ?> error message: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\WAMP\www\PP\itemprogram\index.php on line 9 Quote Link to comment https://forums.phpfreaks.com/topic/63527-solved-mysql_num_rows-unsupplied-argument/ Share on other sites More sharing options...
ToonMariner Posted August 6, 2007 Share Posted August 6, 2007 means the query you have run is not a valid query - you need to quote any strings in a query so '{$login_usernam}' and '{$login_pw}' should help... Quote Link to comment https://forums.phpfreaks.com/topic/63527-solved-mysql_num_rows-unsupplied-argument/#findComment-316636 Share on other sites More sharing options...
Foser Posted August 6, 2007 Author Share Posted August 6, 2007 I still get an error ... Same thing Quote Link to comment https://forums.phpfreaks.com/topic/63527-solved-mysql_num_rows-unsupplied-argument/#findComment-316772 Share on other sites More sharing options...
AndyB Posted August 6, 2007 Share Posted August 6, 2007 Change: $check_query = mysql_query("SELECT * FROM user_info WHERE username = {$login_username} and WHERE password = {$login_pw}"); to: $check_query = mysql_query("SELECT * FROM user_info WHERE username = {$login_username} and password = {$login_pw}"); Mind you, the better way to do it is as below so you get to see just what the problem is: $query = "SELECT * FROM user_info WHERE username = {$login_username} and password = {$login_pw}"; $check_query = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query); Quote Link to comment https://forums.phpfreaks.com/topic/63527-solved-mysql_num_rows-unsupplied-argument/#findComment-316777 Share on other sites More sharing options...
HuggieBear Posted August 6, 2007 Share Posted August 6, 2007 Try changing this: $check_query = mysql_query("SELECT * FROM user_info WHERE username = {$login_username} and WHERE password = {$login_pw}"); To this: $sql = "SELECT * FROM user_info WHERE username = '" . $login_username . "' AND password = '" . $login_pw . "'"; $check_query = mysql_query($sql); if (!$check_query){ echo "Failed to execute query ($sql): " . mysql_error(); } Regards Huggie Quote Link to comment https://forums.phpfreaks.com/topic/63527-solved-mysql_num_rows-unsupplied-argument/#findComment-316778 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.