freemancomputer Posted April 26, 2012 Share Posted April 26, 2012 I am having a problem with updating 2 table entry's at time. If i take out the num_votes it will add the rating. I'm not sure if I'm not doing the math correctly or if its not being entered correctly, then again I could be way off. @mysql_select_db($database) or die( "Unable to select database"); $title = mysql_real_escape_string(urldecode($_POST["title"])); $rating= mysql_real_escape_string($_POST['rating']); $find_query="SELECT * FROM movie WHERE title='$title'"; $find_result=mysql_query($find_query); $find_rating= mysql_result($find_result, $i, "rating"); $find_num_votes= mysql_result($find_result, $i, "num_votes") $sum_rating = $find_rating + $rating; $sum_num_votes = $find_num_votes + 1; include"scripts/connect.php" ; mysql_connect('localhost',$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $title= mysql_real_escape_string($_POST['title']); $error = ''; $sql_rating = "UPDATE movie SET rating='$sum_rating' num_votes='$sum_num_votes' WHERE title='$title'"; mysql_query($sql_rating) or die (mysql_error()); Link to comment https://forums.phpfreaks.com/topic/261610-inserting-data-into-a-table/ Share on other sites More sharing options...
awjudd Posted April 26, 2012 Share Posted April 26, 2012 You are missing a , between the two values that you are updating. $sql_rating = "UPDATE movie SET rating='$sum_rating', num_votes='$sum_num_votes' WHERE title='$title'"; ~awjudd Link to comment https://forums.phpfreaks.com/topic/261610-inserting-data-into-a-table/#findComment-1340568 Share on other sites More sharing options...
freemancomputer Posted April 26, 2012 Author Share Posted April 26, 2012 even with the , in there it still dose not work. Link to comment https://forums.phpfreaks.com/topic/261610-inserting-data-into-a-table/#findComment-1340571 Share on other sites More sharing options...
freemancomputer Posted April 26, 2012 Author Share Posted April 26, 2012 turns out i forgot a ; after $find_num_votes= mysql_result($find_result, $i, "num_votes"); Link to comment https://forums.phpfreaks.com/topic/261610-inserting-data-into-a-table/#findComment-1340574 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.