javascript - PDO: make $dbh available and maintain across all php files -


seem can't make right. basically, 3 php files used: - login.php, testconnect.php , numrows.php numrows.php main file first start played.

login.php , testconnect.php good.

numrows.php:-

<?php global $dbh1; require_once "testconnect.php";  try     {       $stmt = $dbh1->prepare("select count(distinct mfg_code) test");     $stmt->execute(); }  catch(pdoexception $err) {     $alertmsg = $err->getmessage();     }  $num = $stmt->fetch("pdo::fetch_assoc:"); $num = json_encode($num);  echo $num; ?> 

the log error apache showed ""get /testnumcards.php http/1.1" 500 -". again error encountered while debugging "networkerror: 500 internal server error". right way do?

your problem not in making $dbh available in inconsistent code , wrong syntax.
@ least make file way, without useless , wrong code

<?php require_once "testconnect.php"; $stmt = $dbh1->prepare("select count(distinct mfg_code) test"); $stmt->execute(); $num = $stmt->fetch(pdo::fetch_assoc); // note proper syntax $num = json_encode($num); echo $num; 

then error_log details


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -