By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,751 Members | 1,175 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,751 IT Pros & Developers. It's quick & easy.

PHP Error Character (HELP!)

werks
100+
P: 220
Hello PHP experts how can you detect ' character in your search field?
Because every time I input the word hilgard's it returns an error I think because of the character '. This is the error

Expand|Select|Wrap|Line Numbers
  1. Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Title LIKE '%hilgard's%';'., SQL state 37000 in SQLExecDirect in D:\wamp\www\Online Library\opac.php on line 76
  2. [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Title LIKE '%hilgard's%';'.
  3.  
tnx in advance.

--
Kenneth
"Better Than Yesterday"
Feb 14 '08 #1
Share this Question
Share on Google+
2 Replies


dlite922
Expert 100+
P: 1,584
Hello PHP experts how can you detect ' character in your search field?
Because every time I input the word hilgard's it returns an error I think because of the character '. This is the error

Expand|Select|Wrap|Line Numbers
  1. Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Title LIKE '%hilgard's%';'., SQL state 37000 in SQLExecDirect in D:\wamp\www\Online Library\opac.php on line 76
  2. [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Title LIKE '%hilgard's%';'.
  3.  
tnx in advance.

--
Kenneth
"Better Than Yesterday"
Its about time you know about a little some'n some'n called


After you studied it, then do learn how to prevent it:

http://us3.php.net/manual/en/functio...ape-string.php

Only you have MS SQL and not MySQL, but you get the point.

If you're still not satisfied.

Just use string replace

http://us3.php.net/manual/en/function.str-replace.php

[PHP]
str_replace("'", "\'", $sqlString);



[/PHP]

Get it?, got it?, gooOOood!
Feb 14 '08 #2

werks
100+
P: 220
Thanks dlite922 I learned a lot! All the links you post is very useful. Than you very much..

--
Kenneth
"Better Than Yesterday"
Feb 14 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.