Jump to content

[SOLVED] allowing html tags in sql submit


Zeradin

Recommended Posts

I am trying to update a field in my sql table from an html form like this:

 

if ($pblurb != NULL) {
$pblurbquery = 'UPDATE users SET pblurb = "'.$pblurb.'" WHERE username = "'.$username.'"';
$pblurbresult=mysql_query($pblurbquery);

 

but i want the input to allow html tags. When they are included in the form i get a return code 4 and it does not change the entry. how do i allow for html in my input?

 

i know this is probably a common problem but sifting through all the replies that sound kind of like this is proving to be difficult.

 

thanks!

Link to comment
https://forums.phpfreaks.com/topic/122776-solved-allowing-html-tags-in-sql-submit/
Share on other sites

if ($pblurb != NULL) {
mysql_real_escape_string($pblurb);
$pblurbquery = 'UPDATE users SET pblurb = "'.$pblurb.'" WHERE username = "'.$username.'"';
$pblurbresult=mysql_query($pblurbquery);
}

 

^ That did not work. Did I not understand properly?

Do this:

if(!$pblurbresult=mysql_query($pblurbquery)) echo mysql_error();

this will display any mysql errors

 

And problem with query

$pblurbquery = "UPDATE users SET pblurb = '$pblurbEscaped' WHERE username = '$username'";

 

if ($pblurb != NULL) {
$pblurbEscaped = mysql_real_escape_string($pblurb);
$pblurbquery = "UPDATE users SET pblurb = '$pblurbEscaped' WHERE username = '$username'";
$pblurbresult=mysql_query($pblurbquery);
if(!$pblurbresult=mysql_query($pblurbquery)) echo mysql_error();
}

 

that didn't do anything differently =(

if ($pblurb != NULL) {
$pblurbEscaped = mysql_real_escape_string($pblurb);
$pblurbquery = "UPDATE users SET pblurb = '$pblurbEscaped' WHERE username = '$username'";
if(!$pblurbresult=mysql_query($pblurbquery)) echo mysql_error();
}

Try

echo $pblurbquery;

to see if query is well formed

UPDATE users SET pblurb = "This is my profile blurb. I\'m worried quotes are a problem." WHERE id = 7Return Code: 4

 

when it shows the profile blurb it puts it in bold... shit i took the bold tag out and it still has the error, it's obviously another problem.

 

i changed it to id to make it more simple as well

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.