核心提示:1、通过本程序您可以测试您的Mysql数据库是否可以正常连接,数据库用户名或者密码是否正确,也可以参考程序中的代码编写您自己的连接数据库PHP程序。使用方法:请您将文件下载至本地解压后将mysql.php程序上传到网站目录下,然后使用htt...
1、通过本程序您可以测试您的Mysql数据库是否可以正常连接,数据库用户名或者密码是否正确,也可以参考程序中的代码编写您自己的连接数据库PHP程序 。使用方法:请您将文件下载至本地解压后将mysql.php程序上传到网站目录下,然后使用http://域名/mysql.php即可使用,按要求输入数据库用户名、密码、数据库名称即可。
2、PHP数据库连接例程说明: <?php $dbh = mysql_connect(' localhost','数据库用户名','数据库密码'); mysql_select_db('数据库名'); $query = "insert into requests(date, request, email, priority,status) values (NOW(),'$description', '$email', '$priority', 'NEW')"; $res = mysql_query($query, $dbh); $query = "select max(id) from requests"; $res = mysql_query($query, $dbh); $err = mysql_error(); if($err){ echo "发生错误,请通知<a href=mailto:postmaster@yourdomain.com>管理员</a>"; } $row = mysql_fetch_row($res); echo "未来您使用的号码为: ".$row[0]; ?> 以上实例仅供参考. |