title: SQL error: Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource
body: <p>I get an error if I try to publish an article on my CMS. </p>
  
  <p>The error: </p>
  
  <blockquote>
    <p>Warning: mysql_fetch_object(): supplied argument is not a valid MySQL
    result resource in
    /home/investmp/domains/cashcow.nl/public_html/publiceer/functions.php
    on line 32 You have an error in your SQL syntax; check the manual that
    corresponds to your MySQL server version for the right syntax to use
    near 'Premiekoopwoning moet terugkomen'', 'eddy', 'publiceren')' at
    line 1</p>
  </blockquote>
  
  <p>Functions.php:</p>
  
  <pre><code>&lt;?php
  //## Function list: News Manager ##//
  //## Content News:  Lead - Header - Chapeaux - Flat text (text) - Quote - Frame - Image - Chart ##// 
  
  //Upload images to folder (resize = 1|0 - $dir (default = /images as stated in admin)
  function uploadFile($fileinput ,$resize, $dir, $id)
  {
  global $_FILES; 
      $file = $_FILES[$fileinput]['name']; 
  
      if (is_uploaded_file($_FILES[$fileinput]['tmp_name'])) { 
          copy($_FILES[$fileinput]['tmp_name'], $dir.$id."_".$file);
  
          if($resize == 1){ 
              imageResize($file); 
          }
  
          chmod($dir.$id."_".$file, 0775); 
          return $_FILES[$fileinput]['name']; 
      }
  
  }
  
  function lastID()
  {
  
      $laatsteID = mysql_query("select id from artikelen order by ID DESC limit 1"); 
  
      $check = mysql_num_rows($laatsteID); 
  
          if($check !== 0){ 
              while($lid = mysql_fetch_object($laatsteID)){ $laatsteID = $lid-&gt;id; } 
          } else{ 
              $laatsteID = 0; 
          }
  
      return $laatsteID;
  
  } 
  
  function lastBannerID()
  { 
  
      include("db_connect.inc.php"); 
  
      $laatsteID = mysql_query("select id from banners order by id DESC limit 1"); 
      $check = mysql_num_rows($laatsteID); 
  
          if($check !== 0){ 
              while($lid = mysql_fetch_object($laatsteID)){ $laatsteID = $lid-&gt;id; }
          } else { 
              $laatsteID = 0; 
          } 
  
      return $laatsteID; 
  
  } 
  
  //Function to change the size of images automatically by default sizes
  function imageResize($image, $width)
  {
      $filename = $image;
  
  //Max height for images (will be downscaled proportionally untill it fits BOTH sizes!)
      $height = 200; 
  
          header('Content-type: image/jpeg'); 
          list($org_width, $org_height) = getimagesize($filename);
  
              $org_ratio = $org_width/$orig_height; 
  
  
          if($width/$height &gt; $org_ratio){
              $width = $height*$org_ratio; 
          } else {
              $height = $width/$org_ratio; 
          } 
  
      $image_p = imagecreatetruecolor($width, $height); 
      $image = imagecreatefromjpeg($filename); 
  
      imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $org_width, $org_height);
  }
  
  //Function to add Twitter messages to the Twitter website (through the Newsmanager)
  function twitterApi($username,$message)
  {
      $getUserData = "select twUsername, twPassword from gebruikers where gebruikersnaam = '$username'";
      $checkData = mysql_query($getUserData) or die (mysql_error()); 
  
          while($tweet = mysql_fetch_object($checkData)){ 
  
          $twusername = $tweet-&gt;username; 
          $twpassword = $tweet-&gt;password;
          $status = $message;
  
              if ($status) {
              $tweetUrl = 'http://www.twitter.com/statuses/update.xml';
  
                  $curl = curl_init();
                  curl_setopt($curl, CURLOPT_URL, "$tweetUrl");
                  curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2);
                  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
                  curl_setopt($curl, CURLOPT_POST, 1);
                  curl_setopt($curl, CURLOPT_POSTFIELDS, "status=$status");
                  curl_setopt($curl, CURLOPT_USERPWD, "$twusername:$twpassword");
  
                      $result = curl_exec($curl);
                      $resultArray = curl_getinfo($curl);
  
                  if ($resultArray['http_code'] == 200)
                      header("location: ?succes=tweetPosted");
                  else
                      header("location: ?error=tweetFailed"); 
  
                  curl_close($curl);
  
              }
  
          }
  
  }
  
  //## User functions ##// 
  
  
  
  function newUser($gebruikersnaam,$voornaam,$achternaam,$wachtwoord,$gebruikersniveau){ 
  
      if($wachtwoord !== "" | " " AND $gebruikersnaam !== "" | " "){ 
  
          $md5wachtwoord = md5($wachtwoord); 
  
          require("db_connect.inc.php"); 
  
          $dubbelegebruiker = mysql_query("select * from gebruikers where gebruikersnaam = '$gebruikersnaam'"); 
          $checkdubbel = mysql_num_rows($dubbelegebruiker); 
  
              if($checkdubbel == 0){ 
  
                      $nieuwegebruiker = "insert into gebruikers (gebruikersnaam, voornaam, achternaam, wachtwoord, gebruikersniveau) values ('$gebruikersnaam','$voornaam','$achternaam','$md5wachtwoord','$gebruikersniveau')";
                      $checkgebruiker = mysql_query($nieuwegebruiker) or die (mysql_error());
  
                  header("location: ../index.php?page=gebruikers&amp;succes=userCreated"); 
  
              } else { 
  
                  header("location: ../index.php?page=gebruikers&amp;error=failedCreateUser"); 
  
              }
  
      } else { 
  
              header("location: ../index.php?page=gebruikers&amp;error=noUsernamePassword"); 
  
          }
  
  }
  
  //## Magazine functions ##//
  
  
  
  //## Database functions ##//
  function eventLog($username, $action)
  {
      $eventlogger = "insert into systemevents (username, action, date) values ('$username','$action', NOW())"; 
      $checklog = mysql_query($eventlogger) or die (mysql_error());  
  }
  
  //## Database functions ##//
  function insertLog($action, $type, $type_id, $username)
  {
      if($type == 'banner'){
          $selectBanner = mysql_query("select soortbanner, titel from banners where id = '$type_id' limit 1");
  
          while($data = mysql_fetch_object($selectBanner)){
              $details = $data-&gt;soortbanner;
              $titel = $data-&gt;titel;
          }
      } elseif($type == 'bericht') {
          $selectBanner = mysql_query("select soortbericht, kop, pubStatus from artikelen where id = '$type_id' limit 1");
  
          while($data = mysql_fetch_object($selectBanner)){
              $details = $data-&gt;soortbericht;
              $titel = $data-&gt;kop;
              $pubStatus = $data-&gt;pubStatus;
          }
      }
  
      if($type == 'banner' || $type == 'bericht'){
  
          $username = $_SESSION['gebruikersnaam'];
  
          $eventlogger = "insert into systemevents (action, type, type_id, details, titel, username, pubStatus) values ('$action', '$type', '$type_id', '$details', '$titel', '$username', '$pubStatus')"; 
  
          $checklog = mysql_query($eventlogger) or die (mysql_error());
      }
  }
  
  
  function backupDatabase($name,$tables = '*')
  {   
      require("db_connect.inc.php"); 
  
      //get all of the tables
          if($tables == '*')
          {
              $tables = array();
              $result = mysql_query('SHOW TABLES');
              while($row = mysql_fetch_row($result))
              {
                  $tables[] = $row[0];
              }
          }
          else
          {
              $tables = is_array($tables) ? $tables : explode(',',$tables);
          }
  
    //cycle through
    foreach($tables as $table)
   {
      $result = mysql_query('SELECT * FROM '.$table);
      $num_fields = mysql_num_fields($result);
  
      $return.= 'DROP TABLE '.$table.';';
          $row2 = mysql_fetch_row(mysql_query('SHOW CREATE TABLE '.$table));
      $return.= "\n\n".$row2[1].";\n\n";
  
      for ($i = 0; $i &lt; $num_fields; $i++) 
      {
          while($row = mysql_fetch_row($result))
          {   
              $return.= 'INSERT INTO '.$table.' VALUES(';
              for($j=0; $j&lt;$num_fields; $j++) 
              {
                  $row[$j] = addslashes($row[$j]);
                  $row[$j] = ereg_replace("\n","\\n",$row[$j]);
                  if (isset($row[$j])) { $return.= '"'.$row[$j].'"' ; } else { $return.= '""'; }
                  if ($j&lt;($num_fields-1)) { $return.= ','; }
              }
              $return.= ");\n";
          }
     }
          $return.="\n\n\n";
      }
  
    //save file
      $handle = fopen('db-backup-'.time().'-'.(md5(implode(',',$tables))).'.sql','w+');
      fwrite($handle,$return);
      fclose($handle);
  
      header("location: ?succes=backupSucces");
  }   ?&gt;
  </code></pre>
  
  <p>Anyone who could help?</p>