You should be able to do this with a single uery, something like this (please note the comments on the first few lines, I assumed $_POST data;
<?php
/**
* $_REQUEST contains all od the data from $_POST, $_GET and $_COOKIE
*
* If you know where the data is coming from you should use the correct array
* I've guessed $_POST
*/
$rated=$_POST['rated'];
echo $rated;
$rating=$_POST['rating'];
echo $rating;
// Make a MySQL Connection
mysql_connect("localhost", "********", "********") or die(mysql_error());
mysql_select_db("*********") or die(mysql_error());
$result = mysql_query("UPDATE `main` SET `rating` = (`rating` + 1)
WHERE `username` = '$rated'");
if($result)
{
echo 'good';
}
else
{
echo 'bad';
}
?>
I assumed that the field in the database that you're updating is `rating`. If this is called something different replace both instances of `rating` with the correct name.