I am trying to return an error using jquery post function to retrieve the error.
So far I have written in php
$connect = mysql_connect("localhost","username","password") or die("Error connecting to the database.");
but i want to retunrn the message like so
$connect = mysql_connect("localhost","username","password");
if(!$connect){
$data['error'] = true;
$data['message'] = "Error connecting to the database.";
echo json_encode($data);
};
Help!!
Try this:
This will encode the error to a json string