MySQL Forums
Forum List  »  PHP

trouble connecting to mysql database
Posted by: Joshua Morley
Date: March 28, 2015 04:44PM

What's the problem with this? It produces no output and no errors.

<!DOCTYPE html>
<html>
<body>
<?php

ini_set("display_errors",1);
include "/usr/shared/web/<my account name>/cgi-local/pdo.php";
echo $testString . "<br>";

try {
    $dbh = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
    echo 'Connection failed: ' . $e->getMessage();
}
echo "Made it past try/catch.<br>";

?>
</body>
</html>

It worked before I added the six lines starting with "try", so I know the include works. (The "<my account name>" is not to be taken literally.) It correctly displays the value assigned, in the included file, to $testString. The included file also assigns values to the variables that store the credentials. The added lines come straight from: http://php.net/manual/en/pdo.construct.php, except I added the final echo.

Even if I messed up assigning the correct text to the variables that store the credentials, shouldn't I still get some output?

When I try to use mysqli instead of pdo, also borrowing code straight from php.net, I get:

"Fatal error: Cannot instantiate non-existent class: mysqli in /usr/shared/web/newje5/php/mysqliTest.php on line 10"

Does that mean my host doesn't support mysqli, or might there be something I have to do to enable it?

Options: ReplyQuote


Subject
Written By
Posted
trouble connecting to mysql database
March 28, 2015 04:44PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.