Author Topic: apostrophe problem  (Read 25597 times)

0 Members and 1 Guest are viewing this topic.

Offline clubbu

  • Newbie
  • *
  • Posts: 47
    • View Profile
apostrophe problem
« on: August 12, 2011, 09:17:45 AM »
Hello,
I have a problem when I try to change or add an image or keyword in the description field where there is an apostrophe.

The error displayed is as follows:

DB ErrorBad SQL QuerySELECT word_textword_id FROM 4images_wordlist WHERE word_text IN ('laquila''anno''sisma''capoluogo''dellabruzzo''anno''sisma''foto''del''centro''storico''recintato''chiuso''pubblico''l'aquila', 'abruzzo', 'sisma', 'centro', 'storico', 'centro storico', 'recintato', 'chiuso', 'ricostruzione')
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '
aquila', 'abruzzo', 'sisma', 'centro', 'storico', 'centro storico', 'recintato',' at line 3

DB Error
Bad SQL QueryINSERT INTO 4images_wordmatch (image_idword_idname_matchdesc_matchkeys_matchSELECT DISTINCT 220word_id001 FROM 4images_wordlist WHERE word_text 'l'aquila'
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '
aquila'' at line 4

DB Error
Bad SQL QuerySELECT word_textword_id FROM 4images_wordlist WHERE word_text IN ('laquila''anno''sisma''capoluogo''dellabruzzo''anno''sisma''foto''del''centro''storico''recintato''chiuso''pubblico''l'aquila', 'abruzzo', 'sisma', 'centro', 'storico', 'centro storico', 'recintato', 'chiuso', 'ricostruzione')
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '
aquila', 'abruzzo', 'sisma', 'centro', 'storico', 'centro storico', 'recintato',' at line 3

DB Error
Bad SQL QueryINSERT INTO 4images_wordmatch (image_idword_idname_matchdesc_matchkeys_matchSELECT DISTINCT 219word_id001 FROM 4images_wordlist WHERE word_text 'l'aquila'
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '
aquila'' at line 4

DB Error
Bad SQL QuerySELECT word_textword_id FROM 4images_wordlist WHERE word_text IN ('laquila''anno''sisma''capoluogo''dellabruzzo''anno''sisma''foto''del''centro''storico''recintato''chiuso''pubblico''l'aquila', 'abruzzo', 'sisma', 'centro', 'storico', 'centro storico', 'recintato', 'chiuso', 'ricostruzione')
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '
aquila', 'abruzzo', 'sisma', 'centro', 'storico', 'centro storico', 'recintato',' at line 3

DB Error
Bad SQL QueryINSERT INTO 4images_wordmatch (image_idword_idname_matchdesc_matchkeys_matchSELECT DISTINCT 218word_id001 FROM 4images_wordlist WHERE word_text 'l'aquila'
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '
aquila'' at line 4



the problem is the word --> l'aquila

thanks
paolo

Rembrandt

  • Guest
« Last Edit: August 12, 2011, 06:05:47 PM by Rembrandt »

Offline clubbu

  • Newbie
  • *
  • Posts: 47
    • View Profile
Re: apostrophe problem
« Reply #2 on: August 12, 2011, 11:41:24 AM »
Hello Rem,
will not work?

 :(

Rembrandt

  • Guest
Re: apostrophe problem
« Reply #3 on: August 12, 2011, 11:47:45 AM »
try this:

search in includes/search_utils.php:

$allwords_sql 
.= ($allwords_sql != "") ? ", '".$word."'" "'".$word."'";

replace:

$allwords_sql 
.= ($allwords_sql != "") ? ", '".addslashes($word)."'" "'".addslashes($word)."'";

search:

WHERE word_text 
'$key'";

and replace:

WHERE word_text 
'".mysql_real_escape_string($key)."'";


mfg Andi
« Last Edit: August 12, 2011, 06:04:43 PM by Rembrandt »

Offline clubbu

  • Newbie
  • *
  • Posts: 47
    • View Profile
Re: apostrophe problem
« Reply #4 on: August 12, 2011, 06:33:43 PM »
Thanks for your help Rem..

Work!!  :D :D