...

View Full Version : Returns an eror in PHP/Mysql call..



fireblade
06-02-2007, 12:45 PM
What is the error seems here beLow??



function isPasswordMatch($email, $password) {

$SQL="SELECT email FROM user WHERE email='$email' AND Password=Password('$password')";

$id=db_connect();
if ($id) {
$rs=mysql_query($SQL, $id);
$num_rows=mysql_num_rows($rs);
// other gadjets goes here....


this returns an error lice below
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/www/photocity.freehostia.com/includes/php_database.php on line 161

rafiki
06-02-2007, 01:17 PM
use mysql_fetch_array or mysql_fetch_row ?

ddanatzko
06-02-2007, 03:26 PM
What is the error seems here beLow??



function isPasswordMatch($email, $password) {

$SQL="SELECT email FROM user WHERE email='$email' AND Password=Password('$password')";

$id=db_connect();
if ($id) {
$rs=mysql_query($SQL, $id);
$num_rows=mysql_num_rows($rs);
// other gadjets goes here....



The problem is with your SQL statement. try using it like this instead:



$SQL=SELECT email FROM USER WHERE email=$email AND Password=$password";

Fumigator
06-02-2007, 03:50 PM
Yes, your problem is with your query text, but Ddanatzko's code doesn't get you any closer to finding the problem. What you need to do is check your query for errors after you run it.

Do this...


function isPasswordMatch($email, $password) {

$SQL="SELECT email FROM user WHERE email='$email' AND Password=Password('$password')";

$id=db_connect();
if ($id) {
$rs=mysql_query($SQL, $id);
if (!$rs) {
die("SQL Query Error! Query: $SQL<br />Error:".mysql_error());
}
$num_rows=mysql_num_rows($rs);
// other gadjets goes here....

ddanatzko
06-02-2007, 04:07 PM
Fumigator's right, should have read the error message below the post.

fireblade
06-03-2007, 11:56 AM
Thanks seniors,

I got what the problem was there using the mysql_error() function.
Actually the problem was my biggest mistake. I dint have selected any databases before running the query.

Then I added the select_db() function it was working fine...

Thanks for gining the idea.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum