Jump to content

Recommended Posts

if you are meaning a way to keep quotes with it working well, please just let me know what to do:

1) between getting information from user and storing into the database

2) between taking from database and echoing

3) between taking from database and echoing within a text input (if different)

 

currently i have:

$mapped = array_map ('mysql_real_escape_string', $_POST);
$_POST = array_map ('htmlspecialchars', $mapped);

before submitting to the database, when I pull from database into text input... it would turn:

 

bob's house

 

into:

 

bob\

 

 

No, I can't explain what you're doing wrong besides what I just told you. I'm visiting some family during the holidays and I left my crystal ball at home.

 

Somehow you are doing something that is resulting in double escaping. You may be calling things like mysql_real_escape_string() multiple times, or you have magic quotes turned on which means either 1) you're running PHP 4, in which case you should upgrade, or 2) you turned it on manually, in which case I have no idea why you would do that.

$mapped = array_map ('mysql_real_escape_string', $_POST);

$_POST = array_map ('htmlspecialchars', $mapped);

 

that's the only thing being done to POST data before being entered into the database

 

i'm on PHP 5

 

never messed with magic quotes, don't even know how to turn it on

	$action = "UPDATE penguins SET ";
$updated = array();

if($_POST['code']==$passcode){
	if($_POST['area'] != $peng['area'] && $_POST['area'] != ""){
		$action .= "area='{$_POST['area']}', ";
		$updated[] = "area";
		}
	if($_POST['type'] != $peng['type'] && $_POST['type'] != ""){
		$action .= "type='{$_POST['type']}', ";
		$updated[] = "type";
		}
	if($_POST['points'] != $peng['points'] && $_POST['points'] != ""){
		$action .= "points='{$_POST['points']}', ";
		$updated[] = "points";
		}
	}

if($_POST['location'] != $peng['location'] && $_POST['location'] != ""){
	$action .= "location='{$_POST['location']}', ";
	$updated[] = "location";
	}
if($_POST['trapped'] != $peng['trapped'] && $_POST['trapped'] != ""){
	$action .= "trapped='{$_POST['trapped']}', ";
	$updated[] = "trapped status";
	}
$action = substr_replace($action,"",-2);
$action .=" WHERE ID='{$id}'";	

$count = count($updated);
if($count == 0){
	echo "<div class='penghead'>You didn't change anything.</div>";
	return;
}
else{

	$result = mysql_query($action) or die("SQL Error: " . mysql_error());

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.