Jump to content

Silvar

Members
  • Posts

    28
  • Joined

  • Last visited

Everything posted by Silvar

  1. The problem seems to be problems with the id it inserts into my mysql because of duplication?
  2. Okay I moved the $amountIsCurrently+$gAmount to the mysql_query, now I get this error: Duplicate entry '1' for key 'PRIMARY'
  3. So how would you rewrite this code to do the proper action: $gName = htmlspecialchars(addslashes($_POST["editName"])); $gAmount = $_POST["editAmount"]; $gDate = date("d/m-Y"); if(!empty($gName) && !empty($gAmount)) { $editId = $_GET["edit"]; $getCurrentAmount = mysql_query("SELECT amount FROM guilt_list WHERE id = $editId") or die(mysql_error()); $amountIsCurrently = mysql_fetch_row($getCurrentAmount); $listAmount = $amountIsCurrently+$gAmount; mysql_query("UPDATE guilt_list SET name='$gName', amount='$listAmount' WHERE id='$editId'"); mysql_query("INSERT INTO guilt_changes(id, amount, date) VALUES('$editId', '$gAmount', '$gDate')") or die(mysql_error()); echo "<h2>Success: The guilt that ".$gName." owes has been edited!</h2>"; echo "<div style=\"width: 680px; margin: 10px 0 10px 0\"> </div>"; }
  4. Hello everyone. This seems to be a nice forum! You will be seeing me here a lot in the future. Anyway, I got a problem with this code: $editId = $_GET["edit"]; $getCurrentAmount = mysql_query("SELECT amount FROM guilt_list WHERE id = $editId") or die(mysql_error()); $amountIsCurrently = mysql_fetch_row($getCurrentAmount); $listAmount = $amountIsCurrently+$gAmount; mysql_query("UPDATE guilt_list SET name='$gName', amount='$listAmount' WHERE id='$editId'"); It gives me: "Fatal error: Unsupported operand types in /var/www/********/public_html/guilt.php on line 171" Line 171 is: $listAmount = $amountIsCurrently+$gAmount; What seems to be the problem? I can't figure it out. Thanks in advance and happy new year! Best regards, - Silvar
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.