0

I want to insert textbox values to Mysql. i'm using cPanel server here. I have read some articles and I've come up to this code. but it's not inserting to the database. i'm sure about the connection has been established. what am i doing wrong here? any help? here the code please feel free to edit it.

if (!empty($name) || !empty($email) || !empty($office_id) || !empty($title) || !empty($story)) {


    $save_sql = "INSERT INTO `tbl_story` (filename, name, email, office_id, title, story) VALUES ('$img_newname','$name','$email','$office_id','$title','$story')";

    $query = mysql_query($save_sql,$con) or die(mysql_error("Could not write information to the database")); 

    if (mysql_affected_rows($con) == 0) { 
                echo 'Your story was not created.'; 
            } else { 
                echo 'Your story was created successfully'; 
            } }
4

1 回答 1

0

您的所有查询参数都没有插入到数据库表中,或者只有“故事”列没有插入?

您确定连接已建立。以下几点可能对您有所帮助

  1. 如果您没有收到错误,您是否尝试设置 error_reporting on ,这可能会帮助您获得确切的错误。
  2. 也尝试回显 $save_sql; 这会给你一些提示。
  3. 尝试检查您为“故事”定义的数据类型
于 2013-10-29T08:36:07.533 回答