Advertisement
Guest User

Untitled

a guest
Jun 12th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.89 KB | None | 0 0
  1. $host="localhost";
  2. $username="";
  3. $password='';
  4. $db_name=$username;
  5. $tbl_name="inventory";
  6.  
  7. $source = $_POST['Submit'];
  8.  
  9. #$db_inven = mysqli_connect("$host", "$username", "$password", "$db_name");
  10. $db_inven = new mysqli("$host", "$username", "$password", "$db_name");
  11.  
  12.  
  13. # this function searches for albums with names
  14. # like the given album name
  15. function searchAlbum($album){
  16.  
  17.     global $db_inven;
  18.  
  19.     $prepSearch = $db_inven->prepare("SELECT artist, albm, qty, label, descr, " .
  20.                                      "retail, wholesale, cost, medium, id " .
  21.                                      " WHERE album like ?");
  22.     $prepSearch->bind_param('ssissdddsis', $album);                                                                                                                                                                  $prepSearch->execute();                                                                                                                                                                                          
  23.     $prepSearch->bind_result($artist, $ralbum, $qty, $label, $description, $retail, $wholesale, $cost, $medium, $id);
  24.  
  25.     $results = array();
  26.  
  27.     while ($prepSearch->fetch()){
  28.  
  29.         array_push($results, array('artist' => $artist,
  30.                                    'album' => $ralbum,
  31.                                    'qty' => $qty,
  32.                                    'label' => $label,
  33.                                    'descr' => $description,
  34.                                    'retail' => $retail,
  35.                                    'wholesale' => $wholesale,
  36.                                    'cost' => $cost,
  37.                                    'medium' => $medium,
  38.                                    'id' => $id));
  39.     }
  40.     return $results;
  41. }
  42.  
  43.  
  44. $foo = searchAlbum("somealbum");
  45.  
  46. Call to a member function bind_param() on a non-object
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement