Jump to content

pasting quotes from db inside a textarea


anarchoi

Recommended Posts

I'm guessing you're doing this to be able to edit the entry, and then do an UPDATE query. In that case, use htmlspecialchars() and a user defined function unhtmlspecialchars(), to keep the data intact.

 

When echoing from the database, use htmlspecialchars(), and before inserting the data back in, use unhtmlspecialchars:

 

function unhtmlspecialchars($string) {

$string = str_replace('&', '&', $string);

$string = str_replace('"', '"', $string);

$string = str_replace('<', '<', $string);

$string = str_replace('>', '>', $string);

return $string;

}

 

I refuse to use the [ code ] tags, since they break the ampersands >:(

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.