草庐IT

fetch_sub

全部标签

php - mysqli_query 和 mysqli_fetch_assoc 给出错误

我一直在尝试为访问我的index.php文件时发现的mysql错误消息找到解决方法,代码如下:Warning:mysqli_query()expectsparameter1tobemysqli,resourcegivenin/Applications/XAMPP/xamppfiles/htdocs/cms/includes/navigation.phponline24Warning:mysqli_fetch_assoc()expectsparameter1tobemysqli_result,nullgivenin/Applications/XAMPP/xamppfiles/htdocs

php - 如何使用数组中的键 [table.attribute] mysqli_result::fetch_array?

我正在尝试创建一个通用方法来自动从这样的查询中实例化对象:SELECTtown.*,content.*,user.*FROMtownhub.contentLEFTJOINtownONcontent.townReceiver=town.id_townLEFTJOINuserONcontent.author=user.id_user我想要构建的方法应该返回3种类型的对象:Town、User和Content到一个数组中。我想到了类似的事情:protectedfunctionbuild_objects($result,Array$classes){$data=array();$i=0;whil

php - 在 sql->fetch() 时对数组求和

我的代码是这样的:$sql=$pdo->prepare('SELECTsource_clicks,source_impr,source_spendFROM`statistic`WHEREcamp_id=?ANDdateBETWEEN?AND?');$sql->bindColumn('source_clicks',$source_clicks);$sql->bindColumn('source_impr',$source_impr);$sql->bindColumn('source_spend',$source_spend);$sql->execute([$_POST['get_sour

php - while($row = mysqli_fetch_array($result)){ 选择多个表时

我正在使用PHP、javascript和mysql创建此搜索功能。这段代码运行正常。我在html搜索框中输入了一些数据,该搜索框将%keyword%发送到此PHP函数,该函数返回我想要的数据。$query="SELECTid,fornavn,efternavn,adresse,postnr,city,tlf,kon,email,fodselsdagFROMkundeWHEREemailLIKE'%$keyword%'ORfornavnLIKE'%$keyword%'";$result=mysqli_query($dbc,$query);if($result){if(mysqli_aff

php - 如何在 mysql_fetch_assoc 结果中传递一个 post 变量

if($_POST){$client=$_POST['client'];$insu1=$_POST['insu1'];$insu2=$_POST['insu2'];$date=date("dmY");if($insu2='alp'or$insu2='bppi'or$insu2='cpmp'or$insu2='carp'or$insu2='dsp'or$insu2='eep'or$insu2='earp'or$insu2='mbp'){//set@insu2=$insu2;$sql2="Select'$insu2'fromtbl_engineeringorderbytimestamp(`

PHP MySQLi fetch "array push"覆盖数据

我有2个数组:$arr=[];$tempArray=['val1'=>"xxx",'val2'=>0,'val3'=>0];然后在我的mysql查询中,我用当前行的值填充临时数组,最后将他插入$arr:$stmt->bind_result($tempArray["val1"],$tempArray["val2"],$tempArray["val3"]);while($stmt->fetch()){array_push($arr,$tempArray);}问题是,在每个循环中,“array_push”都会覆盖$arr中的数据。例如,我在$stmt->fetch()中循环了3次。1。循环$

php - 是不是可以调用这个stmt fetch语句呢?

我是PHPOOP的新手,我在这里有一个问题。可以这样调用fetch语句吗?$this->stmt->fetch()?我想做的是在我的类中定义$stmt变量并在不同的方法中使用它,即:classDisplay{private$connection;private$stmt;publicfunction__construct($connection){$this->connection=$connection;}publicfunctionselectUsersValues(){$query="SELECTname,surname,employment_dateFROMemployee";

php - fetch_assoc 返回缺少的行

我从数据库表中读取了一些问题,并在内部循环中使用外键从另一个表中获取了可能的答案。显示的答案行应该是固定的5行,但它总是只返回4行,内循环中的答案的第一行似乎总是丢失。$_POST['nbr']是题目数$_POST['type']是问题的类型$row用于问题$row2用于与相关的建议答案这是代码passéunexamenSpecialité:query("Selectnomfromspecialite");while($row=$result->fetch_assoc()){echo''.$row['nom'].''.PHP_EOL;}?>choisilenombredequestio

php - 尝试从数据库中选择 WooCommerce 值时出现 mysqli_fetch_assoc 错误

我目前正在制作一个WordPress插件并尝试从WooCommerce数据库中选择一些值,但我一直得到的都是相同的错误。可能出了什么问题?我的代码:functionprntPage(){//Connectisdefinedsomewhereelse$query="SELECT*FROM`wp_woocommerce_order_items`";$result=mysqli_query($conn,$query);while($row=$result->mysqli_fetch_assoc()){echo"id:".$row["order_item_id"]."-ProductName:

php - 语法错误或访问冲突 : 1139 Got error 'empty (sub)expression' from regexp

我有这个正则表达式:REGEXP'(^0+|0+)17198671(0+|$)$'需要匹配这样的字符串US0017198671000171986710000000000000001719867100000000基本上我需要的是,如果字符串中有所有相同的数字替换零并以零结尾或什么都没有,我想匹配它们。我不明白为什么这个有效的正则表达式不适用于MySQL 最佳答案 MySQL正则表达式引擎不允许空替代,例如ab(c|)或a|。(0+|$)部分匹配输入字符串末尾的1+个零或空字符串,这会导致错误。请注意(^0+|0+)意味着一个或多个零不