php - Fatal error: Call to a member function prepare() on a non-object PDO -
i trying move sql working pdo showing following fatal error: call member function prepare() on non-object in /home/content/58/9508458/html/pa/test. php on line 12
orginal code
<?php $pdfreq=$_get['dadi']; include('config.php'); require('fpdf.php'); $link =mysql_connect($db_host,$username,$password); mysql_select_db($db_name); $update = "update mastertable set pdfstatus =1 id_pk = $pdfreq"; mysql_query($update, $link);
replaced with
<?php $pdfreq=$_get['dadi']; include('config.php'); require('fpdf.php'); $link =mysql_connect($db_host,$username,$password); mysql_select_db($db_name); $sql = "update mastertable set pdfstatus=?, id_pk=?"; $q = $link->prepare($sql); $q->execute(array(1,$pdfreq));
your $link
variable not pdo object. should replace:
$link = mysql_connect($db_host,$username,$password); mysql_select_db($db_name);
with:
$link = new pdo("mysql:dbname=$db_name;host=$db_host",$username,$password);
Comments
Post a Comment