Jump to content

mysql_real_escape_string not working


ecabrera

Recommended Posts

the mysql_real_escape_string does not add slashes when it enter my db y

 

if(isset($_POST['submitbtn'])){

//will open up the db connection
require_once"../includes/connect.php";

$errors = "";
$welcometitle = mysql_real_escape_string($_POST['welcometitle']);
$welcomesection = mysql_real_escape_string($_POST['welcomesection']);
$infotitle = mysql_real_escape_string($_POST['infotitle']);
$infosection = mysql_real_escape_string($_POST['infosection']);
$videotitle = mysql_real_escape_string($_POST['videotitle']);
$videosection = mysql_real_escape_string($_POST['videosection']);


if(isset($welcometitle, $welcomesection) && !empty($welcometitle) && !empty($welcomesection)){
	if(isset($infotitle, $infosection) && !empty($infotitle) && !empty($infosection)){
		if(isset($videotitle, $videosection) && !empty($videotitle) && !empty($videosection)){

	//adding them to the db
	//adding them to the db
$query = mysql_query("UPDATE `home` SET `welcometitle`=  '$welcometitle', `welcomesection`= '$welcomesection', `infotitle`='$infotitle', 
	`infosection`= '$infosection',`videotitle`= '$videotitle',`videosection`= '$videosection'") or die(mysql_error());

	header("location: http://www.website.org/control/edithome");

		}else{
			$errors = "Please fill in the Video Section";
		}
	}else{
		$errors = "Please fill in the Info Section";
	}
}else{
	$errors = "Please fill in the Welcome Section";
}

mysql_close();//will close the inlcude db connection
}

?>

Link to comment
https://forums.phpfreaks.com/topic/260050-mysql_real_escape_string-not-working/
Share on other sites

No. You don't want slashes stored in your database.

 

The idea is no different to escaping quotes within a quoted string.

 

echo 'This is some text with \'quotes\' in it.';

 

You don't expect the backslashes to show up when you echo this. The same theory applies to mysql_real_escape_string. You don't want the actual slashes stored in your database.

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.