Im trying to insert a string into a database that contains ( ) in the text, this seems to be breaking the query.... does anyone know how to do this?
Thanks!
| SitePoint Sponsor |

Im trying to insert a string into a database that contains ( ) in the text, this seems to be breaking the query.... does anyone know how to do this?
Thanks!


Since all text type fields have to be surrounded by quotes in your query anyway, parentheses inside the string has no effect. If you're running into a problem because your input has parentheses in it, you're doing something else very wrong.
This would run just fine:
Other characters might give you problems if you don't handle them somewhere, like quotes. You should pass your input through mysql_real_escape_string() before using it in a query at the least.PHP Code:$name = "Dan";
$favoriteColor = "Blue (or cyan)";
mysql_query("INSERT INTO table (name, favoriteColor) VALUES ('$name', '$favoriteColor')", $connection);
17-29% of paid ad clicks are fraudulent. Get protected with Improvely, your online marketing dashboard.
→ Conversion tracking, click fraud detection, A/B testing and more.

Hi Dan, I'm trying to use the mysql_real_excape_string but I always receive an error "Called to undified function"... isnt this a built in function?


You may have a very old copy of PHP on your server. That function is listed in the manual as 4.3.0+ or 5.0+.
17-29% of paid ad clicks are fraudulent. Get protected with Improvely, your online marketing dashboard.
→ Conversion tracking, click fraud detection, A/B testing and more.


I take it the above is supposed to be mysql_real_escape_string? (no "x")... it was implemented in 4.3.0. So anything <= and you are good to go!Originally Posted by Gexus
Michael R. Sikora
www.blue-eyedesign.com
{redesigning web design}
Bookmarks