note 26330 rejected from function.addslashes by nicos
| From: | nicos@php.net | Date: | Sat, 26 Oct 2002 21:26:23 +0000 |
| Subject: | note 26330 rejected from function.addslashes by nicos | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-38601@lists.php.net to get a copy of this message | ||
I thought that slashes were added before an insert query but this appears to be wrong. This code:
mysql_query("insert into lyrics1 (lyrics) values
('$form_value_containing_single_quotes')");
$query = mysql_query("select lyrics from lyrics1 where song_id='$song_id'");
$source_lyrics = mysql_fetch_array($query);
$lyrics = $source_lyrics['lyrics'];
mysql_query ("insert into lyrics2 (lyrics) values ('$lyrics')");
echo 'ok';
doesn't affect table lyrics2. If instead I put $lyrics =
addslashes($source_lyrics['lyrics']); in the line before the last insert, it will work
fine.
The data from the form was inserted into the database without problems. If this appears sensible, I
probably had a wrong impression about when addslashes does its job.