Jump to content

[SOLVED] I don't understand what's wrong with this query!!!


weemikey

Recommended Posts

Thanks in advance for any help! I have this little query to look for any records that ALREADY use the entered screen name. Here's my query (built in php):

$name_sql = "SELECT member.screen_name,
		      member.public_email
          FROM	member
	  WHERE  member.screen_name = ".$screen_name;


//mysql_query returns true for success or false for error
$result = mysql_query($name_sql,dbconnect()) or die(mysql_error($mysql));

 

If the user had entered "weemikey" as a screen name, for example, the error I would get is 'Unknown column 'weemikey' in 'where clause'. So I take it mysql thinks the value of my variable $screen_name is a column in the database? I am using all kinds of queries that look just like this and I do NOT understand why it's doing this. Any ideas that are so obvious I would have walked right by?

$name_sql = "SELECT member.screen_name, member.public_email FROM member WHERE  member.screen_name = '$screen_name'";

 

I think that should work ;)

 

$name_sql = "SELECT member.screen_name, member.public_email FROM member WHERE  member.screen_name = '" . $screen_name . "'";

 

Try that if the first doesn't. I think they should both work though.

 

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.