2016-07-19 15 views
1

PHPを使用してhtmlフォームからデータベースにデータを送信しようとすると、私はerror unexpected ; in line 6を取得し続けます。私は正確な原因を見つけることができません。dbエラーにフォームの値を送信

これはsend.phpのコードです:

<?php 
//Connecting to sql db. 
$connect = mysqli_connect("host","user","password","database"); 
//Sending form data to sql db. 
mysqli_query($connect,"INSERT INTO sw5_green (firstname_r, lastname_r, vid, occupation, address, firstname_s, lastname_s, country, amount, currency) 
VALUES ('$_POST[post_firstname_r]', '$_POST[post_lastname_r]', '$_POST[post_vid]', '$_POST[post_occupation]', '$_POST[post_address]', '$_POST[post_firstname_s]', '$_POST[post_lastname_s]', '$_POST[post_country]', '$_POST[post_amount]', '$_POST[post_currency]')"; 
?> 
+0

ありがとう:)それは働いた – Haf833

答えて

1

あなたは文の末尾に)が欠落しています。 )これを前に置く;

あなたが不足している

mysqli_query($connect,"INSERT INTO sw5_green (firstname_r, lastname_r, vid, occupation, address, firstname_s, lastname_s, country, amount, currency) 
VALUES ('$_POST[post_firstname_r]', '$_POST[post_lastname_r]', '$_POST[post_vid]', '$_POST[post_occupation]', '$_POST[post_address]', '$_POST[post_firstname_s]', '$_POST[post_lastname_s]', '$_POST[post_country]', '$_POST[post_amount]', '$_POST[post_currency]')"); 
+0

これは、適切な場所にはかなりありません。あなたの説明は正しいが、コード例は間違っている。 –

+1

@SimonShirleyありがとう。 Ans編集 –

0

、それを試してみてください)

「は、この

mysqli_query($connect,"INSERT INTO sw5_green (firstname_r, lastname_r, vid, occupation, address, firstname_s, lastname_s, country, amount, currency) 
VALUES ('$_POST[post_firstname_r]', '$_POST[post_lastname_r]', '$_POST[post_vid]', '$_POST[post_occupation]', '$_POST[post_address]', '$_POST[post_firstname_s]', '$_POST[post_lastname_s]', '$_POST[post_country]', '$_POST[post_amount]', '$_POST[post_currency]'))"; 
+1

あなたはVinod VTの答えと同じ間違いをコピーしました。 (彼はそれ以来修正している)。 –

+0

ちょうど時間をチェックしてください、ちょうど答えを入力してください、それは数秒前にそれを与えられたものです@SimonShirley –

+0

がコピーされているという意味ではありません。答えとコメントは急速に連続していましたが、まったく同じタイプミスであったことは奇妙に思えました。 –

0

間違った構文

と$ _POSTをクエリを使用してコードを置き換え[ post_firs tname_r] 'は$ _POST [' post_firstname_r ']にする必要があります。

保存する前に必ずデータをエスケープしてください。

関連する問題