php - PDO prepare stops script without giving error -


i looked on solutions couldn't find any. checked code , can't seem find errors it.

try {     $handle = new pdo("mysql:dbname=" . database . ";host=" . server, username, password);     $handle->setattribute(pdo::attr_errmode, pdo::errmode_exception);     $handle->setattribute(pdo::attr_emulate_prepares, false); } catch (exception $e) {     trigger_error($e->getmessage(), e_user_error);     exit; } $senddata = $handle->prepare("insert 'posts' (body, user, comments, likes, username, datetime) values(:body, :userid, 'none', 'none', :username, :datetime)"); $senddata->bindparam(':body',$this->body); $senddata->bindparam(':userid',$this->userid); $senddata->bindparam(':username',$this->username); $senddata->bindparam(':datetime',$this->datetime); $senddata->execute(); 

i determined code stops before reaches "bindparam" part. stops right after prepare call.

edit: turns out error in $handle part. declared handle elsewhere , didn't use "global" add inside function. feel stupid.

try:

try { $db = new pdo('mysql:host=localhost;dbname=datebase;charset=utf8', 'user', 'password'); $db->setattribute(pdo::attr_emulate_prepares, false); $db->setattribute(pdo::attr_errmode, pdo::errmode_exception);  }  catch(pdoexception $ex) { echo "something"; die(); }  $body = $_post['body']; $userid = $_post['userid']; $username = $_post['username']; $datetime = $_post['datetime']; $none = "none"; $senddata = $sb->prepare("insert `posts` (body, user, comments, likes, username, datetime) values(:body, :userid, :none, :none, :username, :datetime)"); $senddata->bindvalue(':body', $body); $senddata->bindvalue(':none', $none); $senddata->bindvalue(':userid', $userid); $senddata->bindvalue(':username', $username); $senddata->bidnvalue(':datetime', $datetime); $senddata->execute(); 

edited:

`posts` instead 'posts' 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -