Home > Backend Development > PHP Tutorial > PHP empty function determines whether the mysql form is empty_PHP tutorial

PHP empty function determines whether the mysql form is empty_PHP tutorial

WBOY
Release: 2016-07-21 15:39:31
Original
951 people have browsed it

value to judge.
It’s very simple, give me an example.
Method 1:

Copy code The code is as follows:

$sql = "select * form abc"
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
if(empty($row))//Start to judge whether it is empty enough
{
echo "null";
}
else
{
echo "not null";
}

Method 2:
Copy code The code is as follows:

$sql = "select * form abc"
$result = mysql_query( $sql);
$row = mysql_fetch_array($result);
if(!$row)//Start to judge whether it is empty enough
{
echo "null";
}
else
{
echo "not null";
}

In fact, when the mysql_fetch_array function is used, if the table is empty, it will return false. At this time Naturally, $row did not assign the

value successfully.
Remember, never use $row = mysql_fetch_array($result) or die(mysql_error());
If you die later, the program execution will terminate when mysql_fetch_array changes.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321560.htmlTechArticle value to judge. Very simple, give an example. Method 1: Copy the code. The code is as follows: $sql = "select * form abc" $result = mysql_query($sql); $row = mysql_fetch_array($resul...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template