September 30, 201016 yr I have product which I need to indicate is 3" (inches) but cannot because by entering " it thinks that the query is over... Anyways around this? Chris
September 30, 201016 yr Use backslash to escape. e.g SELECT "3\" inches"; http://dev.mysql.com/doc/refman/5.0/en/string-syntax.html
September 30, 201016 yr Always call mysql_real_escape_string on any data you are submitting as SQL. For example (from http://php.net/manual/en/function.mysql-real-escape-string.php): <?php // Connect $link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password') OR die(mysql_error()); // Query $query = sprintf("SELECT * FROM users WHERE user='%s' AND password='%s'", mysql_real_escape_string($user), mysql_real_escape_string($password)); ?> This will automatically escape problematic characters, freeing you from the danger of malformed queries or security risks from SQL injection.
Create an account or sign in to comment