|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
No ' allowed in MySQL
I am new at MySQL, PHP, and Apache. I have written a comments section on my page and use an INSERT statement to send the comment to a table. Everything works perfectly EXCEPT it will not accept a single quote ('). All other characters are accepted.
The comment field is TEXT. |
|
#2
|
||||
|
||||
|
You're probably using single quotes in your mysql query.
Try parsing the comments with addslashes() before you post them to the database, that will escape all `dangerous' characters.
__________________
This is my code. Is it not nifty? "The biggest problem encountered while trying to design a system that was completely foolproof, was, that people tended to underestimate the ingenuity of complete fools." ---Douglas Adams Join the Itsacon fanclub! Zero Tolerance: Spammers banned so far: 275
![]() |
|
#3
|
|||
|
|||
|
RE: No ' allowed in MySQL
Yes, that was what was wrong. I did not have the addslashes() and didn't realize I needed them. Thanks!
|
|
#4
|
||||
|
||||
|
You're welcome
![]() |
|
#5
|
|||
|
|||
|
Quote:
You need to escape out a single quote character (') and ensure that it becomes a pair of single quotes ('') before trying to put it into a SQL statement. In PHP, the easy way is just run your string through the mysql_real_escape_string() function before the code that tries to put it into the database. See... http://us3.php.net/manual/en/function.mysql-real-escape-string.php |
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > No ' allowed in MySQL |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|