Jump to content

rarebit

Members
  • Posts

    1,002
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

rarebit's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. In reality I had another issue with that reference, they all came through as the same, so I did basically the same but to a temporary array then copied it (may have time to find a better method later), also as you said the trailing comma err'd on me, so here's a quick amendment. $params2=substr($params2, 0, -1); $param=array(); // need to copy because need references!!! grrr for($i=0;$i<count($aa);$i++){ $param[]=&$aa[$i]; } I generate the params and types on the fly so that any number of products may be added at once. I will be banging these (+others) into functions later, but / or how do you mean? (I saw some class examples on php.net but i'm in a rush so just moved on, but I do prefer to optimise wherever possible!) Cheers
  2. After trying every version of array merge, it finally worked by changing this: $param[]=&$k;
  3. Hi, i'm getting the following error when executing the following code. The count should be right That line may now be 39 ( call_user_func_array() )I've tried hard coding the types too (so no extra comma)! And without array_values(), plus other things... and when I print each set of params out they are right if(isset($_POST['order'])){ print "Order<br />"; $param=array(); $params=""; $params2=""; foreach($_POST as $k=>$v){ $pos = strpos($k, 'sku'); if($pos!==false&&$pos==0){ $param[]=$k; $params.="s"; $params2.="?,"; } } if(count($param)>0){ print "Selecting<br />"; if($stmt = $db->prepare("SELECT sku, title, info, quant, cost FROM ".$db_table_prefix."product WHERE sku IN (".$params2.")")) { call_user_func_array('mysqli_stmt_bind_param', array($stmt, $params, array_values(&$param))); $stmt->execute(); Many thanks!
  4. Hi, I wrote some code a fair while ago now and just trying to use it again. The code works fine on my Linux distro, but on Windows i'm getting an error... Basically 'id' is an int not null autoincrement, and I pass it an empty string. Do you know what the issue is?
×
×
  • 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.