Jump to content

PHP Updating Script


Iryk

Recommended Posts

[code]<?php
include("db_connect.php");
if($piece == "1") { $i = one; }
if($piece == "2") { $i = two; }
if($piece == "3") { $i = three; }
if($piece == "4") { $i = four; }
if($piece == "5") { $i = five; }
if($piece == "6") { $i = six; }
if($piece == "7") { $i = seven; }
if($piece == "8") { $i =eight; }
if($piece == "9") { $i = two; }
if($change == "yes") {
  $col = $collected;
  $col++;
  $query_1 = "UPDATE $map SET Collected='$col',$i='$change' WHERE User='$user'";
  mysql_query($query_1) or die("The change could not be made.");
  echo "You're map pieces for <b>$map</b> have been updated.";
}
?>[/code]

That code doesn't work and I have no clue why... on this url below it gives you a map that you are allowd to change by clicking on a piece:

[a href=\"http://majestic-neo.com/pet_db/maps.php?map_num=1\" target=\"_blank\"]http://majestic-neo.com/pet_db/maps.php?map_num=1[/a]

This url is the url that you get for changing a piece to the image without a ? mark on it:

[a href=\"http://majestic-neo.com/pet_db/update.php?map=Secret%20Laboratory%20Map&user=Iryk&piece=5&change=yes&collected=3\" target=\"_blank\"]http://majestic-neo.com/pet_db/update.php?...yes&collected=3[/a]

If anyone knows why the script isn't working please help and give me a working script.
Link to comment
Share on other sites

[!--quoteo(post=365251:date=Apr 16 2006, 09:40 AM:name=shocker-z)--][div class=\'quotetop\']QUOTE(shocker-z @ Apr 16 2006, 09:40 AM) [snapback]365251[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Where are you getting the variables $collected, $change and $user from?
[/quote]

hi
you can help yourself even more just by putting in one more bit on one of your lines:

[code]
mysql_query($query_1) or die("The change could not be made - ".mysql_error());
[/code]

that will tell you what the error is as well as your 'change could not be made' message. try it and let us know what your result is.
Link to comment
Share on other sites

The change could not be made.
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Map SET Collected='4',three='yes' WHERE User='Iryk'' at line 1

That is what I got... and my variables are coming from the url after you click one of the images, w/ a ? mark, on them.
Link to comment
Share on other sites

Does the table 'Map' exists and are you sure the field names are correct? it looks like its to do with the table name as that is first bit of query shown, if it was a field problem then wouldn't normaly show table name... if table map exists make sure it starts with a capital like in your query :)
Regards
Liam
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.