Jump to content

undertaker

Members
  • Posts

    40
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

undertaker's Achievements

Member

Member (2/5)

0

Reputation

  1. Solved here: http://forums.phpfreaks.com/topic/281071-mysqli-dynamic-bind-param-parameters/
  2. I implemented your solution and it works, like a charm. Thank you very much
  3. I am sorry, i havent noticed you changed my code there. Thought it was just a quote of my post. I tried to rewrite the code and present my problem better in a new post since you told me the previous looked like piece of *.
  4. I am trying to pass several parameters dynamically to the bind_param() function. Here is the error i receive: Warning: Parameter 2 to mysqli_stmt::bind_param() expected to be a reference, value given $con = new mysqli('localhost',USER,PASS,DBS); if(mysqli_connect_errno()) { error(mysqli_connect_errno()); } $con -> set_charset("utf8"); /*inside*/ $type=''; $query='SELECT bugID FROM bug'; if(!empty($_GET['cena'])) { $build[]='uCena=?'; $type.='i'; $val[]=$_GET['cena']; } if(!empty($_GET['popust'])) { $build[]='uPopust=?'; $type.='i'; $val[]=$_GET['popust']; } if(!empty($build)) { echo $query .= ' WHERE '.implode(' AND ',$build); } $new = array_merge(array($type),$val); foreach($new as $key => $value) { $tmp[$key]=&$new[$key]; } echo '<br/><br/>'; foreach ($new as $new ){ echo "$new<br/>"; } if ($count = $con->prepare($query)) { call_user_func_array(array($count,'bind_param'),$tmp); $count->execute(); $cres = $count->fetch_row(); $count -> close(); } else error($con->error); /*inside*/ $con -> close();
  5. I would like to dynamically pass data for bind parameters, depending on user selection. This code gives me two errors: Warning: Invalid argument supplied for foreach() Warning: Wrong parameter count for mysqli_stmt::bind_param() $query="SELECT COUNT(*) FROM database WHERE parameter_zero ='approved'"; if(!empty($_GET['first_parameter'])) { $queryPart[] = 'first_parameter=?'; $type[]='s'; $value[]=$_GET['first_parameter']; } if(!empty($_GET['second_parameter'])) { $queryPart[] = 'second_parameter=?'; $type[]='s'; $value[]=$_GET['second_parameter']; } if(!empty($_GET['third_parameter'])) { $queryPart[] = 'third_parameter=?'; $type[]='s'; $value[]=$_GET['third_parameter']; } $query.= ' AND '.implode(' AND ',$queryPart); $bind=array_merge($type,$value); if ($res = $con->prepare($query)) { call_user_func_array(array($count,'bind_param'),ref($bind)); $res->execute(); $cRes = $res-> $fetch_row(); $count -> close(); } else error($con->error); echo $cRes; function ref($arr) { $refs=array(); foreach($arr as $key => $value) { $refs[$key] = &$arr[$key]; } return $refs; }
  6. For example, i am making an application where user could add his restaurant to united country restaurant database. Beside the general information, user could add up to 3 pictures of his restaurant. Now i am asking you, what would be the best way to achieve that? Uploading: I.Using the same database as for the other info? Like pic1, pics2, pic3 columns with image paths? II.Using different database for images connected to general information table with unique id? (how fast is that? ) III. Better solution? Editing: Best solution (+ interface) to change / delete existing images from database since there is maximum limit of 3? Thanks in advance for all the suggestion and ideas.
  7. Are PHP sessions automatically destroyed after you close the browser, or they stay on server for ever, and are later accessible by id? (in case you do not destroy them before the browser exit). Thank you
  8. Thanks everyone It helped! SOLVED! No problem
  9. Oh and is there a way to do it in association with PHP? So the database password cant be visible in online source code?
  10. I would like to fetch data from database when item is selected from dropdown list and show it instantly without refreshing the site. Sample: <select> <option> something </option> <option> something2 </option> <option> something3 </option> </select> <div>shows mysql database results here, depends on item we have chosen</div>
  11. Hello, I made that script for previewing all the images in the directory: $dir = "../images"; $images = glob($dir . "*.jpg"); foreach($images as $image) { echo $image; } Now what i would like to do is to put checkbox to every image. And when i press download button, all the selected images are downloaded. (as .zip, .rar) Thank you very much for your help
  12. How can you protect mysql injection? (from inserting different statements into the input field) Thanks
×
×
  • 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.