[英]Cannot understand why this code doesn't work. I have some trouble with my sql database. $sqll="SELECT * FROM netbarg WHERE r_number='02177736'"
This is my code.这是我的代码。 I know this number(02177736) is stored in database.我知道这个号码(02177736)存储在数据库中。 I'm completely new in php and mysql.我是 php 和 mysql 的新手。
$sqll="SELECT * FROM netbarg WHERE r_number='02177736'";
$result=mysql_query($sqll,$connection);
$ro= mysql_fetch_array ($result);
var_dump($ro);
but it returns false to me.但它对我来说是假的。 I have no idea.我不知道。 Any help will be appreciated.任何帮助将不胜感激。
You should check for errors and report them, eg您应该检查错误并报告它们,例如
$sqll="SELECT * FROM netbarg WHERE r_number='02177736'";
$result=mysql_query($sqll,$connection);
//check for errors!
if (!$result) {
die('Invalid query: ' . mysql_error());
}
$ro= mysql_fetch_array ($result);
var_dump($ro);
Also, you should using something other than the mysql_ functions as are deprecated - see http://php.net/manual/en/mysqlinfo.api.choosing.php此外,您应该使用 mysql_ 函数以外的其他内容,因为已弃用 - 请参阅http://php.net/manual/en/mysqlinfo.api.choosing.php
User mysqli_query insted of mysql_query and the first pass connection and then your query.用户 mysqli_query 插入了 mysql_query 和第一遍连接,然后是您的查询。
$sqll="SELECT * FROM netbarg WHERE r_number='02177736'";
$result=mysqli_query($connection,$sqll);
//check for errors!
if (!$result) {
die('Invalid query: ' . mysqli_error());
}
$ro= mysqli_fetch_array ($result);
var_dump($ro);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.