mario Posted April 2, 2008 Share Posted April 2, 2008 <?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 More sharing options...
discomatt Posted April 2, 2008 Share Posted April 2, 2008 Try echo'ing $lol12. You may want to convert the mysql result to an array or a string Look up mysql_fetch_assoc or mysql_result Link to comment https://forums.phpfreaks.com/topic/99256-limit-page-viewsif-problem/#findComment-507855 Share on other sites More sharing options...
Daniel0 Posted April 2, 2008 Share Posted April 2, 2008 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. Link to comment https://forums.phpfreaks.com/topic/99256-limit-page-viewsif-problem/#findComment-507858 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.