mysql syntax error when try insert ' symbol

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
aigarzzz
Forum Newbie
Posts: 9
Joined: Thu Apr 06, 2006 1:43 am

mysql syntax error when try insert ' symbol

Post by aigarzzz »

how can i save in mysql db string where is ' symbol? every time i want do it, it genereates error, for example
$Name="my'name";
$this->query = "INSERT INTO Rooms (Name) VALUES ('$Name') ";
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Code: Select all

mysql_real_escape_string($Name);
Post Reply