note 26330 added to function.addslashes
| From: | galanis at ceid dot upatras dot gr | Date: | Sat, 26 Oct 2002 20:23:20 +0000 |
| Subject: | note 26330 added to function.addslashes | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-38595@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.
--
http://www.php.net/manual/en/function.addslashes.php
http://master.php.net/manage/user-notes.php?action=edit+26330
http://master.php.net/manage/user-notes.php?action=delete+26330
http://master.php.net/manage/user-notes.php?action=reject+26330