Hello i just installed a simple login script but im getting a error
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/myjesus2/public_html/loginscript.php on line 22
Invalid login information. Please return to the previous page.
html form code:
UsernamePassword
php script
<?php // All code was wrote by Tim Kipp @ TimKippTutorials.com - December 29, 2010 // Your MySQL database login information $host = "localhost"; // Your host address to your database on your server. Usually "localhost". Check with your hosting provider $user = "myjesus2xxx"; // Your username you set up for this database on your server $pass = "xxxxxxxx"; // Your password you set up for this database on your server $db = "myjesus2_login"; // The database name that you will be connecting to // Connecting to the MySQL database mysql_connect($host, $user, $pass); mysql_select_db($db); // Checking to see if the login form has been submitted if (isset($_POST['username'])) { $username = $_POST['username']; $password = $_POST['password']; // Query to check to see if the username and password supplied match the database records $sql = "SELECT * FROM users WHERE username='".$username."' AND password='".$password."' LIMIT 1"; $res = mysql_query($sql); // If login information is correct if (mysql_num_rows($res) == 1) { echo "You have successfully logged in."; exit(); } // If login information is invalid else { echo "Invalid login information. Please return to the previous page."; exit(); } } ?>Anyone ever had this problem before?
