I am working with a php application deployed on Windows Azure.
I am running into an issue that results in the error:
"The page cannot be displayed because an internal server error has occurred."
when I look at the logs I see:
HTTP Error 500.0 - Internal Server Error
D:\Program Files (x86)\PHP\v5.3\php-cgi.exe - The FastCGI process exited unexpectedly
The problem is that this happens when I want to get data from a sql server. When I try to post data to the sql server everything works fine.
The following code represents what I am trying to do with comments to explain what's happening:
try {
// Try to connect to the database.
$conn = new PDO ( "sqlsrv:server = server,1433; Database = name", "user", "password");
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$conn->beginTransaction();
// This works out when executed (I see the row in the table).
$query = "INSERT INTO owner (email) VALUES ('email@email.com')";
$conn->exec($query);
$result = $conn->query("SELECT email FROM owner");
$conn->commit();
// If the SQL select is succesfully performed ($result not false)
if($result !== false) {
echo "there are results";
// Traverse the result set and shows the data from each row
foreach($result as $row) {
echo $row['email']. '<br />';
}
}
$conn = null; // Disconnect
} catch ( PDOException $e ) {
print( "Error connecting to SQL Server. Please call support!" );
die(print_r($e));
}
The code above does insert information in the table on the server but causes the error explained above. Please let me know if there is any more information that I can provide.
Check access database credentials or maybe you have duplicate entry in database for email@email.com
. What is logged in error log?