Jump to content


Photo

Can this be done?


  • Please log in to reply
7 replies to this topic

#1 R1der

R1der
  • Members
  • PipPipPip
  • Advanced Member
  • 104 posts

Posted 11 October 2006 - 11:09 AM

ok this is hard to explain

I just made a game for my users. Basicly thay click alot of numbered links.

i.e
<a href="#t=1&s=0#">0</a><a href="#t=1&s=1#">1</a><a href="#t=1&s=2#">1</a>

Ok so i got a rand statement

<?
$rand = rand(1,100);
if($rand==1 || $rand==20 || $rand==25 || $rand==56 || $rand==72 || $rand==100) {

echo "Wow you found a needle. Keep looking and see if you can find more. Remember the more needles you find the better the chance of winning.";

$db->query("UPDATE users SET uNeedle=uNeedle+'1' WHERE uID='" . $user['uID'] . "'");
}		
?>

ok now what i want it to do if the user gets the random number that echos "Wow you found a needle. Keep looking and see if you can find more. Remember the more needles you find the better the chance of winning." i want it to redirect them to say needle.php?view How can this be done?


Hope this makes sence :(

Thanks in advance

#2 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 11 October 2006 - 11:14 AM

Use a header redirect after you've updated the database.

<?php
if($rand==1 || $rand==20 || $rand==25 || $rand==56 || $rand==72 || $rand==100) {

echo "Wow you found a needle. Keep looking and see if you can find more. Remember the more needles you find the better the chance of winning.";

$db->query("UPDATE users SET uNeedle=uNeedle+'1' WHERE uID='" . $user['uID'] . "'");

header("Location: needle.php?view");
}
?>

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#3 R1der

R1der
  • Members
  • PipPipPip
  • Advanced Member
  • 104 posts

Posted 11 October 2006 - 11:21 AM

Thanks for your reply. but i tried that one b4 i posted my problem on here.

You see because the page dont refresh or anything when you click the links. it dont do anything really it just goes to say "needle.php#t=1&s=1#" and so on when clickin the links. that it but the page dont refresh

Does this make sence? if not you can goto http://www.hcn-chat.com/needle.php to try this game to see what i mean.

#4 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 11 October 2006 - 11:29 AM

In that case I don't think I've understood what you're after.

As for getting me to try it, that page is riddled with errors.  I'd correct them first:

Warning: main(../includes/inc-header.php): failed to open stream: No such file or directory in /home/fhlinux202/h/hcn-chat.com/user/htdocs/needle.php on line 3

Warning: main(../includes/inc-header.php): failed to open stream: No such file or directory in /home/fhlinux202/h/hcn-chat.com/user/htdocs/needle.php on line 3

Warning: main(../includes/inc-header.php): failed to open stream: No such file or directory in /home/fhlinux202/h/hcn-chat.com/user/htdocs/needle.php on line 3

Warning: main(): Failed opening '../includes/inc-header.php' for inclusion (include_path='.:/usr/share/pear') in /home/fhlinux202/h/hcn-chat.com/user/htdocs/needle.php on line 3


Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#5 R1der

R1der
  • Members
  • PipPipPip
  • Advanced Member
  • 104 posts

Posted 11 October 2006 - 11:33 AM

Thats just a copy of the game. that isnt the main game the error is just because i dragged it there so you didn't have to signup to my game if ya wanna see it without the errors you can signup to my game you can goto www.hcn-chat.com/game

Sorry about this.

#6 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 11 October 2006 - 11:42 AM

OK, let me see if I've got this correct...

The page loads, you click links on the page, this is meant to generate a random number using php and check if the random number is one of the needles.  If it is, it adds one to their total in the database and then redirects them to needle.php?view

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#7 R1der

R1der
  • Members
  • PipPipPip
  • Advanced Member
  • 104 posts

Posted 11 October 2006 - 11:44 AM

yes. well thats how i wanted it to work lol

#8 R1der

R1der
  • Members
  • PipPipPip
  • Advanced Member
  • 104 posts

Posted 11 October 2006 - 12:08 PM

Ok thanks for your reply huggie. i have now solved the problem. i just changed the links to goto somewhere else. like needles.php?stp=1 and so on. damnit was so simple. sorry to have wasted your time




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users