I am working on my first ever .php application! All I am doing is posting some data to a database: simple stuff.
Right now, everything works fine, I can send my data to the DB no problems. However, I want to return an error message to my Objective-c application. I have the try and catch statements to make sure I connect to the DB, and if there is an error I would like to communicate that back to my application.
Here is some of what I have so far:
$dsn='mysql:dbname=******;host=******;';
$user='******';
$pass='******';
try {
/* obtain a database connection handle */
$pdo = new PDO($dsn, $user, $pass);
}
catch (PDOException $exception) {
echo("Failed to connect to the database. Error: " . $exception->getMessage());
}
Also, is it possible to set a limit for how long the PDO will attempt to connect to the database?
Right now when I purposely put in something invalid, it tries to connect for a long time.
If you’re trying to do what I think you are, it doesn’t work like that.
If you want to pass the error message to an Objective-C application, you will need to pipe, write contents to a file, or write the error to
STDERRand capture it from the Objective-C application.What exactly are you trying to accomplish? Calling a PHP script from an Objective-C script?