Jump to content

PHP Warning: PDOStatement::execute() expects parameter 1 to be array, string given in


guymclarenza

Recommended Posts

if($pid != "") {
    $bname = $_REQUEST['bname'];
    $btitle = $_REQUEST['btitle'];
    $btags = $_REQUEST['btags'];
    $bdesc = $_REQUEST['bdesc'];
    $btext = $_REQUEST['btext'];
    $bimg = $_REQUEST['bimg'];
    $bimgalt = $_REQUEST['bimgalt'];
            
            $data = "";
                if($bname!="") { $data = $data." 'bname' => ".$bname.", "; }
                if($btitle!="") { $data = $data."'btitle' => ".$btitle.", "; }
                if($btags!="") { $data = $data."'btags' => ".$btags.", "; }    
                if($bdesc!="") { $data = $data."'bdesc' => ".$bdesc.", "; }
                if($btext!="") { $data = $data."'btext' => ".$btext.", "; }    
                if($bimg!="") { $data = $data."'bimg' => ".$bimg.", "; }    
                if($bimgalt!="") { $data = $data."'bimgalt' => ".$bimgalt.", "; }
                $data = $data."'pid ' =>". $pid.", " ;
                $data = "[".$data."]";
                
            
            $build = "";
                if($bname!="") { $build = $build." page_name = :bname,"; }
                if($btitle!="") { $build = $build." page_title = :btitle,"; }
                if($btags!="") { $build = $build." page_tags = :btags,"; }
                if($bdesc!="") { $build = $build." page_desc = :bdesc,"; }
                if($btext!="") { $build = $build." page_text = :btext,"; }
                if($bimg!="") { $build = $build." page_img = :bimg,"; }
                if($bimgalt!="") { $build = $build." page_imgalt = :bimgalt,"; }
                $build = $build." page_id = :pid";
                
                
                    
            $sql = "UPDATE pages SET ".$build." WHERE page_id=:pid";
            echo $sql."<br /><br />";            
            echo $data."<br /><br />";    
            
            $stmt= $pdo->prepare($sql);
            $stmt->execute($data);

 Result of echo SQL and Data

UPDATE pages SET page_name = :bname, page_title = :btitle, page_tags = :btags, page_desc = :bdesc, page_text = :btext, page_img = :bimg, page_imgalt = :bimgalt, page_id = :pid WHERE page_id=:pid

[ 'bname' => Home, 'btitle' => Market Net, 'btags' => full stack development, search engine ready, professional web development, web design, 'bdesc' => Market net gives you online access to market traders country wide, Support Local businesses today, 'btext' =>

Market Net is the place for you to find those goodies you saw on the markets, buy them online and support small local businesses. Watch this space for more information.

Test

#D hvac

, 'bimg' => supportlocal.jpg, 'bimgalt' => Support Local Small Businesses, 'pid ' =>106, ]

Yet I am getting said error message.  What am I doing wrong?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.