I'm trying to create a program that shows the emails of teachers. The name and emails of these teachers are in a database.
I took the sample code from Google and modified it, but it does not seem to work. I am also unable to resolve the error, as the message given is "Unknown error". How should I go about to debug / fix this error?
I have restarted the sql server, and tried tweaking the code in many many ways, but it doesn't seem to want to give me my result :( I have added the gae app to the applications list for the database as well.
The relevant code snippet is found here:
For security, I have changed the code so that the IP is 111.111.111.111 and the database is db.
<h2>Teachers:</h2>
<?php
// Create a connection.
$db = null;
if (isset($_SERVER['SERVER_SOFTWARE']) &&
strpos($_SERVER['SERVER_SOFTWARE'],'Google App Engine') !== false) {
// Connect from App Engine.
try{
$db = new PDO('mysql:host=111.111.111.111:3306;dbname=db', 'root', 'password');
}catch(PDOException $ex){
die(json_encode(
array('outcome' => false, 'message' => 'Unable to connect.', 'error' => $ex->getMessage())
)
);
}
}
try {
// Show existing guestbook entries.
foreach($db->query('SELECT * from db.teacher') as $row) {
echo "<div><strong>" . $row['title'] . " " .$row['name'] . "</strong> has email <br> " . $row['email'] . "</div>";
}
} catch (PDOException $ex) {
echo "An error occurred.";
}
$db = null;
?>
When I go to the website, this is what I am greeted with:
Teachers:
{"outcome":false,"message":"Unable to connect.","error":"SQLSTATE[HY000] [2002] Unknown error 4294967295"}
Thank you!!