SoireeExtreme Posted February 9, 2007 Share Posted February 9, 2007 I've created an attack script for a game. Players attack Creatures it reads out who won/lose or if the battle is a draw, and its suppose to update certain things in the database such as gold/credits number of turns and such. Well everything works find except 1 part in the updating process. I have the script go into the database and get info on how many credits/gold a creature is worth if the player wins. Now that it does that except it doesn't update the database for the player with a new number of credits/gold. $update1=$creature3['credits']/1; if($atk1>$atk2) { echo "<center>You Won! You gained: $update1 Gold,<br>"; $skill="update ac_users set credits=credits+'update1', numturns=numturns-'0' where playername='$player'"; mysql_query($skill); Now thats the code. Could anyone point out what I've done wrong of help fix this issue? update1 is how many credits the creature is worth and if you look at the skill query where it says update1 it doesn't do that. Any help would be great appreciated. Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/37805-solved-not-updating-database/ Share on other sites More sharing options...
Balmung-San Posted February 9, 2007 Share Posted February 9, 2007 1. update1 should be $update1 2. If you're ever having a SQL query error, change your query from mysql_query(); to mysql_query() or die(mysql_error()); That will give you plenty of error information. Link to comment https://forums.phpfreaks.com/topic/37805-solved-not-updating-database/#findComment-180870 Share on other sites More sharing options...
sspoke Posted February 9, 2007 Share Posted February 9, 2007 credits=credits+'update1' quotes are for strings not values Link to comment https://forums.phpfreaks.com/topic/37805-solved-not-updating-database/#findComment-180872 Share on other sites More sharing options...
SoireeExtreme Posted February 9, 2007 Author Share Posted February 9, 2007 Durrr oh my. I can't believe I missed that thank you for pointing such a small error out to me. Staring a coding look enough and you miss these things. A fresh part of eyes is always helpful. Thakn you again Link to comment https://forums.phpfreaks.com/topic/37805-solved-not-updating-database/#findComment-180874 Share on other sites More sharing options...
Balmung-San Posted February 9, 2007 Share Posted February 9, 2007 Durrr oh my. I can't believe I missed that thank you for pointing such a small error out to me. Staring a coding look enough and you miss these things. A fresh part of eyes is always helpful. Thakn you again Don't forget the mysql_error() thing. It's very useful when you have problems with your MySQL statements, however don't forget to take it out before you go live with it. Link to comment https://forums.phpfreaks.com/topic/37805-solved-not-updating-database/#findComment-180876 Share on other sites More sharing options...
SoireeExtreme Posted February 9, 2007 Author Share Posted February 9, 2007 Yeah I was told to use that in the past, but forgot about it. So thanks for the tip. Link to comment https://forums.phpfreaks.com/topic/37805-solved-not-updating-database/#findComment-180964 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.