Jump to content

My Simple Query is not working.


lpxxfaintxx

Recommended Posts

Very frustrating.

 

I have echoed out $sessid and $friendid to make sure that data is indeed stored in those two variables.

 

 

$query = mysql_query("SELECT * FROM friends WHERE username = '$sessid' AND friendname = '$friendid'") or die(mysql_error());
$result = mysql_query($query);
$row = mysql_fetch_array($result); 
	$num_results = mysql_num_rows($result);
		if ($num_results > 0){
		$isfriend = 'y';

		}else{
	$isfriend = 'n';
		} 

 

 

Error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/q94/public_html/alumnify.com/profile.php on line 46

 

 

Any ideas? Thanks a bunch.

Link to comment
https://forums.phpfreaks.com/topic/142447-my-simple-query-is-not-working/
Share on other sites

$query = "SELECT * FROM friends WHERE username='$sessid' AND friendname='$friendid'";
$result = mysql_query($query) or die(mysql_query());
$num_results = mysql_num_rows($result);
if ($num_results > 0){
$row = mysql_fetch_array($result); 
$isfriend = 'y';
} else { $isfriend = 'n'; }

 

you were trying to run mysql_query() on $result which allready contained the result of a string processed by mysql_query()[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.