【发布时间】:2016-03-11 19:50:07
【问题描述】:
include "include/connection.php";
$date= date("Y-m-d H:i:s");
$profile_comment="INSERT INTO `infotown_test`.`profile_comments` (`id`, `user_id`, `name`, `email`, `comments`, `date_and_time`) VALUES (NULL, '".$_REQUEST['user_id']."', '".$_REQUEST['name']."', '".$_REQUEST['email']."', '".$_REQUEST['comment']."', '".$date."')";
mysql_query($profile_comment);
header("location:company-profile.php?id=2");(why it's not working?)
【问题讨论】:
-
在该标题之前是否有任何 html 内容或回显?
-
使用 $id = mysql_insert_id();我认为它因为 id 而不起作用
-
在标头前检查查询错误。您应该在开发模式下开启错误报告。
-
在
header()函数之后尝试exit()。 -
危险:您使用的是an obsolete database API,应该使用modern replacement。您容易受到SQL injection attacks的影响,现代 API 可以让您更轻松地从 defend 中获得。
标签: php