从PHP4移动到带有PHP5的服务器时出错


Errors moving from PHP4 to server with PHP5

我在将我的网站从PHP 4移动到使用PHP 5的服务器时遇到以下3个错误。有人能帮我吗?

警告:mysql_select_db():提供的参数无效第37行/home/xxxxxx/index.php中的MySQL链接资源

mysql_select_db($conn, "yourmil_content");

警告:mysql_query():提供的参数不是有效的mysql链接247 行/home/xxxxxxx/index.php中的资源

$result = mysql_query($sql, $conn);

警告:mysql_fetch_array():提供的参数不是有效的mysql第248行/home/xxxxxx/index.php中的结果资源

$data = mysql_fetch_array($result);

首先(假定$conn是有效连接)

$conn = mysql_connect('host_name', 'user_name', 'mysql_password');

然后

mysql_select_db($conn, "yourmil_content");

应该是

mysql_select_db("yourmil_content", $conn);

您以错误的顺序提供了参数,这就是为什么没有根据此错误选择Database的原因

警告:mysql_select_db():提供的参数无效第37行/home/xxxxxx/index.php中的MySQL链接资源

因为,数据库并没有被选中,所以其他的事情都不起作用。检查mysql_select_db,同时注意deprecated警告。