Foser Posted June 29, 2007 Share Posted June 29, 2007 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\WAMP\www\Projects\LogiPlan\index.php on line 20 thats my error. this is my script: <title>Login Page</title> <?php //starting SESSION session_start(); //Lazy Login if ($_SESSION['LOGGEDIN'] == TRUE){ header("Location: /main/index.php");} //SQL Configuration file require("config.php"); //when pressed submit execute the FOLOWING if (isset($_POST['submit'])){ // USER TYPED INFORMATION $user = mysql_real_escape_string($_POST['username']); $password = sha1(md5($_POST['password'])); // Searching DB for username and password Match $result = mysql_query("SELECT * FROM user_info username = '$user' and password = '$password'"); if (mysql_num_rows($result) > 0){ // SETTING UP SESSIONS $_SESSION['LOGGEDIN'] = TRUE; $_SESSION['UNAME'] = $user; //Go To Member Control Panel if ($_SESSION['LOGGEDIN'] = TRUE){ header("Location: /main/index.php"); exit; }} // IF EVERYTHING ELSE IS FALSE EXECUTE THIS: else { echo "You have not entered the correct data. You may try again.";}} ?> <form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <label>Username: <input type="text" name="username" id="username"> </label> <br> Password: <label> <input type="password" name="password" id="password"> </label> <br> <label> <input type="submit" name="submit" id="submit" value="submit"> </label> </form> thansk Link to comment https://forums.phpfreaks.com/topic/57749-solved-msqyl-num-rows-not-valid-argument/ Share on other sites More sharing options...
hackerkts Posted June 29, 2007 Share Posted June 29, 2007 Maybe you will find some errors with your query, try mysql_error() Link to comment https://forums.phpfreaks.com/topic/57749-solved-msqyl-num-rows-not-valid-argument/#findComment-285923 Share on other sites More sharing options...
aim25 Posted June 29, 2007 Share Posted June 29, 2007 Try this, i had the same problem, but i dont remember how i fixed it. <?php $result = "SELECT * FROM user_info username = '$user' and password = '$password'"; ?> Link to comment https://forums.phpfreaks.com/topic/57749-solved-msqyl-num-rows-not-valid-argument/#findComment-285933 Share on other sites More sharing options...
Foser Posted June 29, 2007 Author Share Posted June 29, 2007 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= 'admin' and password = '55c3b5386c486feb662a0785f340938f518d547f'' at line 1 wow first time i see this error, seems like it does not know where to get the admin username from. but i checked my database everything is spelled correcly Link to comment https://forums.phpfreaks.com/topic/57749-solved-msqyl-num-rows-not-valid-argument/#findComment-285939 Share on other sites More sharing options...
no_one Posted June 29, 2007 Share Posted June 29, 2007 You forgot the WHERE in your select Select [values] from table WHERE [condition] Link to comment https://forums.phpfreaks.com/topic/57749-solved-msqyl-num-rows-not-valid-argument/#findComment-285942 Share on other sites More sharing options...
Foser Posted June 29, 2007 Author Share Posted June 29, 2007 hehe yea just found out came to tell u guys but you beat me to it. thanks guys Link to comment https://forums.phpfreaks.com/topic/57749-solved-msqyl-num-rows-not-valid-argument/#findComment-285943 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.