Author Topic: MySQL query problem, maybe bug  (Read 2658 times)

0 Members and 1 Guest are viewing this topic.

Offline ericTopic starter

  • Irregular
  • Posts: 1
    • View Profile
MySQL query problem, maybe bug
« on: January 08, 2003, 10:57:57 AM »
my query:

$query = \"INSERT INTO $whattype1 (id, title, description, size, category, bywho, uname, boxurl, urls, type, dateadded) VALUES (\'\', \'$title1\',\'$description1\',\'$size1\',\'$category1\',\'$bywho1\',\'$uname1\',\'$boxurl1\',\'$urls1\',\'$type1\',\'$datetime\')\";

it works but if I try to use   \'   or   , in the description it gives errors, it\'s because in the query, it uses    \'    and     ,   seperate.                    

Offline delamitri

  • Irregular
  • Posts: 7
    • View Profile
MySQL query problem, maybe bug
« Reply #1 on: January 08, 2003, 11:04:18 AM »
Its because of the \', the commas wont affect it.

When adding texual data into the database, its a good idea to use addslashes and when retreiving it back out, use stripslashes.

so for instance you should use:

Code: [Select]
$query = "INSERT INTO $whattype1 (id, title, description, size, category, bywho, uname, boxurl, urls, type, dateadded) VALUES (\'\', \'".addslashes($title1)."\',\'".addslashes($description1)."\',\'$size1\',\'$category1\',\'$bywho1\',\'$uname1\',\'$boxurl1\',\'$urls1\',\'$type1\',\'$datetime\')";


See http://www.php.net/manual/en/function.addslashes.php for other ways of formatting text for database and urls.

Hope this helps

Kevin[/code][/url]