4images Forum & Community

4images Issues / Ausgaben => Discussion & Troubleshooting => Topic started by: clubbu on August 12, 2011, 09:17:45 AM

Title: apostrophe problem
Post by: clubbu 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 Error: Bad SQL Query: SELECT word_text, word_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 Query: INSERT INTO 4images_wordmatch (image_id, word_id, name_match, desc_match, keys_match) SELECT DISTINCT 220, word_id, 0, 0, 1 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 Query: SELECT word_text, word_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 Query: INSERT INTO 4images_wordmatch (image_id, word_id, name_match, desc_match, keys_match) SELECT DISTINCT 219, word_id, 0, 0, 1 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 Query: SELECT word_text, word_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 Query: INSERT INTO 4images_wordmatch (image_id, word_id, name_match, desc_match, keys_match) SELECT DISTINCT 218, word_id, 0, 0, 1 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
Title: Re: apostrophe problem
Post by: Rembrandt on August 12, 2011, 11:24:51 AM

http://www.4homepages.de/forum/index.php?topic=29950.msg158671#msg158671
Title: Re: apostrophe problem
Post by: clubbu on August 12, 2011, 11:41:24 AM
Hello Rem,
will not work?

 :(
Title: Re: apostrophe problem
Post by: Rembrandt 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
Title: Re: apostrophe problem
Post by: clubbu on August 12, 2011, 06:33:43 PM
Thanks for your help Rem..

Work!!  :D :D