...

View Full Version : PHP Error



Kev0121
03-20-2009, 08:09 PM
arning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/youronli/public_html/process.php on line 22

Getting This Error...
Here's my script...




<?php
error_reporting(E_ALL);
session_start();

$dbHost = ""; // Database Connection Details - host
$dbUser = ""; // Database Connection Details - username
$dbPass = ""; // Database Connection Details - password
$dbname = ""; // Database Connection Details - database name


$db = mysql_connect($dbHost,$dbUser,$dbPass); // Connection Code
mysql_select_db($dbname,$db); // Connects to database

if(isset($_POST['submit']))
{
$username = $_POST['username'];
$password = $_POST['password'];

$sql = "SELECT * FROM users WHERE username = '$username' AND password = '$password'";
$que = mysql_query($sql);

if(mysql_num_rows($que) == 1)
{
$_SESSION['loggedin'] = 1;
header("Location: usercp.php");
}else
{
echo "<font color=\"red\"> Error Wrong Login Details </font>";
echo "<a href=\"login.php\">Login Page</a>";
}
}
?>

timgolding
03-20-2009, 08:13 PM
Its telling you that the query has failed. if you put the line


echo $sql;


just under


$sql = "SELECT * FROM users WHERE username = '$username' AND password = '$password'";


and see what comes out?

timgolding
03-20-2009, 08:16 PM
Are sure that you've spelled users, username and password exactly as they are in the database?

Kev0121
03-20-2009, 08:16 PM
Ah, dont matter i fixed it..i found out the guy im working with changed the connection info dammit! sorry about that


Kevin



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum