Forum Moderators: coopster

Message Too Old, No Replies

Warning: mysql_num_rows(): supplied argument is not a valid MySQL resu

Php mysql error

         

woemlavy

6:44 pm on Aug 20, 2004 (gmt 0)

10+ Year Member



I get the following message when trying to login or create a new user.

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /functions.php on line 34

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /functions.php on line 36

Here is my functions file:

<script language="JavaScript">

function openWindow (url,name,widgets)
{
popupWin = window.open (url,name,widgets);
popupWin.opener.top.name="opener";
popupWin.focus();
}
</script>

<?
function wrongpass(){
?>
<table border=0 cellpadding=5 cellspacing=5>
<tr>
<td>
<font class="verify2">
<b>You have supplied an incorrect User Name and/or Password.</b>
</font>
</td>
</tr>
</table>
<?
}

//checks password and username
function checkpass($handle,$pass){
require_once($home."mysqlinfo.php");
include("i_aeskey.php");
$query="SELECT AES_DECRYPT(password,'$AES_key') FROM users WHERE (handle='$handle')";
$result = mysql_query($query);

if(mysql_num_rows($result));
{
if($r = mysql_fetch_array($result))
{$dbpass=$r[0];}
if($pass==$dbpass)
{return 1;}
else{

$querysecond="SELECT password FROM users WHERE (handle='$handle')";
$resultsecond = mysql_query($querysecond);
if(mysql_num_rows($resultsecond))
{
while($r = mysql_fetch_array($resultsecond))
{$dbpass=$r[0];}
if ($pst!=1){pak(&$pass);}
if($pass==$dbpass)
{return 1;}
else
{return 0;}
}

}
}
return 0;
}

//function used in password checking
function pak(&$string){
$salt=substr($string,0,2);
$string=crypt($string,$salt);
}

function teX($string,$class=""){
echo"
<table border=0 cellpadding=5 cellspacing=5>
<tr>
<td>
<font class=\"$class\">
<b>$string</b>
</font>
</td>
</tr>
</table>";

return 1;
}

?>

Any thoughts? I was working fine on my development server. Then I transfer the script to a different server and now I get this error.

Thanks in advance,
Christian

jatar_k

6:47 pm on Aug 20, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



try changing this and see what comes back

from
$result = mysql_query($query);

to
$result = mysql_query($query) or die (mysql_error());

willybfriendly

7:03 pm on Aug 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Check your connection to your db - password, db name, etc.

I assume that code was cut when you posted this (maybe in mysqlinfo.php?).

WBF

woemlavy

7:11 pm on Aug 20, 2004 (gmt 0)

10+ Year Member



After adding

$result = mysql_query($query) or die (mysql_error());

I get:

You have an error in your SQL syntax near '(password,'mykey') FROM users WHERE (handle='')' at line 1

jatar_k

9:10 pm on Aug 20, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



that would be the error reported from mysql

I assume that is this query dying
$query="SELECT AES_DECRYPT(password,'$AES_key') FROM users WHERE (handle='$handle')";

password should be between single quotes and $handle seems to be empty.

Try echo'ing $handle and see why it isn't getting assigned and put single quotes around password.

woemlavy

1:29 pm on Aug 23, 2004 (gmt 0)

10+ Year Member



I think the problem stemmed from my domains being virtual. There was a problem with the functions.php connecting to the database. My hosting team is looking at it right now. Thanks for all the help guys.

Christian