I'm about to rip out my own hair, i've been looking at this 5 lines for the past 3 hours, and i can't for the sake of my sanity find out what's wrong with it.
The connection is fine:
$db = new PDO('mysql:host='.$config['database']['host'].';dbname='.$config['database']['name'],$config['database']['username'],$config['database']['password']);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
Then i run this statement:
$product = $db->prepare('SELECT * FROM products JOIN suppliers ON products.supplier_id = suppliers.id WHERE products.partnumber=:partnumber');
$product -> execute( array( ':partnumber' => $_POST['partnumber'] ) );
$p = $product->fetchAll(PDO::FETCH_ASSOC);
if i do var_dump($p)
it says bool(false)
. But if i run the statement in my db manually, it finds the product perfectly fine.
Just after the beforementioned statement, i run this command:
$cu = current($db->query('SELECT currency_code FROM countries JOIN users ON users.country = countries.iso_alpha2 WHERE users.id="'.$_SESSION['userid'].'"')->fetch());
Which works perfectly fine, it returns the currency as i told it to.
So, my question it. Why doesn't my prepared statement work?
EDIT:
I've tried to run $db->errorInfo
, it returns NULL