Jump to content
MakeWebGames

Need Help


DAngelo

Recommended Posts

I am working on a rodeo mod. For some reason this is not working right. I can not see the problem. 1 of two things is happening. Either it is not passing the id to function join or function join is not working properly. Db's are not getting updated. I have tried a couple different ways as you will see the commented code. Any help would be greatly appreciated!

 

<?php 
require "globals.php";

/* switch($_REQUEST['action']) 
{
 case 'join': join(); break;
 default: rodeo_index(); break;
}

function rodeo_index()
{*/
global $ir, $db, $userid;
if($ir['jail']>0 || $ir['hospital']>0)
{
die("<center>You can not move around right now.</center>");
}
if(!$_GET['join'])
{

print "<center>Welcome to the Rodeo. There are a few different events that you can join. You can only join one event per week!
The events will run at 8pm game time every Saturday night. The events will pay out tour points for 1, 2, 3 places each week for each event.
At the end of the month there will be a championship event where the top 3 tour point holders will compete for the Championship and a substantial prize.
</center><br><br>";
print "<center>Would you like to join an event?</center>
<center><table BORDER=2 CELLPADDING=2 CELLSPACING=2> <tr><td>

<a href='rodeo.php?action=join&id=1'>Join Saddle Bronc Event.</a>
</td>
<td>
<a href='rodeo.php?action=join&id=2'>Join Bare Back Event</a>
</td></tr>
<tr><td>
<a href='rodeo.php?action=join&id=3'>Join Steer Wrestling Event</a>
</td>
<td>
<a href='rodeo.php?action=join&id=4'>Join Bull Riding Event</a>
</td>

</tr>
</table></center>";

//show joined users
/*$view=$db->query("SELECT username FROM saddle_bronc");
$view1=$db->query("SELECT username FROM bare_back");
$view2=$db->query("SELECT username FROM steer_wrestling");
$view3=$db->query("SELECT username FROM bull_riding");
print "<center><h3>Registered Contestants</h3></center><br><br>";
print "<center><table width =75%><tr><td><b>Saddle Bronc</b></td><td><b>Bare Back</b></td><td><b>Steer Wrestling</b></td><td><b>Bull Riding</b></td></tr>";

while ($display = $db->fetch_row($view))
  {
	print "<tr><td>".$display['username']."</td>";
	while($display1 = $db->fetch_row($view1))
	   {
			print "<td>".$display1['username']."</td>";
			while($display2 = $db->fetch_row($view2))
			   {
					print "<td>".$display2['username']."</td>";
					while($display3 = $db->fetch_row($view3))
						{
							print "<td>".$display3['username']."</td></tr></table></center>";
						}
				}
		}
}
}*/
}
//update DB's after join
if(!function_exists('join'))
{
function join()
{
   global $ir, $db, $userid;
$id=abs((int) $_GET['id']);
If ($ir['rodeo'] > 0)
{
	Die ("You have already entered an event this week!");
}
else
{
Switch($id) 
{
	case '1' :
		$db->query("INSERT INTO saddle_bronc VALUES ('', $userid, ".$ir['username'].", 0)");
		$db->query("UPDATE users SET rodeo = 1 WHERE userid = $userid");
		Break;

	case '2' :
		$db->query("INSERT INTO bare_back VALUES ('', $userid, ".$ir['username'].", 0)");
		$db->query("UPDATE users SET rodeo = 1 WHERE userid = $userid");
		break;

	case '3' :
		$db->query("INSERT INTO steer_wrestling VALUES ('', $userid, ".$ir['username'].", 0)");
		$db->query("UPDATE users SET rodeo = 1 WHERE userid = $userid");
		break;

	case '4' :
		$db->query("INSERT INTO bull_riding VALUES ('', $userid, ".$ir['username'].", 0)");
		$db->query("UPDATE users SET rodeo = 1 WHERE userid = $userid");
		break;
	}	
}
}
}
$h->endpage();
exit;

?>
Link to comment
Share on other sites

Try these things;

 

  1. Remove the capital 'i' in If (Line 75)
  2. Running the queries in phpmyadmin, to see if an error is thrown
  3. Try not having an if else in join(), and use a default: 'You have already entered a rodeo this week'; break;
  4. Report back with any issues that occur after doing 1, 2 and 3.
Link to comment
Share on other sites

I would suggest you start from scratch and write the code again.

There is no way you should be using code that does this

while ($display = $db->fetch_row($view))

{

print "<tr><td>".$display['username']."</td>";

while($display1 = $db->fetch_row($view1))

{

print "<td>".$display1['username']."</td>";

while($display2 = $db->fetch_row($view2))

{

print "<td>".$display2['username']."</td>";

while($display3 = $db->fetch_row($view3))

{

print "<td>".$display3['username']."</td></tr></table></center>";

}

}

}

}

}

Link to comment
Share on other sites

I agree there is probably a much better way to do it but seeing as I am new to php and that works. I used it. However, I am open to suggestions if more experience coders like yourself would give me some insight as to how it could be better done instead of just saying redo it.

Link to comment
Share on other sites

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.   Paste as plain text instead

  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...