PHP如何去执行一个SQL语句
展开全部
<?php
$db_server = "localhost";
$db_user = "root";
$db_pwd = "password";
$db_name = "test";
$sql = "select * from user where username='admin'";
$conn = mysql_pconnect($db_server, $db_user, $db_pwd);
$my_db = mysql_select_db($db_name, $conn);
$result = mysql_query($sql, $conn);
$userInfo = mysql_fetch_array($result);
mysql_close($conn);
echo "帐户:" .$userInfo["username"]. "";
echo "密码:" .$userInfo["password"]. "";
echo "年龄:" .$userInfo["userage"]. "";
echo "等级:" .$userInfo["usergrade"]. "";
?>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询