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>";
}
?>
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