Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 用单词结果填充数组 $sql23=“从map1pokemon ORDER BY RAND()中选择*LIMIT 1;”; $result23=mysql\u query($sql23)或die(mysql\u error()); $battle\u get23=mysql\u fetch\u数组($result23); $sql2=“从口袋妖怪中选择*,其中name=””$battle_get23['pokemon']。“”; $result2=mysql\u query($sql2)或die(mysql\u error()); $battle\u get2=mysql\u fetch\u数组($result2); $filler=“从口袋妖怪中选择*,其中name='Charmander'”; $filler2=mysql\u query($filler)或die(mysql\u error()); $filler3=mysql\u fetch\u数组($filler2); $pokemon1=数组填充(1,10,“$filler3.”); $pokemon2=数组填充(1,2,“$battle\u get2.”); $pokemon3=array\u merge($pokemon1$pokemon2); 洗牌(口袋妖怪3美元); $pokemon4=数组移位($pokemon3); $pic2=mysql\u real\u escape\u字符串($pokemon4['pic']); $pic=带标签($pic2); 回声“; 回声“_Php_Mysql - Fatal编程技术网

Php 用单词结果填充数组 $sql23=“从map1pokemon ORDER BY RAND()中选择*LIMIT 1;”; $result23=mysql\u query($sql23)或die(mysql\u error()); $battle\u get23=mysql\u fetch\u数组($result23); $sql2=“从口袋妖怪中选择*,其中name=””$battle_get23['pokemon']。“”; $result2=mysql\u query($sql2)或die(mysql\u error()); $battle\u get2=mysql\u fetch\u数组($result2); $filler=“从口袋妖怪中选择*,其中name='Charmander'”; $filler2=mysql\u query($filler)或die(mysql\u error()); $filler3=mysql\u fetch\u数组($filler2); $pokemon1=数组填充(1,10,“$filler3.”); $pokemon2=数组填充(1,2,“$battle\u get2.”); $pokemon3=array\u merge($pokemon1$pokemon2); 洗牌(口袋妖怪3美元); $pokemon4=数组移位($pokemon3); $pic2=mysql\u real\u escape\u字符串($pokemon4['pic']); $pic=带标签($pic2); 回声“; 回声“

Php 用单词结果填充数组 $sql23=“从map1pokemon ORDER BY RAND()中选择*LIMIT 1;”; $result23=mysql\u query($sql23)或die(mysql\u error()); $battle\u get23=mysql\u fetch\u数组($result23); $sql2=“从口袋妖怪中选择*,其中name=””$battle_get23['pokemon']。“”; $result2=mysql\u query($sql2)或die(mysql\u error()); $battle\u get2=mysql\u fetch\u数组($result2); $filler=“从口袋妖怪中选择*,其中name='Charmander'”; $filler2=mysql\u query($filler)或die(mysql\u error()); $filler3=mysql\u fetch\u数组($filler2); $pokemon1=数组填充(1,10,“$filler3.”); $pokemon2=数组填充(1,2,“$battle\u get2.”); $pokemon3=array\u merge($pokemon1$pokemon2); 洗牌(口袋妖怪3美元); $pokemon4=数组移位($pokemon3); $pic2=mysql\u real\u escape\u字符串($pokemon4['pic']); $pic=带标签($pic2); 回声“; 回声“,php,mysql,Php,Mysql,”; 顶部的查询获取了每个口袋妖怪的信息,然后我想使用数组填充和数组合并使其中一个结果更难显示,但是现在它没有显示混合了口袋妖怪后的口袋妖怪结果,我相信我混合了口袋妖怪是错的,但不知道为什么 有人知道我做错了什么吗?这句话似乎没用: $pic2=mysql\u real\u escape\u字符串($pokemon4['pic']) 然后,您不显示所需内容是合乎逻辑的,因为您不存储所需内容。让我们回顾一下您的代码: $filter3显然是一个包含所有表列的数组 $pokemon1=数组填充(1

”; 顶部的查询获取了每个口袋妖怪的信息,然后我想使用数组填充和数组合并使其中一个结果更难显示,但是现在它没有显示混合了口袋妖怪后的口袋妖怪结果,我相信我混合了口袋妖怪是错的,但不知道为什么


有人知道我做错了什么吗?

这句话似乎没用:

$pic2=mysql\u real\u escape\u字符串($pokemon4['pic'])

然后,您不显示所需内容是合乎逻辑的,因为您不存储所需内容。让我们回顾一下您的代码:

$filter3
显然是一个包含所有表列的数组

$pokemon1=数组填充(1,10,“$filler3.”)

什么?是否将数组与字符串连接起来?不要用这种诡计,它不会给你带来好的结果<代码>$pokemon1=数组填充(1,10$filler3)正常。有点贪婪,但还行

你可以做的一件事是使用随机生成器,它将更容易使用,更少贪婪,更快

 $filler = "SELECT * FROM pokemon WHERE name='Charmander'";
 $filler2 = mysql_query($filler) or die(mysql_error());
 $filler3 = mysql_fetch_array($filler2);
$rand=rand(12);

如果($rand在新代码中。它们不再被维护,现在是。看到红色框了吗?改为学习准备好的语句,并使用or。我知道,人们在我的每个问题中都这么说XD我最终会切换,但现在我使用它,因为我知道:/在你把事情弄得一团糟之前,现在停止使用它。PDO只需要。每个您在这里编写的代码行将在未来的PHP版本中被破坏,所以现在花一点时间来复习PDO并避免以后的麻烦。如果您使用PDO,您将免费消除危险。另外,为什么您要逃避MySQL的
$pic
HTML而不是逃避实际在MySQL中使用的
$battle\u get23
MySQL?这里似乎有点不对劲。好吧,我现在不担心所有这些,伙计们,只需要解决手头的问题:/你说的“贪婪”是什么意思?兰特(12)是从哪里来的?好吧,谢谢,我还是用我的方式找到了另一个解决方案,谢谢你:)我相信你的方法是可行的,所以我会接受它。rand是一个随机生成正整数的函数。它是一个内置函数。“贪婪”代表“你的解决方案在内存中占据了很多位置,执行时间也很长”.我明白了,这并不能完全满足我的需要,在我提供的代码中,我只完成了我需要的部分工作。
 $filler = "SELECT * FROM pokemon WHERE name='Charmander'";
 $filler2 = mysql_query($filler) or die(mysql_error());
 $filler3 = mysql_fetch_array($filler2);
$rand = rand(12);
if($rand <=10){
     $result = $filler3;
}else{
     $result = $battle;
}
echo $result['name'];