...

View Full Version : SELECT table FROM field



?gkj
07-07-2003, 09:30 PM
The problem I am having is that I want a system where if I type in my client's name, it will find them in my database. My code is:



$result = mysql_query("SELECT * FROM clients WHERE Name = $name",$db);


which is fine, the trouble comes into play when I put a space in the "Name" field in my database. (ex I want "Joe Smith" instead of "JoeSmith")

So when I put a space in the name, the code won't read the database entry, but if I leave no spaces it works fine.

Can anyone help me? Thank in advance.

raf
07-07-2003, 09:35 PM
spaces or not shouldn't make a difference. As long as both values (value in db and value of $name is the same)
Maybe print the value for $name to look if you have the complete name inthere
(with print $name; )

?gkj
07-07-2003, 10:38 PM
Thanks,


I figured out the problem. I put single quotations around $name and it worked correctly.

raf
07-07-2003, 11:10 PM
:o i overlooked that :o



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum