我的代碼是將從表單發佈的值插入到表中。 CODE:如何使用我的PHP代碼將值插入到外鍵字段?
1 $email1 = $_POST['txtemail'];
2 $user1 = $_POST['txtuser'];
3 $date1 = $_POST['txtdate'];
4 $subject1 = $_POST['txtsubject'];
5 $percent = $_POST['txtpercent'];
6 $percent1 = (string) $percent;
7 $query = "insert into personal_record values '','$email1','$user1','$date1','$subject1','$percent1'";
8 $result = mysql_query($query,$link);
這是我的代碼,它給錯誤:
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 protected]','Jugal','29 Mar 2011 13:28:42','jquery','40'' at line 1
請幫我儘快...! 請幫忙。
你缺少括號:可以將括號中的值開始它需要'VALUES(.....)' – 2011-03-29 18:09:33
而且,你的代碼很容易受到[SQL注入](HTTP:/ /stackoverflow.com/questions/601300/what-is-sql-injection)。 – 2011-03-29 18:09:55