Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6722419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:26:42+00:00 2026-05-26T09:26:42+00:00

i get this error line on this php file . can someone locate where

  • 0

i get this error line on this php file . can someone locate where is the error ?

————-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———-

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 .
—

 // 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 <p>"; 
    } 

 //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 <p>"; 
    } 

 //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 )) 

?>
<link href="style.css" type="text/css" rel="stylesheet" />
 { 
<?php
echo '<div id="voting_14" class="voting voting_template_votess-up-down">';
echo "<strong class='positive_votes'>";
$current = $ratings[votes];
echo "<span>+" . round($current,0) . "</span>";
echo "<a href=".$_SERVER['PHP_SELF']."?mode=vote&voted=1&id=".$ratings[id].">       <input class='vote_positive' type='submit'></a>";
echo '</strong>';

echo "<strong class='negative_votes'>";
$current2 = $ratings[nvotes]; 
echo "<a href=".$_SERVER['PHP_SELF']."?mode2=vote&voted=2&id=".$ratings[id].">      <input class='vote_negative' type='submit'></a>";
echo "<span>-". round($current2,0) ."</span>";
echo '</strong>';

echo '</div>';

 } 
 ---the end 

i have sql table userads with : id , name , username , total, votes , nvotes.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:26:43+00:00Added an answer on May 26, 2026 at 9:26 am

    Correct your code to following,

    setcookie('Mysite'.$id, 'Voted', $month); // ERROR 1
    

    and

     while($ratings = mysql_fetch_array( $data )) 
    {  // ERROR 2
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get this error:- You have an error in your SQL syntax; check the
I get this error: Can't locate Foo.pm in @INC Is there an easier way
I get this error message when installing SQL 2005 Analysis services. The cabinet File
I have an error.php file which can be grossly simplified to: <? if (!isset($error))
We get this error in Visual Studio 2005 and TFS very often. Can anyone
i get this error {Method 'System.DateTime ConvertTimeFromUtc(System.DateTime, System.TimeZoneInfo)' has no supported translation to SQL.}
I have a single php file, with this code in it: <?php header("Location: somepage.php");
I get this error when trying to update the profile in ucp SQL ERROR
hopefully someone can help me with this headache I have. I'm currently running Drupal
OK firstly, I added this line to my .htaccess file so the php engine

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.