아직 게시 양식을 설정하지 않았으므로 일부 테스트 데이터로 생성 된 사전 구성된 배열이 있습니다. 배열은 다음과 같습니다MySQL 구문 오류 - 쿼리 배열
$query = mysql_query("INSERT INTO `Developers` (`Name`,`Email`,`Username`,`Password`,`Location`,`Platform`,`Developer_or_Designer`,`Tags`, `Paypal_Email`) VALUES (" . $ud['name'] . ", " . $ud['email'] . ", " . $ud['username'] . ", " .$ud['password'] . ", " . $ud['location'] . ", " . $ud['platform'] . ", " . $ud['developer_or_designer'] . ", " . $ud['tags'] . ", " . $ud['paypal_email'] . ")") or die(mysql_error());
그러나, 다음과 같은 오류와 함께 사망 :
이 배열에서$ud = array('name' => 'name', 'username' => 'username', 'password' => 'password', 'location' => 'london', 'platform' => 'mobile', 'developer_or_designer' => 'developer', 'tags' => 'hello', 'paypal_email' => '[email protected]', 'developer_or_client' => 'developer', 'email' => '[email protected]');
foreach ($ud as $key => $value) {
$value = mysql_real_escape_string($value);
}
, 그때 내 데이터베이스로 MySQL의 쿼리를 통해 데이터를 삽입하려고
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@email.com, username, password, london, mobile, developer, hello, [email protected])' at line 1
어디에서 잘못 될지 알려주실 수 있습니까?
업데이트를 확인하시기 바랍니다 (numberic가 아닌 경우). 당신은 여전히 따옴표가 필요 –
,'mysql_real_escape_string'의 살균 입력이 유효하지만 쿼리에 필요한 따옴표를 추가하지 않음 – Clive
또한 mysql_real_escape_string에 참조로 값에 액세스해야하는 효과가 필요하면 'foreach ($ ud as $ key => & $ 값) {'... – Clive