Jump to content

[SOLVED] Trouble writing to database


Nexus Zero

Recommended Posts

This following code snippet successfully takes a specific entry from the "comments" table and dumps it into the $row array. The 'if' statement looks at a $_GET value which, if set to 'up', takes an integer from this array, increases it, and is meant to write it back to the database. While the code does increase this integer (revealed when using echo lines), it doesn't seem to write the number back to the database, or if it does, not in the right place.

 

$result = mysql_query("SELECT * FROM comments WHERE commentsID=$commentsid");
$row = mysql_fetch_array($result);

if($judgement=="up") 
  {
  $insert = $row['Rank']++;
  mysql_query("INSERT INTO comments ('Rank') VALUES ($insert)");

 

Any help will be much appreciated!

Link to comment
Share on other sites

Thanks for the quick reply.

 

Unfortunately, that didn't seem to work either. After the increment, both $insert and $row['Rank'] are 1 (as opposed to 0 before). It's a matter of writing it to the database in the correct way, though I don't see what's going wrong.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.