이 간단한 형태가 왜 작동하지 않는지 설명해주십시오.mysql 실제 이스케이프 문자열은 아무 것도 반환하지 않음
문제는 제가 mysql_real_escape_string()
을 사용할 때 아무 것도 없습니다. 제거하면 완벽하게 작동합니다. 여기서 문제가 무엇인지 잘 알고 계시나요?
이 전체 간단한 코드입니다,
<?php
// Loop the post fields
$postFields = array('username', 'password', 'checkSubmission');
$postArray = array();
foreach($postFields as $postVal){
$postArray[$postVal] = mysql_real_escape_string($_POST[$postVal]);
}
print_r($postArray);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Signin</title>
<head>
</head>
<body><? echo $error;?>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post" id="signinForm">
Username: <input type="text" name="username" value="" />
Password: <input type="password" name="password" value="" />
<input type="hidden" name="checkSubmission" value="1" />
<input type="submit" name="Submit" value="Signin" />
</form>
</body>
</html>
편집 : mysql_real_escape_string()
Array ([username] => [password] => [checkSubmission] =>)
을 사용 그리고 이것은 print_r()
mysql_real_escape_string()
없이
Array ([username] => thre[password] => werr[checkSubmission] => 1)
때
print_r()
가 비어 있습니다
도움 주셔서 감사합니다.
당신의 반환을 넣을 수 ? –
질문이 업데이트되었습니다. 잠시만 기다려주십시오. – itsme
데이터베이스에 연결되어 있습니까? mysql_real_escape_string은 데이터베이스에 연결되어있는 경우에만 작동한다. –