简体   繁体   English

无法理解为什么此代码不起作用。 我的 sql 数据库有问题。 $sqll="SELECT * FROM netbarg WHERE r_number='02177736'"

[英]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.

相关问题 我有两个具有相同代码的不同域,但是其中一个不起作用。 为什么? - I have two different domains with the same code, but one of them doesn't work. Why? 从sql数据库中选择数据无效。 我如何解决它? - Selecting data from sql database doesn't work. how do I fix it? 为什么我的php无法连接到sql数据库代码? - Why doesn't my php connect to sql database code work? 我在使用 str_split 时遇到了一些问题,它无法在我的语言中正常工作 - I have some trouble with str_split, it doesn't work correctly with my language 我正在尝试将一些数据输入数据库。 它创建新表,但不填充它们 - I'm trying to get some data into my database. It creates the new tables but doesn't fill them 我的简单HTML上传器无法正常工作。 为什么? - My simple HTML uploader doesn't work. WHY? 我无法将IP添加到我的数据库中。 为什么? - I can't add IPs to my database. Why? 如何将单个值发布到PHP MyAdmin。 此代码似乎无效。 我正在尝试从表单获取值到数据库 - How do I post a single value to PHP MyAdmin. This code doesn't seem to work. I am trying to get a value from a form into a database 我如何使用php创建CMS,而最终用户不必了解数据库。 那可能吗 - How can I Create a CMS using php where end user doesn't have to know anything about database. Is that possible 速记IF不起作用。 为什么? - Shorthand IF doesn't work. Why?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM