coding error?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
newbie9999
Forum Newbie
Posts: 2
Joined: Tue Nov 03, 2009 7:09 pm

coding error?

Post 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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: coding error?

Post by requinix »

The manual is always a good place to start. Take a look at the "single quotes" section of that page.
newbie9999
Forum Newbie
Posts: 2
Joined: Tue Nov 03, 2009 7:09 pm

Re: coding error?

Post by newbie9999 »

Thanks for your very unhelpful answer. Where do you suppose I got the rest of the code?
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: coding error?

Post 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
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply