php - Pure JSON? Error: Value <br of type java.lang.String cannot be converted to JSONObject -


this error:

07-05 23:27:47.883: e/log_tag(2657): connection success  07-05 23:27:47.890: e/log_tag(2657): error parsing data <br /> 07-05 23:27:47.890: e/log_tag(2657): <font size='1'><table class='xdebug-error xe-fatal-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>  07-05 23:27:47.890: e/log_tag(2657): <tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> fatal error: call member function prepare() on non-object in c:\wamp\www\sample\insertorders.php on line <i>23</i></th></tr> 07-05 23:27:47.890: e/log_tag(2657): <tr><th align='left' bgcolor='#e9b96e' colspan='5'>call stack</th></tr> 07-05 23:27:47.890: e/log_tag(2657): <tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>time</th><th align='left' bgcolor='#eeeeec'>memory</th><th align='left' bgcolor='#eeeeec'>function</th><th align='left' bgcolor='#eeeeec'>location</th></tr> 07-05 23:27:47.890: e/log_tag(2657): <tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0010</td><td bgcolor='#eeeeec' align='right'>245224</td><td bgcolor='#eeeeec'>{main}(  )</td><td title='c:\wamp\www\sample\insertorders.php' bgcolor='#eeeeec'>..\insertorders.php<b>:</b>0</td></tr> 07-05 23:27:47.890: e/log_tag(2657): </table></font> 07-05 23:27:47.890: e/log_tag(2657): org.json.jsonexception: value <br of type java.lang.string cannot converted jsonobject 

this php code

$con=mysqli_connect($host, $username, $password)or die("cannot   connect");  mysqli_select_db($con,$db_name)or die("cannot select db");  if (!empty($_post)) { //initial query $query = "insert orders (tablenum, menuid) values (:table, :menuid) ";  //update query $query_params = array(     ':table' => $_post['tablenum'],     ':menuid' => $_post['menuid'] );  //execute query try {     $stmt   = $db_name->prepare($query);     $result = $stmt->execute($query_params); } catch (pdoexception $ex) {     $response["success"] = 0;     $response["message"] = "database error. couldn't add post!";     die(json_encode($response)); }     $response["success"] = 1;     $response["message"] = "username added!";     die(json_encode($response));}  

i've read lot error. i'm parsing html block, not pure json. can't define pure json need pin-point me php code have.

the real error line:

$stmt   = $db_name->prepare($query); 

should be:

$stmt   = $con->prepare($query); 

$db_name string while $con actual mysqli connection can use prepare queries. json error wrapped around actual exception that's being thrown , displayed xdebug.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -