addslashes problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
FCB
Forum Newbie
Posts: 8
Joined: Mon Jun 21, 2004 6:12 pm

addslashes problem

Post by FCB »

i use the function but the slashes don't show up in the database. I use addslashes in a different script and it works just fine...

Code: Select all

<?php
$alt = $HTTP_POST_VARS['alt'];
$url = $HTTP_POST_VARS['url'];
$img = addslashes('<img src="'.$url.'" alt="'.$alt.'" />');
?>
thanks in advance!
~FCB
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

what does $img look like? I'm not sure but I don't think the slashes will show up in the database. Adding slashes escapes the character. So, when it's in a query, MySQL just inserts the escaped character, and doesn't interpret it.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Have a read through the Magic Quotes are Evil link in the Starter Pack at the top of this board.
Post Reply