Jump to content


Photo

PHP Updating Script


  • Please log in to reply
4 replies to this topic

#1 Iryk

Iryk
  • Members
  • PipPip
  • Member
  • 25 posts

Posted 15 April 2006 - 04:51 PM

<?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.";
}
?>

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.

#2 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 16 April 2006 - 08:40 AM

Where are you getting the variables $collected, $change and $user from?
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#3 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 16 April 2006 - 08:46 AM

[!--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) View Post[/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:

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

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.
"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!

#4 Iryk

Iryk
  • Members
  • PipPip
  • Member
  • 25 posts

Posted 16 April 2006 - 04:27 PM

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.

#5 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 18 April 2006 - 08:59 AM

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
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users