PHP中没有显示MYSQL中的数据

时间:2016-02-21 06:51:07

标签: php mysql

我正在尝试将一些数据存储在HTML表单上收集的MYSQL中。我没有收到任何错误,但是当我检查数据库时,没有添加行。 在页面上我有这个收集信息,剥离一些多余的数据,然后将其移动到工作类。

if (!empty($_POST['work1'])){
    $errors = array();
    $user_id = $userID;
    $type = "1";
    $location = substr($_POST["work1"], 37, -11);
    $work = new Work ($user_id,$type,$location);

     if($work->addWork())
        {
            if($work->sql_failure)  $errors[] = lang("SQL_ERROR");
        }
     if(count($errors) == 0) {
    $successes[] = $work->success;

     }
 }

工作班如下。

class Work
{
private $user_id;
private $type;
private $location;
public $sql_failure = false;
public $success = NULL;
public $status = false;

function __construct($user_id,$type,$location)
{
    $this->user_id = $user_id;
    $this->type = $type;
    $this->location = $location;
}
    public function addWork() {
       global $mysqli,$websiteUrl,$db_table_prefix;

            $i = 0;
            $stmt = $mysqli->prepare("INSERT INTO     ".$db_table_prefix."portfolio_info (
            user_id,
            type,
            location
            )
            VALUES (
            ?,
            ?,
            ?
            )");
        $stmt->bind_param("iis", $this->user_id, $this->type, $this->location);
        $stmt->close();
        return $i;
    }
  }

0 个答案:

没有答案