Jump to content


Photo

saving to Mysql database


  • Please log in to reply
2 replies to this topic

#1 grlayouts

grlayouts
  • Members
  • PipPipPip
  • Advanced Member
  • 342 posts

Posted 15 September 2006 - 09:59 PM

ok i have a game where when people go to make a gang it should update in to places, but when i try to get the gang name to update in the players tab it doesnt work..This is what i have?

if ($step == make) {
		if ($stat[taxdebt] > 0) {
		print "<br><font color=red>You cannot make a Gang without <b>paying</b> your taxes. Sorry!</font><br>Right now you owe <b>$stat[taxdebt]</b>!";
		include("footer.php");
		exit;
	}
	if ($stat[credits] < 10000) {
		print "You don't have enough credits to make a gang.";
		quit();
	}
	if ($stat[triad]) {
		print "You're already in a gang. Try quitting the one your in first.";
		quit();
	}
	print "<form method=post action=zones.php?step=make&action=go>";
	print "I want my gang to be called <input type=text name=tname>. <input type=submit value=Make>";
	print "</form>";
	if ($action == go) {
		$numt = mysql_num_rows(mysql_query("select * from triads where name='$tname'"));
		if ($numt > 0) {
			print "There is already a gang by that name.";
			quit();
		}
		print "You have made the gang called <a href=zones.php?step=my>[$tname]</a>.";
		mysql_query("insert into triads (name,owner) values('$tname',$stat[id])");
		$myt = mysql_fetch_array(mysql_query("select * from triads where name='$tname'"));
		$geting = mysql_query("SELECT * FROM players WHERE where id='$stat[id]");
		$getto = mysql_result($getting);
		mysql_query("update players set triad=$myt[id] where id=$stat[id]");
		mysql_query("update players set zone1=$myt[name] where id=$getting[id]");
		mysql_query("update players set credits=credits-10000 where id=$stat[id]");


#2 grlayouts

grlayouts
  • Members
  • PipPipPip
  • Advanced Member
  • 342 posts

Posted 16 September 2006 - 08:59 AM

no one??

#3 SDraconis

SDraconis
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 16 September 2006 - 11:13 PM

Just off the top of my head I want to ask what exactly you mean by "it doesn't work".  Do you mean the table isn't being updated?

Couple debugging tips:
1.) Print your queiries out so you can see what is being sent to your DB
2.) Make sure all the mysql_query calls that do updates return TRUE. If not, make use of the mysql_error function.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users