Advertisement
DibDibsTH13TEEN

PHP 3

Jul 16th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.05 KB | None | 0 0
  1. //This is the code that sets the query and sends it to my PDO class, which will be below this...
  2. $sql = new dibdibs\pdo;
  3. $sql->connect();
  4.  
  5. $vals = [
  6.     $_GET['username']
  7. ];
  8.  
  9. if ($sql->numRows("SELECT * FROM `w_a_accounts` WHERE (`name` LIKE %?%)", $vals) > 0){
  10.     $result = $sql->query("SELECT * FROM `w_a_banned-names` WHERE (`name` LIKE %?%)", $vals);
  11. }
  12. else{
  13.     $sql->close();
  14.     return "false";
  15. }
  16.  
  17. if ($result['contains'] == 1){
  18.     $sql->close();
  19.     return "true";
  20. }
  21.  
  22. else{
  23.     if ($result['name'] == $_GET['username']){ return "true"; }
  24.     else{ return "false"; }
  25. }
  26.  
  27. //This is the PDO method that prepares statements and executes them
  28. public function query($query, $valuesUnescaped=[]){
  29.     $statement = $this->con->prepare($query);
  30.    
  31.     for ($i=0; $i<count($valuesUnescaped); $i++){
  32.         $prepVal = ($valuesUnescaped[$i]);
  33.         $statement->bindParam($i+1, $prepVal);
  34.     }
  35.    
  36.     $statement->execute();
  37.    
  38.     $rows = $statement->fetchAll(\PDO::FETCH_ASSOC);
  39.     return $rows;
  40. }
  41.  
  42. //This function works for other queries, but it is throwing errors when using the LIKE clause.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement