0

It's been a long night and maybe I'm so tired I'm overlooking something simple, but this has me dumbfounded.

I know for a fact - 100% that these variables contain a value :
$receiver_id
$myid
$receiver_username

I defined them at the top of the page and echoed them and they all return their value, yet when I plug them into the query I get nothing (which normally would lead me to believe they don't contain a value or they are misspelled). If I use straight values in the query it works fine. I know beyond a shadow of a doubt that those variables all match up to a value in the table in proper column, no misspellings, etc.

What would make this query not work when I plug in the variables?

$nick="SELECT nick FROM address_book WHERE their_id='$receiver_id' AND my_id='$myid' AND their_username='$receiver_username'" or die(mysql_error());
	$nresult=mysql_query($nick);
	while($n=mysql_fetch_array($nresult)){
		$nickn=$n['nick'];}
2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by CFROG
0

It's been a long night and maybe I'm so tired I'm overlooking something simple, but this has me dumbfounded.

I know for a fact - 100% that these variables contain a value :
$receiver_id
$myid
$receiver_username

I defined them at the top of the page and echoed them and they all return their value, yet when I plug them into the query I get nothing (which normally would lead me to believe they don't contain a value or they are misspelled). If I use straight values in the query it works fine. I know beyond a shadow of a doubt that those variables all match up to a value in the table in proper column, no misspellings, etc.

What would make this query not work when I plug in the variables?

$nick="SELECT nick FROM address_book WHERE their_id='$receiver_id' AND my_id='$myid' AND their_username='$receiver_username'" or die(mysql_error());
	$nresult=mysql_query($nick);
	while($n=mysql_fetch_array($nresult)){
		$nickn=$n['nick'];}

try to echo $nickn; inside the while statement.

0

Thanks for the quick reply, but I finally managed to get it. I accidentally overwrote one of the variables farther down in the script and when I echoed at the bottom of the page, obviously I got a result. I think I need to call it quits for the night, lol.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.