这个是在那上拔下来的
<?php
// 连接,选择数据库
$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')
or die('Could not connect: ' . mysql_error());
echo 'Connected successfully';
mysql_select_db('my_database') or die('Could not select database');
// 执行 SQL 查询
$query = 'SELECT * FROM my_table';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
// 用 HTML 显示结果
echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";
// 释放结果集
mysql_free_result($result);
// 关闭连接
mysql_close($link);
?>
出现如下错误。。。
Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL Server Host 'mysql_host' (11001) in c:\AppServ\www\ssq.php on line 3
Could not connect: Unknown MySQL Server Host 'mysql_host' (11001)
create database db;
create table xx(
aaa INT,
bbb CHAR(10));
insert into xx values(1,"aaa");
select * from xx where id=1;
update xx set bbb="bbb" where id=1;