こんにちは、コンマなどの句読点を含む説明テキストを含むテキスト領域を持つフォームがあります。
これを使用したPHPスクリプトで
$description = empty( $_POST['inputDescription'])? 'NULL': "'" . mysql_real_escape_string($_POST['inputDescription']) . "'";
しかし、これであるカンマを含むテキストを送信すると、まだ構文エラーが発生します..
SQL 構文にエラーがあります。near を使用する正しい構文については、MySQL サーバーのバージョンに対応するマニュアルを確認してください。
どんな考えでも素晴らしいでしょう私は私の髪を引っ張っています!
EDIT 多くのコード (申し訳ありません)
<?php
session_start();
include "includes/connection.php";
$contact = $_POST['inputName'];
$company = $_POST['inputCompany'];
$region = $_POST['inputRegion'];
$address1 = $_POST['inputAddress1'];
$address2 = empty( $_POST['inputAddress2'])? 'NULL' : "'" . mysql_real_escape_string( $_POST['inputAddress2']) . "'";
$city = $_POST['inputCity'];
$county = empty( $_POST['inputCounty'])? 'NULL' : "'" . mysql_real_escape_string( $_POST['inputCounty']) . "'";
$postcode = $_POST['inputPostcode'];
$email = empty( $_POST['inputEmail'])? 'NULL' : "'" . mysql_real_escape_string( $_POST['inputEmail']) . "'";
$telephone1 = $_POST['inputPhoneOne'];
$telephone2 = empty( $_POST['inputPhoneTwo'])? 'NULL' : "'" . mysql_real_escape_string( $_POST['inputPhoneTwo']) . "'";
$website = empty( $_POST['inputWebsite'])? 'NULL' : "'" . mysql_real_escape_string( $_POST['inputWebsite']) . "'";
$description = empty( $_POST['inputDescription'])? 'NULL': "'" . mysql_real_escape_string($_POST['inputDescription']) . "'";
$userid = $_POST['inputUserID'];
if(
$contact == '' ||
$company == '' ||
$address1 == '' ||
$address2 == '' ||
$city == '' ||
$county == '' ||
$postcode == '' ||
$telephone1 == '' ||
$telephone2 == '' ||
$email == '' ||
$website == '' ||
$description == '' ||
$region == '' ||
$userid == ''){
$_SESSION['status'] = 'error';
} else {
mysql_query("INSERT INTO RegionalContacts
(`bID`,`user_id`,`Name`,`Company`,`Address1`,`Address2`,`City`,`County`,`Postcode`,`Telephone1`,`Telephone2`,`eMail`,`Website`,`Description`,`Region`)
VALUES(NULL,'$userid','$contact','$company','$address1',$address2,'$city',$county,'$postcode','$telephone1',$telephone2,$email,$website,$description,'$region')") or die(mysql_error());
$_SESSION['status'] = 'success';
}
header("location: regionalContacts.php");
?>