I can’t use my database


I have a database, and I have PHP code to communicate with the database

$db = new PDO("mysql:host=localhost;dbname=$database;charset=utf8", $username, $password;

but nothing happens. It seems to connect (it doesn’t report an error when I try), but nothing happens on executing a query, and then the server just seems to stop reading PHP altogether.

Is there a way to access my 000 database from outside the site to make sure it works, or any other way to figure out what’s going on? I can access the database through PHPMyAdmin, but not from my own code, which worked perfectly fine on another host.



try {
    $conn = new PDO("mysql:host=$servername;dbname=$database", $username, $password);
    // set the PDO error mode to exception
    echo "Connected successfully"; 
    } catch(PDOException $e) {    
    echo "Connection failed: " . $e->getMessage();


Yes, I have it in a try block:

catch (PDOException $e) {
	echo json_encode($e->getMessage());

Like I said, no error, nothing.
Edit: It’s as if the file just ends at $stmt->fetch();. Beyond it, nothing gets echoed. No HTML is displayed. The rest of the file is gone. It’s still there in the editor, but not in the generated source code.


Hi @Frungi

Can you upload the whole file here?