add source code from form to DB - quote error- tried addslashes..

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi I spent my 6+ hours trying yesterday to get a form to submit source code to the db.
The data gets in the db fine if it is just plain ascii.

The server has Magic Quotes on and this is bad according to most but should not stop it from
working- in fact it should just work.

Short Source is here can anyone tell my what addslash/addquote/removequote/htmlentities thing I
need to do? I've tried a few.

if (!empty($HTTP_POST_VARS["cname"]))
{
$cname= $HTTP_POST_VARS["cname"];
$source= $HTTP_POST_VARS["source"];

echo "<p></p>Form Source = <br>".htmlspecialchars($source)."<br>";

// try to make it insert right.
// not getting insert error but only getting partial data inserted for source.

//$source= "'.mysql_escape_string($source).'";
//$source = addslashes($source);
//$source = "'.mysql_escape_string(stripslashes($source)).'";

$sql = 
"INSERT INTO classes set 
cname='$cname',
source='$source'";

// the query prints on the screen fine
print "<br>".htmlspecialchars($sql)."<br>";

mysql_connect("a", "b", "c"); 

mysql_select_db("codepost"); 

mysql_query($sql);

echo "New code added!!!";
}

?>
<p></p>
<form action="addnewclass.php" method=POST> 
Class name: <input type="text" name="cname"> <br> 
Source: <textarea name="source" rows="10" cols="65"></textarea> <br> 
<input type="submit" value="Add Code"> 
</form> 



__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux