【发布时间】:2012-06-07 00:23:01
【问题描述】:
是否可以有两个这样的mysqli查询?
mysqli_query($dblink, "INSERT INTO images (project_id, user_id, image_name, date_created, link_to_file, link_to_thumbnail, given_name) VALUES ('$project_id', '$user_id', '$image_name', '$date_created', '$link_to_file', '$thumbnail', '$ImageName')");
mysqli_query($dblink, "INSERT INTO images_history (project_id, user_id, image_name, date_created, link_to_file, link_to_thumbnail, given_name, day, month, year) VALUES ('$project_id', '$user_id', '$image_name', '$date_created', '$link_to_file', '$thumbnail', '$ImageName', '$day', '$month', '$year')");
基本上我想更新我的数据库中的两个表。有没有更好的方法来做到这一点?
【问题讨论】:
-
可以运行 2 个查询,当然可以。
-
您说有可能,但上述方法不起作用。它只是插入到图像中,而不是插入到 images_history 中。
-
好吧,也许您应该检查特定查询是否有问题,它与任何其他查询无关。
-
@PartisanEntity 您应该将
mysql_error()更改为mysqli_error(),因为两者是不同的,当mysqli查询失败时,mysql_error()不会给您任何回复。 -
当然您可以运行两个或十个或任意数量的查询。数量无所谓。问题与数量无关。只是执行第二个查询时出错。