Hi Friends

I am facing an issue in update query using PDO Prepare method. Please help me to fix the issue.

$consql = "UPDATE $database.$constant_application SET SCYQ64EMAL=:SCYQ64EMAL, SCYQ64EV01=:SCYQ64EV01, SCYQ64EV02=:SCYQ64EV02, 
        SCYQ64EV03=:SCYQ64EV03,SCYQ64EV04=:SCYQ64EV04, SCYQ64EV05=:SCYQ64EV05, SCYQ64EV06=:SCYQ64EV06, SCUSER=:SCUSER, SCJOBN=:SCJOBN, SCPID=:SCPID, SCYQ64AVGP=:SCYQ64AVGP, SCYQ64TZ=:SCYQ64TZ, SCUPMJ=:SCUPMJ, SCUPMT=:SCUPMT where SCYQ64CID=:SCYQ64CID";
    $row = $dbh->prepare($consql);
    $row->bindParam(":SCYQ64EMAL",$SCYQ64EMAL);
    $row->bindParam(":SCYQ64EV01",$SCYQ64EV01);
    $row->bindParam(":SCYQ64EV02",$SCYQ64EV02);
    $row->bindParam(":SCYQ64EV03",$SCYQ64EV03);
    $row->bindParam(":SCYQ64EV04",$SCYQ64EV04);
    $row->bindParam(":SCYQ64EV05",$SCYQ64EV05);
    $row->bindParam(":SCYQ64EV06",$SCYQ64EV06);
    $row->bindParam(":SCUSER",$SCUSER);
    $row->bindParam(":SCJOBN",$SCJOBN);
    $row->bindParam(":SCPID",$SCPID);
    $row->bindParam(":SCYQ64AVGP",$SCYQ64AVGP);
    $row->bindParam(":SCYQ64TZ",$SCYQ64TZ);
    $row->bindParam(":SCUPMJ",$SCUPMJ);
    $row->bindParam(":SCUPMT",$SCUPMT);
    $row->bindParam(":SCYQ64CID",$SCYQ64CID);

I am facing an issue

What's the issue? Am guessing the colons before your parameter names in bindParam...

update is not reflect in the database

Member Avatar for diafol

Have you executed it?

echo the prepared statement to ensure that the embedded variables are as you expect

With bindParam (from manual):

e.g.

$sth->bindParam(':calories', $calories, PDO::PARAM_INT);

You can add datatype. If you're not using this, then you may as well do:

$consql = "UPDATE $database.$constant_application SET SCYQ64EMAL=?, SCYQ64EV01=?, SCYQ64EV02=?, SCYQ64EV03=?,SCYQ64EV04=?, SCYQ64EV05=?, SCYQ64EV06=?, SCUSER=?, SCJOBN=?, SCPID=?, SCYQ64AVGP=?, SCYQ64TZ=?, SCUPMJ=?, SCUPMT=? where SCYQ64CID=?";
$row = $dbh->prepare($consql);
$values = array($SCYQ64EMAL,$SCYQ64EV01,$SCYQ64EV02,$SCYQ64EV03,$SCYQ64EV04,$SCYQ64EV05,$SCYQ64EV06,$SCUSER,$SCJOBN,$SCPID,$SCYQ64AVGP,$SCYQ64TZ,$SCUPMJ,$SCUPMT,$SCYQ64CID);
$row->execute($values);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.