Jump to content

Recommended Posts

	<?php

$query12 = "SELECT randompoints FROM users WHERE username = '$username'";
$lol12 = mysql_query($query12);
$part2[] = "112";
$part2[] = "235";
$part2[] = "632";
$part2[] = "532";
$part2[] = "723";
$part2[] = "662";
$part2[] = "236";
$part2[] = "3262";
$part2[] = "236";
$part2[] = "263";
$part2[] = "328";
$part2[] = "643";
$part2[] = "854";
$part2[] = "125";
$part2[] = "834";
$part2[] = "974";
$part2[] = "473";
$part2[] = "172";
$part2[] = "843";
$part2[] = "634";
$part2[] = "5000";
$part2[] = "281";
$username = $session->username;

srand ((double) microtime() * 1000000);

$part2output = rand(0,count($part2)-1);

if($lol12 < '10' ){
echo "<p>$username wins <b>" . $part2[$part2output] . "</b> gold bits.</p><br><br><br>";
$outcome = $part2[$part2output];
$sql = "UPDATE users SET goldbits = goldbits+'$outcome' WHERE username = '$username'";
mysql_query($sql);
$lol = "UPDATE users SET randompoints = randompoints+1 WHERE username = '$username'";
mysql_query($lol);
}
else {
echo "You've played too much ";
}
?>

 

I know it could be neater with some built in functions, but that's how I wanted to do it.

But when I run it as it is now, it won't let you play at all.

It keeps saying I've played too much.

Is there a simplerer way to do to this? -not sure-

I just want to limit their page views to 10, before they can stop playing.

Link to comment
https://forums.phpfreaks.com/topic/99256-limit-page-viewsif-problem/
Share on other sites

mysql_query() returns a resource. You'll need to use one of the mysql_fetch_*() functions to actually get the results of the query. Also (and this is not related to the problem), in the $lol12 < '10' part you should use an integer and not a string. It would work in the same way seeing as PHP converts it for you, but it's more correct to just use an integer.

This thread is more than a year old. Please don't revive it unless you have something important to add.

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

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.