Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.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 Mysqli代码需要Mysqli_结果参数_Php_Mysql_Mysqli - Fatal编程技术网

为什么我的PHP Mysqli代码需要Mysqli_结果参数

为什么我的PHP Mysqli代码需要Mysqli_结果参数,php,mysql,mysqli,Php,Mysql,Mysqli,我的php中有一行代码如下: $sel_venue = "SELECT 'char_type' FROM 'character_type_allowed' WHERE status='Open'"; $run_venue = mysqli_query($con,$sel_venue); while ($row = mysqli_fetch_array($run_venue)) if ($row['char_type'] == 'Mortal') { print

我的php中有一行代码如下:

 $sel_venue = "SELECT 'char_type' FROM 'character_type_allowed' WHERE     status='Open'";
 $run_venue = mysqli_query($con,$sel_venue);
 while ($row = mysqli_fetch_array($run_venue)) 

  if ($row['char_type'] == 'Mortal')
      { print ("<li><a href='http://houston-by-night.com/sheets/create/mortal.php'>Create Mortal</a></li>"); }
$sel\u VICE=“从“允许字符类型”中选择“字符类型”,其中状态为“打开”;
$run\u vention=mysqli\u query($con,$sel\u vention);
while($row=mysqli\u fetch\u数组($run\u场所))
如果($row['char\u type']=='vertal')
{打印(“
  • ”)
    与此关联的链接不起任何作用。除了表现出想要扩张的样子之外,没有任何互动。我的错误日志会产生这样的结果:为什么它会要求这样做


    [08-Aug-2016 23:28:41 America/New_York]PHP警告:mysqli_fetch_array()希望参数1是mysqli_result,布尔值在第8行的/home/houchat/public_html/incl/creation.PHP中给出,不能将“作为字段/表名的记号”

    您的查询产生错误。您可以通过mysqli_error($con)看到错误

    请参阅下面更正的代码

     $sel_venue = "SELECT `char_type` FROM `character_type_allowed` WHERE     status='Open'";
     $run_venue = mysqli_query($con,$sel_venue) or die(mysqli_error($con));
     while ($row = mysqli_fetch_array($run_venue)) {
    
       if ($row['char_type'] === 'Mortal') { 
          print ("<li><a href='http://houston-by-night.com/sheets/create/mortal.php'>Create Mortal</a></li>");
       }
    
     }
    
    $sel\u-vinge=“从“允许字符类型”中选择“字符类型”,其中状态为“打开”;
    $run_vention=mysqli_query($con,$sel_venue)或die(mysqli_error($con));
    while($row=mysqli\u fetch\u数组($run\u场所)){
    如果($row['char_type']=='vertal'){
    打印(“
  • ”); } }
    您的查询失败,因此
    $run\u vention
    是布尔值
    false
    ,而不是您期望的值。在使用任何查询结果之前,应该检查错误。这样做:

    $run_venue = mysqli_query(...);
    
    if(!$run_venue) die(mysqli_error($con));
    ... //<- we get here if the query succeeded
    
    $run\u vention=mysqli\u查询(…);
    如果(!$run\u场馆)死亡(mysqli\u错误($con));
    ... //