punctuation problem with quesry search

I am working on a site that deals with businesses. Some of them have
apostrophies in the name. Is there an easy way to get results without worrying about if the user added the apostrophy in the query?

Go Go Gadget query

You don’t have to worry about it. PHP automatically (by default, that is, it depends on configuration) escapes quotes.

I am doing a search by name. When I type in Tinas Italian Kitchen
I get a no result return. When I type In Tina’s Italian kitchen, I get the result that I am looking for

The other problem I am having, is trying to create an alphabetical search.
I use this line in the code:
$sql = "SELECT id,restName, restAddress, restCity, restState,restZip, restCuisine, restCuisine02,restType, restPhone, restFax, restWeb, deliveryRadius,
delivery_time, restHours, restFeature, restMap FROM $table_name WHERE restName = like b%;

the result returns this:
Parse error: parse error, expecting T_STRING' orT_VARIABLE’ or `T_NUM_STRING’ in /home/western/public_html/show_rest_alph.php on line 21

my input line on the page that calls that query is:

B

please help!!!

So type in “Tina’s Italian Kitchen”. I don’t see your problem, again. What isn’t it doing right?

Is it because you didn’t end the PHP tag before putting HTML code? Do you have a ?> before you have the HTML tag?

When using the keyword LIKE in MySQL I beleive the correct format is

SELECT * FROM table WHERE column IS LIKE “%col_”; or
SELECT * FROM table WHERE column LIKE “%col_”;

And to get an alphabetical result use the ORDER BY keyword.

Also the reason you are getting the correct response for 1 and not the other is that they are NOT the same. A WHERE clause is matched EXACTLY unless you use the LIKE keyword.

Manual pages:
http://dev.mysql.com/doc/mysql/en/SELECT.html (WHERE, ORDER BY)
http://dev.mysql.com/doc/mysql/en/Strin … tions.html (LIKE)

Thanks so much, here is the correct query:

$sql = “SELECT id,restName, restAddress, restCity, restState,restZip, restCuisine, restCuisine02,restType, restPhone, restFax, restWeb, deliveryRadius,
delivery_time, restHours, restFeature, restMap FROM $table_name WHERE restName like ‘b%’”;

Sponsor our Newsletter | Privacy Policy | Terms of Service