marklarah Posted April 2, 2008 Share Posted April 2, 2008 Sounds n00bish but wait... So im making a slot machine for some forums, with its online currency, and they win according to the outcome. I programmed it in javascript (i know no javascript whatsoever, but its almost the same as php save a few things, but its easy) Anyway, the rest is in php, and the currency is in a mysql table. The slot machine works fine, as it should. But heres the bit for winning; if (r1 == r2 && r2 == r3) { document.slots.show.value = "JACKPOT!!!! 2000 CHIPS!!! W00T W00T W00T!!!"; alert("JACKPOT!!!! 2000 CHIPS!!! W00T W00T W00T!!!") <? mysql_query("UPDATE users SET chips = chips+2000 WHERE userid = '$useridm'") or die(mysql_error()); ?> window.location = "http://boards.ammostar.net/casino.php?action=slot"; }else if (r1 == r3 && r1 != r2){ document.slots.show.value = "You won 150 chips!"; alert("You won 150 chips!") <? mysql_query("UPDATE users SET chips = chips+150 WHERE userid = '$useridm'") or die(mysql_error()); ?> window.location = "http://boards.ammostar.net/casino.php?action=slot&win="; }else{ document.slots.show.value = "Sorreh, you didn't win anything. Better luck next time "; alert("Sorreh, you didn't win anything. Better luck next time ") window.location = "http://boards.ammostar.net/casino.php?action=slot"; } So guess what? I lost, but gained 2150 chips. Isnt that nice? (becuase php has no way of knowing when to execute/not execute Anyway, my solution would to be on the redirection, use another $_GET and move the mysql updating to the get. That would work, but then how to i make sure people dont just go on that page an give themselfs lots of chips? Is there any other way? Thanks Mark Link to comment https://forums.phpfreaks.com/topic/99289-mysql-execute-help/ Share on other sites More sharing options...
marklarah Posted April 2, 2008 Author Share Posted April 2, 2008 For the record, may i just point out i muuuuch prefer programing in php than javascript. PHP ftw! Link to comment https://forums.phpfreaks.com/topic/99289-mysql-execute-help/#findComment-508000 Share on other sites More sharing options...
marklarah Posted April 3, 2008 Author Share Posted April 3, 2008 so er... Link to comment https://forums.phpfreaks.com/topic/99289-mysql-execute-help/#findComment-508227 Share on other sites More sharing options...
marklarah Posted April 3, 2008 Author Share Posted April 3, 2008 ?? Link to comment https://forums.phpfreaks.com/topic/99289-mysql-execute-help/#findComment-508575 Share on other sites More sharing options...
cooldude832 Posted April 3, 2008 Share Posted April 3, 2008 1 don' bump a board 2) The currency field type is? also you can't execute php after the page loads and your if statements appear to be javascript if/else commands so that php is executing even though its in a javascript if/else because in php's eyes that if/else doesn't exist yet Link to comment https://forums.phpfreaks.com/topic/99289-mysql-execute-help/#findComment-508590 Share on other sites More sharing options...
marklarah Posted April 3, 2008 Author Share Posted April 3, 2008 Yeah it doesnt matter, ive used a work around. For anybody in my situation, use a non-modifyable text box to hold the currency. works like a charm . Link to comment https://forums.phpfreaks.com/topic/99289-mysql-execute-help/#findComment-508700 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.