I am having problems updating and inserting data into my database. I have debugged most of the program so I know for sure that the problem is the line of code for updating and the line of code for inserting data. I am very confused because their are other functions that use the same code and all the variables I used in each function were declared locally in the function so I know they are not conflicting. the code at the top that says is all the database code to open the line of communication with the database and php. That code works I've already tested it in other programs. I can still pull data with the SELECT code from the database and I've checked and double checked if the names match up with the table. This code is part of some ajax code so it will update in real time but the post I use with the javascript transfers the data just fine to the php file. So I have no idea what I'm doing wrong or if there is just something wrong with the server. If anyone as any ideas please let me know. Also the purpose of this code is to make it so that users can like, favorite, and give a rating out of 5 stars to the content they are viewing on my site.
This is the code:
<?php include "base.php";?>
</head>
<?php
$rateMe = mysql_query("SELECT * FROM rating WHERE Username = '".$_SESSION['Username']."' AND Title = '".$_POST['myTitle']."'");
if(mysql_num_rows($rateMe) == 0)
{
$registerquery = mysql_query("INSERT INTO rating (Username, Author, Star, Like, Favorite, Title) VALUES('".$_SESSION['Username']."','".$_POST['myAuthor']."','".$_POST['myrating']."','".$_POST['myLike']."', '".$_POST['myFavorite']."', '".$_POST['myTitle']."')");
}else
{
$makeUpdate = mysql_query("UPDATE rating SET Star = '".$_POST['myrating']."' WHERE Username = '".$_SESSION['Username']."' AND Title = '".$_POST['myTitle']."'");
}
?>
and this is the table I'm trying to insert data into
table: rating
Username varchar(255)
Author varchar(255)
Star float
Like varchar(255)
Favorite varchar(255)
Title varchar(255)