[Solved] PDO states I am missing tokens, But I am not – what’s wrong with this [closed]

You are setting the query before you add the filter to the query string. // Get the results from the query $query->setQuery($sqlSelect) ->setParameter(‘startMonth’, $startMonth) ->setParameter(‘endMonth’, $endMonth); if (!empty($filter)) { $sqlSelect .= ‘AND LOG.VALUE LIKE :filter ‘; $query->setParameter(‘filter’, ‘%’.$filter.’%’); } You are setting the query to $sqlSelect and aftwards appending the filter part after setting the … Read more

[Solved] How to show all arrays without numbers etc

This is nothing related to PDO. You might wanna do this: for ($i = 0; $i < count($tijdlijn); $i++) print_r ($tijdlijn[$i][‘bericht’]); Or in a better way: foreach ($tijdlijn as $tijd) print_r ($tijd[‘bericht’]); 0 solved How to show all arrays without numbers etc

[Solved] PDOException SQLSTATE[HY000] [2002] No such file or directory

The error message indicates that a MySQL connection via socket is tried (which is not supported). In the context of Laravel (artisan), you probably want to use a different / the correct environment. Eg: php artisan migrate –env=production (or whatever environment). See here. 5 solved PDOException SQLSTATE[HY000] [2002] No such file or directory

[Solved] SQL INSERT VALUES INTO TABLE FROM FILE [closed]

Both your PHP and your MySQL syntax have problems. First, your SQL statement needs to be surrounded by quotes. Secondly, the syntax for LOAD DATA INFILE is incorrect. Try this: $stmt=$db->prepare(“LOAD DATA INFILE ‘insert.txt’ into table `Info`”); $stmt->execute(); See the MySQL docs for LOAD DATA INFILE for more options. You’ll probably need to specify your … Read more

[Solved] Cant solve this : Invalid parameter number: number of bound variables does not match [closed]

Missing Comma (,) in this line. Due to which bound variables were not matching. $req = $pdo->prepare(“INSERT INTO t_events_changes …. Values (… :new_standby_start:old_standby_end, … )”); ^ here missing comma Change it to, :new_standby_start,:old_standby_end, 2 solved Cant solve this : Invalid parameter number: number of bound variables does not match [closed]

[Solved] Fatal error: Uncaught exception ‘Exception’ with message ‘id not supplied’

throw new Exception(“id not supplied”); This line throws the exception that causes the fatal error you’re seeing. It’s run under this condition: if(!isset($id)){ So obviously, the condition matches, which means that the $id variable is not set. Also, extract($_REQUEST) is extremely bad practice. Simple scope example: function foo($a) { $a = 5; echo $a; //5 … Read more

[Solved] fetchAll helper function using PDO

edit: as the Colonel indicated, apparently this (no longer?) works with LIMIT clauses. If you’re using simple queries / are not that bothered with type: function fetchAll(){ $args = func_get_args(); $query = array_shift($args);//’SELECT * FROM users WHERE status=? LIMIT ?,?’ //you’ll need a reference to your PDO instance $pdo somewhere…. $stmt = $pdo->prepare($query); $stmt->execute($args); return … Read more

[Solved] php pdo $_post insert

$fields = array_keys($_POST); if (!empty($fields)) { $names = implode(‘`, `’, $fields); $values = implode(‘, :’, $fields); $sql = “INSERT INTO customers ( `”.$names.”` ) VALUES ( :”.$values.” )”; print_r($sql); $addRandom = $pdo->prepare($sql); foreach ($fields as $field) { $addRandom->bindValue(“:{$field}”, $_POST[$field]); } $boolean = $addRandom->execute(); if ($boolean){ echo ‘INSERTED’; } else { echo ‘FAILED’; } } 0 … Read more

[Solved] Is this prepared statement?

Yes you are using a prepared statement with a parameter. That’s the right thing to do. Parameters are the best way to write safe SQL statements in the majority of cases. There are just a few edge cases where they don’t help (see my answer to how safe are PDO prepared statements) I can suggest … Read more

[Solved] Fatal error: Call to a member function prepare() on a non-object in C:\wamp\www\sideProjects\loginTut\db.php on line 20 [closed]

You forgot to assign a value to $conn from the return value of DBConnect(), eg this DBconnect($config); should be $conn = DBConnect($config); You also don’t need to use global $conn in your script as it will be in scope. I’d also recommend not catching the exception from the PDO constructor. How else will you know … Read more

[Solved] bind_param for php pdo for select

I rectified that above and got error on below public function getAllRecord($table){ $result = $this->con->prepare(“SELECT * FROM “.$table); $result->execute(); $results = $result->fetchAll(); $rows = array(); if ($results->rowCount > 0) { while($row = $results->fetch(PDO::FETCH_ASSOC)){ $rows[] = $row; } return $rows; } return “NO_DATA”; } Error:Notice: Trying to get property of non-object in C:\xampp\htdocs\inv_project\public_html\includes\DBOperation.php on line 68 … Read more