Php and MySQL Long Text Problem

Though mysql casting is one of the way to address special characters in the text,there is another simple function which lets  you to do this..

This http://php.net/manual/en/function.mysql-real-escape-string.php  lets you to do this very easily



require_once'config1.php';
$sn = mysql_connect($mysql_hostname, $mysql_user, $mysql_password);
mysql_select_db($mysql_database, $sn);
$a=file_get_contents("http://www.google.com");
echo $a;
$a1="";

//Making Mysql escape string

$query = sprintf("INSERT INTO `testingtable` ( `no` , `a1` )VALUES (%d , '%s')",
mysql_real_escape_string($a1,$sn),
mysql_real_escape_string($a,$sn));
//Inserting the text

mysql_query($query, $sn);

You can use this function for Insert and Update also

This entry was posted on Sunday, January 25th, 2009 at 6:27 am and is filed under Php, SQL. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.

Post a Comment