View Single Post
Old 09-08-2021, 05:35 AM  
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,123
Quote:
Originally Posted by zijlstravideo View Post
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?
Publisher Bucks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote