Home >Backend Development >PHP Tutorial > 新人求教php连接不上数据库有关问题

新人求教php连接不上数据库有关问题

WBOY
WBOYOriginal
2016-06-13 13:43:18968browse

新人求教php连接不上数据库问题!
代码如下

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->

<?php>

$conn=MySql_connect("localhost","root","root") or die("connect fail".MySql_error());
echo"<p>success</p>";
$ok=MySql_select_db("test",$conn);
if($ok)
{
echo "<p>数据库选择成功</p>";
}
else
{
echo "<p>选择失败</p>";
}
?>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn