我是 PHP 开发新手
当我尝试向数据库提交数据时遇到一些问题,这是我试图插入到数据库名称主题和图像中的代码。
$user = '1';
$title = mysql_real_escape_string($_POST['title']);
$msg = mysql_real_escape_string($_POST['msg']);
$date = date('Y-m-d H:i:s');
$img= "";
$iname = $_FILES['file_1']['name'];
$temp4 = $_FILES['file_1']['tmp_name'];
move_uploaded_file($temp,"upload/".$iname);
$path = "upload/".$iname;
if (isset($_POST['submit']))
{
$sql = mysql_query("INSERT INTO topic (UserID, Title, MsgBody, DateTime) VALUES('".$user."', '".$title."', '".$msg."', '".$date."')");
$sql2 = mysql_query("INSERT INTO image (TopicID, ImgPath) VALUES('".mysql_insert_id()."', '".$path."')");
}
else
{
echo "error";
}