Jump to content

Archived

This topic is now archived and is closed to further replies.

Iryk

PHP Updating Script

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.

Share this post


Link to post
Share on other sites
Where are you getting the variables $collected, $change and $user from?

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

×

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.