草庐IT

Mysqli_result

全部标签

php - 在 Mysqli 准备语句中返回一个数组

我的数据库类中有函数返回来自特定国家(例如西类牙)的人的id。但出于某种原因,我只得到一个值,但同一个国家的人很多。这是函数:ClassDbAb{private$db;publicfunctionsameCountry($country){$query="SELECTidFROMusersWHEREcountry=?";$stmt=$this->db->prepare($query);$stmt->bind_param("s",$country);if($stmt->execute()){$stmt->bind_result($sameCountry);$stmt->fetch();r

php - 使用 mysqli 从数据库中获取所有结果

这个问题在这里已经有了答案:getarrayofrowswithmysqliresult(2个答案)关闭2年前。请查看下面我的代码。通过该类(class),我可以像这样显示结果:$connectTest=newtestResults();$test=$connectTest->grabResults(test,id,id);echo$test['id'];echo$test['name'];echo$test['address'];在我的数据库中,“测试”表中有几个字段。我使用index.php?id=1转到我的页面。有了这个,我只显示一行的结果,因为它获取了所有结果,其中id=1。我

php - 如果不存在则使用 mysqli + php 创建数据库

如果数据库名称不存在,我正在尝试使用mysqli创建一个数据库,使用以下代码:SignUp!LogIn代码检查数据库,发现它不存在。接下来我想创建数据库(如果它不存在)但我总是收到以下错误:Warning:mysqli_connect():(HY000/1049):Unknowndatabase'php1'inE:\xampp\htdocs\PhpProject1\index.phponline3Unknowndatabase'php1'Warning:mysqli_query()expectsparameter1tobemysqli,booleangiveninE:\xampp\ht

如果未启用 mysqli,PHP 不会抛出异常

我有set_charset("utf8");}catch(Exception$e){echojson_encode(array('msg'=>$e->getMessage()));}如果mysqli未启用,则它不会捕获错误:Fatalerror:UncaughtError:Class'mysqli'notfoundinC:\test\db_connect.php:8Stacktrace:#0C:\test\getContacts.php(2):require_once()#1{main}throwninC:\test\db_connect.phponline8我该怎么做才能捕获错误?这

php - mysqli_num_rows() 期望参数 1 为 mysqli_result, object

这个问题在这里已经有了答案:PHPWarning:mysqli_num_rows()expectsparameter1tobemysqli_result,objectgiven(1个回答)关闭11个月前。这是我第一次使用mysqli。它似乎在寻找mysqli_num_rows()中括号之间的结果集的名称。然而,当我尝试$stmt、$conn时,却什么也没有,我得到了同样的错误。令人沮丧!下面最后一行$WHAT的位置是什么?或者也许我正在尝试错误的方法。我想要做的就是检查是否返回了结果。我真的不需要行数。我应该只做一个带有错误消息的else语句吗?这是最好的方法吗?是否有编写函数来连接和

PHP Codeigniter 错误:调用未定义的方法 ci_db_mysql_driver::result()

我试图使用codeigniter创建一个xml响应。当我运行代码时抛出以下错误。此页面包含以下错误:第1行第48列错误:文档末尾的额外内容load->helper('url','xml','security');echo'oops!noparametersselected.';}functionauthorize($email='blank',$password='blank'){header("content-type:text/xml");echo'';echo'';if($email=='blank'AND$password=='blank'){echo'failed';}els

PHP 警告 : mysqli_close() expects parameter 1 to be mysqli

我正在尝试通过php连接到sql数据库,但一直收到我无法弄清楚的错误。我可以毫无错误地连接到另一个调试脚本。我获得连接并提取数据,但最后出现错误。$con=mysqli_connect("localhost","username","password","dbname");//Checkconnectionif(mysqli_connect_errno()){echo"FailedtoconnecttoMySQL:".mysqli_connect_error();}//ThisSQLstatementselectsALLfromthetable'Locations'$sql="SELE

php - 使用 mysqli_query() 时,mysql_error() 不工作

这个问题不太可能帮助任何future的访问者;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况有关,这些情况并不普遍适用于互联网的全局受众。为了帮助使这个问题更广泛地适用,visitthehelpcenter.关闭9年前。没有错误显示使用mysql_error()函数。msqli_query()工作正常,但是当我在它旁边添加mysql_error时,即使查询无效并且连接错误,我在网页中也没有收到任何东西。example.mysqli_query($link,$query)ordie(mysql_error());链接脚本:查询脚本:='".mysql_real_escape

php - Symfony Doctrine 数组结果的 Flatten Array Result

通过存储库,我得到了一个数组结果(每个数组都是一个实体对象),如下所示:array(0=>objectoftypeentity,1=>anotherobjectoftypeentity,2=>anotherobjectoftypeentity,)每个对象都有一些属性,比如id和name等。但我想要的是仅使用每个对象的ID展平整个数组。我想要的是这个(仅用ID展平数组):Array([0]=>1[1]=>6[2]=>23)Mysolution:$ids=array_map($transform=function($entity){if($entityinstanceofEntity){r

php xpath : query within a query result

我正在尝试解析一个html文件。想法是使用title和desc类获取跨度,并在每个具有属性class='thebest'的div中获取它们的信息。这是我的代码:testmoshe1haimmoshe2moshe3title1desc1spanclass="title">title2desc2KFIR;$doc=newDOMDocument();@$doc->loadHTML($example);$xpath=newDOMXPath($doc);$expression="//div[@class='thebest']";$arts=$xpath->query($expression);f