Web Hosting Talk







View Full Version : Need PHP Help


zRedDice
07-17-2002, 09:56 AM
Well... I've spent 3 hours looking at it... I checked spelling, syntax, and logic, and it all gives the same error.

It is part of a page object, in which all of the functions are defined and work fine. The query executes with no problem, but then it gets an error on the mysql_num_rows() line, saying that $result is not a valid result identifier. Anyone know why?

I posted this in the main forum by mistake... Here it is again. :)


function checkauth()
{
global $PHP_AUTH_USER, $PHP_AUTH_PW, $PHP_SELF;
global $userid, $password, $username, $userconame;

if(!isset($username))
{
$this->startpage();
$this->loginpage();
$this->endpage();
exit;
}
else
{
session_register($password, $username);
$query = "SELECT id, name FROM companies WHERE username='$username' AND password=password('$password')";
$result = mysql_query($query, $this->conn);
if(!mysql_num_rows($result))
{
session_unregister($password);
session_unregister($username);

$this->startpage();
$this->loginpage();
$this->endpage();
}
else
{
$record = mysql_fetch_object($result);
$userconame = $record->name;
$userid = $record->id;
}
}
}

Gyrbo
07-17-2002, 12:57 PM
try adding or print(mysqm_error()) after the query, that should give you any errors.

Starhost
07-17-2002, 04:09 PM
Or just:


$query = "SELECT id, name FROM companies WHERE username='$username' AND password=password('$password')";
$result = mysql_query($query, $this->conn) or die ("" .mysql_error());

zRedDice
07-19-2002, 09:56 AM
I feel quite stupid, but I guess we all do sometimes. *sigh*

I had the wrong field name... *sigh*

Thanks for your time, however :)

- James