Highlighted

validar consulta sql

New Here ,
Jul 31, 2020

Copy link to clipboard

Copied

al intenta validar una consulta con por ejemplo  if (!Datos) no detecta cuando no se encontro un registro,

probe con empty . count mysqli_num _rows y tampoco  me resolvieron el problema.

puede ser un problema de configuracion del php o dreamweaver?

Views

41

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

validar consulta sql

New Here ,
Jul 31, 2020

Copy link to clipboard

Copied

al intenta validar una consulta con por ejemplo  if (!Datos) no detecta cuando no se encontro un registro,

probe con empty . count mysqli_num _rows y tampoco  me resolvieron el problema.

puede ser un problema de configuracion del php o dreamweaver?

Views

42

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 31, 2020 0
Adobe Community Professional ,
Aug 01, 2020

Copy link to clipboard

Copied

Don't blame the software.  Answers are contained in your code.

 

Nancy O'Shea, ACP
Alt-Web.com

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 01, 2020 1
osgood_ LATEST
LEGEND ,
Aug 02, 2020

Copy link to clipboard

Copied

What exactly are you trying to do? Are you trying to find out IF any records exist when querying your database and IF they don't return a message or do something else?

 

Something like below where the number of rows are returned from the database query into a variable  - $numRows

 

$conn = new mysqli('localhost' , 'username' , 'password' , 'databaseName');

$sqlQuery = $conn->query("SELECT * FROM tableName WHERE id= '3'") or die($conn->error);
$sqlQuery = $sqlQuery->fetch_assoc();
$numRows = $sqlQuery->num_rows;

 

If no results are found:

 

if($numRows == 0) {

Do Something

}

else {

Do Something Else

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 02, 2020 0