- 论坛徽章:
- 0
|
$filename = "test.txt";
$file = fopen($filename, "at");
$conn=mysql_connect("localhost", $myname, $mypass);
$strsql="select * from user where user_ip = '1.2.3.4'";
$sql_result=mysql_db_query($mydb, $strsql, $conn);
fwrite($file,"11111\n");
mysql_data_seek($sql_result, 0);
if ($row=mysql_fetch_row($sql_result)) {
$tt = $row[$4];
fwrite($file,"22222\n");
}
fwrite($file,"333333\n");
mysql_free_result($sql_result);
mysql_close();
fclose($file);
一旦select为空
则,不会像test.txt里写任何数据,但是如果注释掉其中的$tt = $row[$4];
select 为空也会写到test.txt里两行数据
我的理解是:select为空,应该向test.txt里写两行数据11111和333333
select 不为空,则会向test.txt里写三行数据:11111/22222/333333
为啥select为空时,根本就不写数据呢? |
|