Jump to content
Sign in to follow this  
ridesign

apostraphe casuing error in product name for search queries

Recommended Posts

Hi,

I have a contribution which logs search queries however when any product with a aphostrahe " ' " is searched it returns the following error:

 

1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'aim

')' a

 

insert into search_queries (search_text,search_result) values ('a','(pid 119) L'aim')

 

[TEP STOP]

 

Is there a way to resolve this?

 

thanks

+ merry christmas to everyone

Share this post


Link to post
Share on other sites
I have a contribution which logs search queries however when any product with a aphostrahe " ' " is searched it returns the following error:
Probably, this contribution does not use the osC way of doing an insert (using function tep_db_perform in includes/functions/database.php) and therefore it doesn't put a backslash in front of the apostrophe, therefore MySQL sees it as the end of the string and when it sees the next apostrophe: error.

The function tep_db_perform adds slashes in this line:

	  default:
		$query .= '\'' . tep_db_input($value) . '\', ';

where tep_db_input does the addslashes (a PHP function):

  function tep_db_input($string) {
return addslashes($string);
 }

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×