我的代码是将从表单发布的值插入到表中。 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