且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP选择列表-在数据库中插入多个值

更新时间:2023-01-22 11:23:14

还有一个额外的结束括号应删除.您不检查查询是否成功.

There is an extra closing bracket that should be removed. You are not checking if your query was successful or not.

$carGroups = mysql_query("INSERT INTO car_groups VALUES('$company','$cars[$i]]')"); 

应该是:

$carGroups = mysql_query("INSERT INTO car_groups VALUES('$company','$cars[$i]')") or die(mysql_error()); 

由于$ cars是一个数组,因此可以使用 print_r

Since $cars is an array, you can print its content using print_r or var_dump:

print_r($cars);
var_dump($cars);

有用的读物​​:
如何在PHP中获得有用的错误消息?
不建议使用mysql_ *函数

Useful reading:
How to get useful error messages in PHP?
mysql_* functions are deprecated