|
php不能打开MYSQL;PHP-MYSQL已安装,如何解决:
我的mysql运行如下:(mysql已设定了用户denguo)
[root@localhost root]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 3.23.49
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> Use dase1
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select * from my1;
+--------+------------+
| name | phone |
+--------+------------+
| denguo | 5346727 |
| den | 1319201085 |
+--------+------------+
2 rows in set (0.03 sec)
mysql>
Fatal error: Call to undefined function: mysql_connect() in /var/www/html/denguo/05.php on line 7
源码如下:
<html>
<head><title>Web Database Sample Index</title>
</head>
<body bgcolor=#ffffff>
<h1>Data from mytable</h1>
<?php
$connect=mysql_connect('localhost','denguo','');
$select = mysql_select_db('dase1',$connect);
$result = mysql_query("select * from my1", $connect);
if ($result) {
echo "Found these entries in the database:<ul>";
while ($r = mysql_fetch_array($result)) {
$name = $r["name"];
$phone = $r["phone"];
echo "<li>$name, $phone";
}
echo "</ul>";
}
else{
echo "No data.";
}
mysql_free_result($result);
?>
<p><a href="add.php3">Add new entry</a>
</body>
</html> |
|