Page 1 of 1

coding error?

Posted: Tue Nov 03, 2009 7:16 pm
by newbie9999
Just learning ...

This retrieves zero records:

$z="55555";
$query = 'SELECT * FROM `UserNames` WHERE Zip="$z"';

This gets them all:

$query = 'SELECT * FROM `UserNames` WHERE Zip="55555"';

What's the difference and how do I use a variable name?

Thanks,

newbie9999

Re: coding error?

Posted: Tue Nov 03, 2009 7:38 pm
by requinix
The manual is always a good place to start. Take a look at the "single quotes" section of that page.

Re: coding error?

Posted: Wed Nov 04, 2009 11:53 am
by newbie9999
Thanks for your very unhelpful answer. Where do you suppose I got the rest of the code?

Re: coding error?

Posted: Wed Nov 04, 2009 12:47 pm
by AbraCadaver
newbie9999 wrote:Thanks for your very unhelpful answer. Where do you suppose I got the rest of the code?
Not from the link that tasairis posted.

Check it and learn how variable interpolation works within strings that are single quoted as opposed to double quoted.

-Shawn