U
U
Uzair Izha2016-02-04 19:24:56
PHP
Uzair Izha, 2016-02-04 19:24:56

How to check the success of a database query?

I have a Select request, how to check if the request is successful? Didn't find an answer on google.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Z
ZLOFENIX, 2016-02-04
@ZLOFENIX

if (($res = mysql_query ("select ...")) === FALSE) - pure error check, or after mysql_query check for mysql_err !=
0 net/manual/ru/function.mysql-query.php
For mysqli, pdo - about the same and in the same place.

M
MdaUZH, 2016-02-04
@MdaUZH

if PDO
$db->STH->rowCount() > 0 - true

J
JihadTV, 2016-02-04
@JihadTV

And right in the IDE, why not try to make a query to the database? Definitely not writing in a notebook.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question