sql返回空行,即使数据存在于数据库中

vkc1a9a2  于 2021-06-19  发布在  Mysql
关注(0)|答案(1)|浏览(366)

因此,我有一个会话变量,它从login获取信息并通过它显示数据。我尝试了各种方法,但总是返回null。数据存储在phpmyadmin中,但当我在phpmyadmin中运行sql查询时,它再次返回null。
PHP:

<?php

$host="localhost";
$user="root";
$password="";
$db="bhprj";
session_start();

$con=mysqli_connect($host,$user,$password,$db);
$var =  $_SESSION['en'];
$sql = "select * from PB where mailid = '{$_SESSION['en']}';";
$res=mysqli_query($con,$sql);
$result=mysqli_fetch_assoc($res);
<div class="input-field">
    <p>SOURCE</p><br> 
    <input type="text" name="sn" value="<?php echo $result['source']; ?>" required>
</div>
<div class="input-field">
    <p> destination </p> <br>
    <input type="text" name="dn" value="<?php echo $result['destination']; ?>" required>
</div>
<div class="input-field">
    <p>NO OF PASSENGERS </p><br><br> 
    <input type="number" name="nn" value="<?php echo $result['nop']; ?>" required>
</div>

<div class="input-field">
    <p>DATE</p><br><br> 
    <input type="date" name="date" value="<?php echo $result['date']; ?>" required>
</div>

希望得到帮助。

xcitsw88

xcitsw881#

尝试这样编写sql查询: $sql = "select * from PB where mailid = ". {$_SESSION['en']};

相关问题