SQL:mysqli_query,无输出 [英] SQL: mysqli_query, no output

查看:97
本文介绍了SQL:mysqli_query,无输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

session_start();
$user=$_SESSION['username'];
$con=mysqli_connect("$host","$username","$password","$db_name");
$sql1="SELECT UserID FROM User WHERE username='$user'";
$query=mysqli_query($con,$sql1);
echo $query;

我不确定这是什么问题,我尝试在这里搜索,并尝试了不同的方式来编写语法和检查参数中的错误,但是仍然没有命令的输出.我在这里想念什么?

Im not sure what's the problem with this, I've tried searching around here and tried different ways of writing the syntax and checking for errors in parameter but still no output for the command. What am i missing here?

更新

$sql1="SELECT UserID FROM User WHERE username='$user'";
$query=mysqli_query($sql1,$con);
$row=mysqli_fetch_array($query);
$uid=$row[0];
echo $uid;

根据其他人的回答,我尝试这样做.仍然没有输出,或者给出的输出为0.如果我在sql中尝试查询,它会显示正确的查询.

As answered by the others, I tried doing this. There is still no output or an output of 0 was given. Where if I tried the query in sql, it shows the right one.

更新2

它尝试了var_dump()命令,并返回NULL.这是否意味着它无法读取数据库?

It tried the var_dump() command and it returns NULL. Does that mean it can't read the database?

推荐答案

我能够使用mysql语法解决我的问题.仍然无法确定mysqli的问题,但能够完成我的任务.感谢您的回答.

I was able to do some workaround with my problem using mysql syntax. Still not able to determine the problem with mysqli but able to finished my task. Thanks for answering guys.

这篇关于SQL:mysqli_query,无输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆