Quote:
Originally Posted by zijlstravideo
function hookitup()
{
require_once('dbcreds.php');
return new PDO("mysql:host=$host;dbname=$dbname;charset=utf8" ,$user,$password,array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
}
dbcreds file:
<?php
$dbname='dbname';
$dbuser='dbusername';
$dbpass='dbpassword';
$dbhost='localhost';
?>
These two don't match, that's why you're getting a blank page (as no database connection is being made).
Change the function to:
function hookitup()
{
require_once('dbcreds.php');
return new PDO("mysql:host=$dbhost;dbname=$dbname;charset=utf8" ,$user,$password,array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
}
And as K33n noted, change:
$stmt = $db->prepare($sql_str);
to:
$stmt = $db->prepare($sql);
|
Thank you.
Its still not showing anything BUT, does that mean I also need to make the following changes based on this error?
Quote:
#0 /blah/blah/domain.com/recipesnew.php(118): PDO->__construct('mysql:host=loca...', NULL, NULL, Array)
#1 /blah/blah/domain.com/recipesnew.php(18): hookitup()
#2 {main}
thrown in /blah/blah/domain.com/recipesnew.php on line 118
|
return new PDO("mysql:host=$dbhost;dbname=$dbname" ,
$dbuser,$dbpass,array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
}
Or am I looking in the wrong place/overthinking and doing the wrong thing?