Jump to content

[SOLVED] slashes and database


davidsakh

Recommended Posts

I'm trying to break my database. I was able to successfully insert:

 

blah? "lol" 'wee''

 

into the database, so I think I'm cleaning the strings properly, but when I print it out for the user inside of an input field, 'wee' isn't displayed, because the slashes aren't added.

 

in the source, i see:

 

value='blah? "lol" 'wee'' />

 

so, I addslashes(), and this works, but the user sees slashes around "lol" when I don't want her to.

 

Any help would be greatly appreciated. Security is not my strong point.  :-\

Link to comment
https://forums.phpfreaks.com/topic/145033-solved-slashes-and-database/
Share on other sites

When displaying data that contain quotes you need to use the function htmlentities with then ENT_QUOTES option:

<?php
$str = 'blah? "lol" ' . "'wee'";
echo '<input type="text" value="' . htmlentities($str,ENT_QUOTES) . '">';
?>

 

Ken

When displaying data that contain quotes you need to use the function htmlentities with then ENT_QUOTES option:

<?php
$str = 'blah? "lol" ' . "'wee'";
echo '<input type="text" value="' . htmlentities($str,ENT_QUOTES) . '">';
?>

 

Ken

 

prompt and dead-on. It works.

 

I apologize for my stupidity. Thanks. :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.