CSV
ファイルをウェブサイト経由でデータベースに挿入しようとしています。スクリプトは正常に動作しますが、単一引用符を含むデータベースには値を挿入しません(たとえば、 "May's Flowers")。私はreal_escape_string
関数とstriplashes
を試しましたが、それは役に立たなかった。私は文字列として変数をキャストしようとしました。任意のヒント?コードの一重引用符で囲まれたCSV値は無視されます
パート:
if($_FILES["file"]["size"] > 0)
{
$file = fopen($filename, "r");
//skip first line
fgetcsv($file); // first line wont show but neither the 3r
while (($getData = fgetcsv($file, 1000)) !== FALSE)
{
$sql = "INSERT into accounts (accountnumber, accountname, bookccy, date)
values ('$getData[0]','$getData[1]','$getData[2]','$getData[3]')";
$result = mysqli_query($conn, $sql);
[準備文](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php)を使用して、[bind_param(http://php.net/manual/en /mysqli-stmt.bind-param.php)。これは、あなた自身の値を引用する必要性を回避します。 – aynber
例を挙げることができますか? @aynber – noel293
私はリンクされているドキュメントを読む、すべての例があります。 – aynber