PHP连接数据库

PHP连接数据库
<?php

session_start();

$_SESSION[‘username‘]="dddddddddd";

if($_SESSION[‘username‘]==null){
    
echo "<script>location.href(‘session.php‘)</script>";
    
}

$con = mysql_connect("localhost","root","");

if(!$con){
    die("connect error".mysql_error());
}

mysql_select_db("cnxinwa",$con);
$sql="select * from `users` where 1 ";

 $result= mysql_query($sql);
 
 //while ($row=mysql_fetch_array($result))
 //{
 //    echo $row[‘username‘] . "<br />";
 //}
 $row=mysql_fetch_assoc($result);
 //echo "用户名:". $row["username"] ."密码:" . $row["password"]; 
?>
<!DOCTYPE table PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><HEAD><TITLE></TITLE></HEAD>
<body>
<table>
<tr><td><?php echo  $row["username"] ?></td></tr>
<tr><td><?php echo  $row["password"] ?></td></tr>
</table>
</body>
</html>
PHP连接数据库

PHP连接数据库

上一篇:gesture(解决ios双击放大)


下一篇:【计算机网络】一个HTTP请求的完整历程,DNS是怎么解析域名得到IP的?