MYSQL Query Problem

Hi There, I have a problem with my MYSQL query, I keep getting this message:

mysql 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 ‘1’ at line 1 in query: 1

Shown below is the script can anyone tell me what the problem is:

<?php
	$cid = (int)($_GET['cid']);
	$pid = (int)($_GET['pid']);
	
	// Connects to your Database
	mysql_connect("localhost", "##", "") or die(mysql_error());
	mysql_select_db("###") or die(mysql_error()); 
	
	// Get the radio button values 
		
	
	// Insert record 
		
	// What if the don't like yours
	if (!isset($_POST['vote'])) {
	$sql = mysql_query("UPDATE co_rate SET votes = votes +1, total = total +1 WHERE photo_id= $pid");
	  $update_idy = mysql_query($sql) or die ("mysql error: " . mysql_error() . " in query: " .  $sql);
		$nr = mysql_num_rows( $sql );
		mysql_free_result( $sql );	
		
	} elseif (!isset($_POST['idly'])) { 
	
		// Update the data
	$sqla = mysql_query("UPDATE co_rate SET dly = dly +1, total = total +1 WHERE photo_id= $pid");
		  $update_idy = mysql_query($sqla) or die ("mysql error: " . mysql_error() . " in query: " .  $sqla);
		$nr = mysql_num_rows( $sqla );
		mysql_free_result( $sqla );	
	}

	// Put it into an array 
	$array = mysql_query("SELECT * FROM co_rate ") 
	or die (mysql_error());
	
	
	// Loop Through the data 
	while ($rate = mysql_fetch_array($array)) {
									  
									  //This calculates the sites ranking and then outputs it - rounded to 1 decimal
										$current =  $rate[votes] / $rate[total] * 100; 
										echo "Current Rating: " . round($current, 1) . "% <br>"; 

									  }

?>

your sql looks okay.

you might want to try;
UPDATE co_rate SET co_rate.votes = co_rate.votes +1, co_rate.total = co_rate.total +1 WHERE photo_id= $pid

or;
UPDATE co_rate SET votes = $votesplusone, total = $totalplusone WHERE photo_id= $pid

I keep getting this error when I choose the bottom radio button any ideas?

mysql 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 ‘1’ at line 1 in query: 1

please echo the sql string

SQL

	if (isset($_POST['vote'])) {
	$sql = mysql_query("UPDATE co_rate SET co_rate.votes = co_rate.votes +1, co_rate.total = co_rate.total +1 WHERE photo_id= $pid");
	  $update_idy = mysql_query($sql) or die ("mysql error: " . mysql_error() . " in query: " .  $sql);
		$nr = mysql_num_rows( $sql );
		mysql_free_result( $sql );	
		
	} elseif (!isset($_POST['idly'])) { 
	
		// Update the data
	$sqla = mysql_query("UPDATE co_rate SET co_rate.dly = co_rate.dly +1, co_rate.total = co_rate.total +1 WHERE photo_id= $pid");
		  $update_idy = mysql_query($sqla) or die ("mysql error: " . mysql_error() . " in query: " .  $sqla);
		$nr = mysql_num_rows( $sqla );
		mysql_free_result( $sqla );	
	}

i can’t believe i’m debugging php code, i don’t even do php!!

$sql = [COLOR="Red"]mysql_query[/COLOR]("UPDATE ... ");
$update_idy = [COLOR="red"]mysql_query[/COLOR]($sql)

mysql_query() executes a query, and assigns a “handle” (whatever that is)

you cannot then execute the handle as though it were another query

This loop will read each row of the results set in turn into a php array:

while ($row=$this->db->dbFetchArray($result)) {
    $database_result_output[]=$row;
}