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'];}

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.

No result, I'm perplexed

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.