[英]inserting data from php to database mysql table
我在將數據從php插入數據庫時遇到問題。
文件是: Patient.php
表名稱是: Patient_tbl
表格內部是: 頭像和教育
這是插入代碼: 以下代碼沒有問題,“教育”的值將插入到表中
$sql = "INSERT INTO " . $this->_table;
$sql .= "education,";
$params = array(
urlencode($patient->getEducation()),
);
return $this->exec($sql, $params);
}
但是現在這是我的問題, “頭像”不要插入表中
錯誤消息是: “無法准備查詢。”
$sql = "INSERT INTO " . $this->_table;
$sql .= "education, avatar, ";
$params = array(
urlencode($patient->getEducation()),
urlencode($patient->getAvatar()),
);
return $this->exec($sql, $params);
}
我有什么問題? 我找不到解決方案。
非常感謝您的幫助。
謝謝
基本語法sql查詢“ INSERT”為
INSERT [INTO] tbl_name [(col_name,...)]
VALUES (expression,...),(...)
如果使用某些參數,則需要添加括號,如下所示:
$sql = "INSERT INTO " . $this->_table;
$sql .= "(education, avatar) VALUES (?, ?)";
$params = array(
urlencode($patient->getEducation()),
urlencode($patient->getAvatar()),
);
return $this->exec($sql, $params);
}
然后寫,在$ this-> exec中是什么?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.