您当前的位置: 首页 >  php

暂无认证

  • 4浏览

    0关注

    95081博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

原生php创建错误日志文件

发布时间:2022-03-28 20:33:54 ,浏览量:4

conn.log文件在你运行的php文件的同级

 $fp = fopen($filename,'a');//模式是写入方式打开 $str = "错误日期:".date('Y-m-d H:i:s')."==错误内容:".$errormsg; fwrite($fp,$str);//写入 fclose($fp);//关闭 } $dataname = 'a';//数据库 $conn = mysql_connect('localhost','root','');//数据库软件密码账号,本地地址 if($conn){ $r =mysql_select_db($dataname,$conn); if($r){ mysql_query('set names utf8');//指定的字符编码 }else{ makeErrorLog('conn.log',$dataname.'数据库不存在'); } }else{ makeErrorLog('conn.log','数据库连接失败!'); } $sql = "select * fro1m voto";//首先数据库要链接成功,sql语句错误才行哦 $result = mysql_query($sql); $arr = mysql_fetch_assoc($result); if($arr){ print_r($arr); }else{ makeErrorLog('conn.log','SQL语句执行错误!'); } ?> 

在这里插入图片描述

关注
打赏
1655516835
查看更多评论
立即登录/注册

微信扫码登录

0.4894s