title: can someone tell me what the error in this page?
body: <p>i get this error line on this php file . can someone locate where is the error ?</p>
  
  <p>-------------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 '' at line 1----------</p>
  
  <p>i have this page for votes to users but if i vote in one user this vote goes to all users . how can i make this code when voting this vote goes only to its user .
            --  </p>
  
  <pre><code> // Connects to your Database 
   mysql_connect("localhost", "dbusername", "dbpassword") or die(mysql_error()); 
   mysql_select_db("mydatabase") or die(mysql_error()); 
  
  //We only run this code if the user has just clicked a voting link
   if ( $mode=="vote") 
   { 
  
   //If the user has already voted on the particular thing, we do not allow them to vote     again    
      //$cookie = "Mysite$id"; 
  if(isset($_COOKIE[$cookie])) 
      { 
      Echo "Sorry You have already ranked that site &lt;p&gt;"; 
      } 
  
   //Otherwise, we set a cooking telling us they have now voted 
  else 
      { 
      $month = 2592000 + time(); 
      setcookie('Mysite'.$id, 'Voted', $month); 
  
       //Then we update the voting information by adding 1 to the total votes     and adding their vote (1,2,3,etc) to the total rating 
  
   mysql_query ("UPDATE userads SET total = total+$voted, votes = votes+1 WHERE id =     $id"); 
  
      } 
   } 
    if ( $mode2=="vote") 
   { 
  
   //If the user has already voted on the particular thing, we do not allow them to vote     again    
      //$cookie = "Mysite$id"; 
  if(isset($_COOKIE[$cookie])) 
      { 
      Echo "Sorry You have already ranked that site &lt;p&gt;"; 
      } 
  
   //Otherwise, we set a cooking telling us they have now voted 
  else 
      { 
      $month = 2592000 + time(); 
      setcookie('Mysite'.$id, 'Voted', $month); 
  
       //Then we update the voting information by adding 1 to the total votes     and adding their vote (1,2,3,etc) to the total rating 
  
   mysql_query ("UPDATE userads SET total = total+$voted, nvotes = nvotes+1 WHERE id =     $id"); 
  
      } 
   }  
  
   //Puts SQL Data into an array
   $data = mysql_query("SELECT * FROM userads WHERE id = $id ") or die(mysql_error()); 
  
   //Now we loop through all the data 
   while($ratings = mysql_fetch_array( $data )) 
  
  ?&gt;
  &lt;link href="style.css" type="text/css" rel="stylesheet" /&gt;
   { 
  &lt;?php
  echo '&lt;div id="voting_14" class="voting voting_template_votess-up-down"&gt;';
  echo "&lt;strong class='positive_votes'&gt;";
  $current = $ratings[votes];
  echo "&lt;span&gt;+" . round($current,0) . "&lt;/span&gt;";
  echo "&lt;a href=".$_SERVER['PHP_SELF']."?mode=vote&amp;voted=1&amp;id=".$ratings[id]."&gt;       &lt;input class='vote_positive' type='submit'&gt;&lt;/a&gt;";
  echo '&lt;/strong&gt;';
  
  echo "&lt;strong class='negative_votes'&gt;";
  $current2 = $ratings[nvotes]; 
  echo "&lt;a href=".$_SERVER['PHP_SELF']."?mode2=vote&amp;voted=2&amp;id=".$ratings[id]."&gt;      &lt;input class='vote_negative' type='submit'&gt;&lt;/a&gt;";
  echo "&lt;span&gt;-". round($current2,0) ."&lt;/span&gt;";
  echo '&lt;/strong&gt;';
  
  echo '&lt;/div&gt;';
  
   } 
   ---the end 
  </code></pre>
  
  <p>i have sql table userads  with : id , name , username , total, votes , nvotes.  </p>