在布尔值中调用成员函数fetch_assoc()

时间:2015-11-23 10:52:52

标签: php mysql forms mysqli

有一个提交“更新”的表单。表单已从数据库中设置值。它有效(专辑总是改变)。但是如果我更改表单中的值并不重要,我单击“更新”,它将抛出

  

致命错误:在布尔值中调用成员函数fetch_assoc()   第35行/www/doc/www.mudreslova.sk/www/admin/edit-galeriu.php

您可以尝试链接“http://www.mudreslova.sk/admin/edit-galeriu.php?url1=fsdfds”,它现在正在运行。 请问代码有什么问题?

 <?php
   $titulok='Edit ALBUM';
   include('header.php');
   require_once('connect.php');

   if (!empty($_POST["submit"]) && isset($_GET[url1])) { // all entries are required in FORM
      $sql="
         UPDATE gallery 
         SET namesk='{$_POST[namesk]}', nameen='{$_POST[nameen]}', descriptionsk='{$_POST[descriptionsk]}', 
            descriptionen='{$_POST[descriptionen]}', date='{$_POST[date]}', url1='{$_POST[url1]}' 
         WHERE url1='{$_GET[url1]}';

         UPDATE photos 
            SET url1_gallery='{$_POST[url1]}'
            WHERE url1_gallery='{$_GET[url1]}';
      ";
      $success = rename("../photos/$_GET[url1]","../photos/$_POST[url1]");

      if ($mysqli->multi_query($sql) && $success===true) {
         $messEditAlb="Album was changed :)";

      } else {
         $messEditAlb="Error, Album wasn't changed.";
      }
      $_GET["url1"] = $_POST["url1"];
   }
?>

<div id="mobile-margin">
   <div class="container center">
      <h1 class="tshadow">Editovať ALBUM</h1>
      <p><?php echo $messEditAlb ?></p>
   <?php   
      if (isset($_GET[url1])) {
         $result = $mysqli->query("SELECT * FROM gallery WHERE url1='$_GET[url1]'");
      while ($row = $result->fetch_assoc()) { // line 35!
         echo 
         "
         <form action='' method='post'>
            <div class='form-fotky widexs'>
               <label for='namesk' class='left'>Názov albumu - SK:</label>
               <input type='text' name='namesk' id='namesk' value='$row[namesk]' required>
            </div> 
            <div class='form-fotky widexs'>
               <label for='url1' class='left'>url adresa: napr. michalsky-jarmok2</label>
               <input type='text' name='url1' id='url1' value='$row[url1]' required>            
            </div>   
            <div class='form-fotky widexs'>
               <input type='submit' name='submit' value='Update' class='pure-button pure-button-primary bggreen'>
            </div>    
         </form>";
      }};
 include('footer.php'); ?>

0 个答案:

没有答案