i have ajax call that send data to the pph script which inserts it into database.
If for some reasons I have error when connecting to database ot error on insertion how do i sent some sort of error to ajax.
<?php error_reporting(0); $a = $_POST['user']; $b = $_POST['name']; $c = $_POST['comment']; $link = mysql_connect('localhost', 'rot', 'joker1'); if (!$link) { $arr = array('connect' => 0); //die('Could not connect: ' . mysql_error()); } header('Content-type: application/json'); echo json_encode($arr); ?>
This is the only way i was able to pass json back to ajax. Can anyone suggest better way to do this. I would like to keep die statement but in order to get it working i had to comment it off