php 查询数据库的指定记录并显示 第50-56行无法显示数据库的记录
<?php$id=$_SESSION["id"];$sql="SELECTidFROM31201385_userinfoWHEREid=$id";$result=mysq...
<?php
$id=$_SESSION["id"];
$sql="SELECT id FROM 31201385_userinfo WHERE id=$id";
$result=mysqli_query($link,$sql);
$row = mysql_fetch_assoc($result);
echo $row;
?> 展开
$id=$_SESSION["id"];
$sql="SELECT id FROM 31201385_userinfo WHERE id=$id";
$result=mysqli_query($link,$sql);
$row = mysql_fetch_assoc($result);
echo $row;
?> 展开
1个回答
展开全部
mysql_fetch_assoc这玩意会给出一个数组,echo是打印不出来的,要用print_r 或var_dump这类函数才行,
<?php
$con = mysql_connect("localhost", "hello", "321");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db("test_db",$con);
$sql = "SELECT * from Person WHERE Lastname='Adams'";
$result = mysql_query($sql,$con);
print_r(mysql_fetch_assoc($result));
mysql_close($con);
//输出类似:
Array
(
[LastName] => Adams
[FirstName] => John
[City] => London
)
?>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询