0

I'm new to PHP and databases and am currently battling blank pages. I tried to print the error messages on the web page, but no luck... Here's a sample PHP:

<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once("scripts/config.php");
$pdo = new PDO("mysql:host=".$dbhost.";dbname="".$dbname, $uname, $dbpw);
$sql = "SELECT * FROM DbTable";
$statement = $pdo->prepare($sql);
echo $statement->execute();
?>

Why is this page coming up blank?

Thanks in advance.

TimB
  • 843
  • 5
  • 15
  • `How do I get PHP errors to display?` - https://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display – Xatenev Feb 05 '19 at 12:42
  • I looked at that and implemented the accepted answer; can't access php.ini on my host though. – TimB Feb 05 '19 at 12:43
  • 1
    What? You should work on a local environment where you have access to all necessary configuration files. You have a `ParseError` and you should be able to identify them easy with a proper code editor. – Xatenev Feb 05 '19 at 12:44
  • `";dbname="".$dbname` Say no more ... TYPO – RiggsFolly Feb 05 '19 at 12:51
  • `echo $statement->execute();` also isn't going to work. You need to fetch that result object. – user3783243 Feb 05 '19 at 12:55
  • In this case I just wanted to check whether the query was successful. It returns 1, so it's fine. – TimB Feb 05 '19 at 12:56

1 Answers1

0

You have to enable error reporting in php.ini (search for the ERROR section).

Cosmin Staicu
  • 1,514
  • 2
  • 18
  • 21