开发者

How to make a prepared statement with php variables and php array elements?

开发者 https://www.devze.com 2023-03-12 11:03 出处:网络
I know this is just some annoying syntax thing but i just can\'t get the code below to work. 开发者_开发知识库 Please can someone help?

I know this is just some annoying syntax thing but i just can't get the code below to work. 开发者_开发知识库 Please can someone help?

if($stmt = $link -> prepare("INSERT INTO google_pre_transaction VALUES    (?,?,?,?,?,?,?,?,?,?,?,?,?")) {
  /* Bind parameters
     s - string, b - boolean, i - int, etc */
  $stmt -> bind_param("iiisss", 
  $m_id,
  $page_one['input-one'], 
  $page_one['input-two'],
  $page_one['title'],
  $page_one['first'], 
  $page_one['last']
  );


You have 13 ? and 7 variables. The numbers have to match.

Also, your closing parenthese is outside the quote, which is bad syntax.

This should work:

prepare("INSERT INTO google_pre_transaction VALUES (?,?,?,?,?,?,?)")


For one, you have a lot more ? then you have parameters in you bind_param. They should be the same amount.

I'm guessing the error is saying exactly that by the way.

0

精彩评论

暂无评论...
验证码 换一张
取 消