Reputation: 167
function newpage($user_id,$page_title,$page_name,$page_content){
if(!$stmt=$this->_conn->prepare("INSERT INTO pages(user_id,heading,name,content,created)values(?,?,?,?,NOW())")){
echo $this->_conn->error;
}
$stmt->bind_param('isss',$user_id,$page_title,$page_name,$page_content);
if(!$stmt->execute()){
return false;
}else{
return true;
}
}
any problems in the query, used mysqli prepared statements, query contain NOW() for current time..in mysql db 'created' is changed to "sting(20)"
error is
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 Fatal error: Call to a member function bind_param() on boolean in C:\program data2\xampp\htdocs\engine\admin\cms.class.php on line 15
**
Solved...
**
Upvotes: 0
Views: 464
Reputation: 3986
Try this:
function newpage($user_id,$page_title,$page_name,$page_content){
if(!$stmt=$this->_conn->prepare("INSERT INTO pages
(user_id,heading,name,content,created)
values (?,?,?,?,NOW())")) {
echo $this->_conn->error;
}
$stmt->bind_param('isss',$user_id,$page_title,$page_name,$page_content);
if(!$stmt->execute()) {
return false;
} else {
return true;
}
}
Upvotes: 0
Reputation: 566
I think ')' is missing
"INSERT INTO pages(user_id,heading,name,content,created)values(?,?,?,?,NOW())"
Upvotes: 3