Jump to content

Kryllster

Members
  • Posts

    186
  • Joined

  • Last visited

Everything posted by Kryllster

  1. Ok thanks for replying! Here is the code; <?php // initialize outcome of fight and loot chances $outcome = mt_rand(1,100); $level_advance = 2; $gold = mt_rand(1000,4000); $diamonds = mt_rand(3,; $rubies = mt_rand(3,7); // My Fight and loot generator $smarty->assign('gold',$gold); $smarty->assign('rubies',$rubies); $smarty->assign('diamonds',$diamonds); // First the fight if($outcome < 70){ // Connect to database include('includes/config.php'); include('includes/advance_level.php'); // Update database $sql="UPDATE $tbl_name SET onhand = onhand + $gold, diamond = diamond + $diamonds, rubie = rubie + $rubies, advance = advance + $level_advance WHERE uname='$uname'"; mysql_query($sql) or die (mysql_error()."<p>$sql</p>"); $smarty->display('fight_success.tpl'); } else{ $smarty->display('fight_failure.tpl'); } ?> When the link that leads to this it goes thru an index contoller and executes the depending on the out come of course diplays the values like I wanted to, but all the person has to do is hit their back button on over and over wash rinse and repeat. I am learninf alot but this has me stymied. I was trying to do it where it runs the script then exits and directs it to the right page the first version worked better however I could not get the the variable output to the template??
  2. Is there a way for me to prevent someone from hitting their back button and running a script over and over and over again?? Thanks In advance?
  3. Oky doke thanks alot for ur help do I put topic solved or what? Kryll
  4. Your code works too? Can you tell me about some of the if statement like what kind of pipes are this and anything for pointers?? I am trying to write out stuff but I had been copying and pasting alot. Anyways thanks,
  5. <?php session_start(); $uname = $_SESSION['uname']; // Define Form Variables $take_gold = 0 + $_POST['take_gold']; $take_diamond = 0 + $_POST['take_diamond']; $take_rubie = 0 + $_POST['take_rubie']; // Connect and Select data from database include ('includes/config.php'); $sql="SELECT * FROM $tbl_name WHERE uname='$uname'"; $result=mysql_query($sql); // Put info into array while($row=mysql_fetch_assoc($result)) { // Assign Variable to array element after the array is created. $bank = $row['bank']; $dbalance = $row['dbalance']; $rbalance = $row['rbalance']; // Test the money if($take_gold > $bank){ echo "Your not Allowed to do that!! STOP Hit your browser back button please."; } elseif($take_diamond > $dbalance){ echo "Your not Allowed to do that!! STOP Hit your browser back button please."; } elseif($take_rubie > $rbalance){ echo "Your not Allowed to do that!! STOP Hit your browser back button please."; } else{ $sql="UPDATE $tbl_name SET bank = bank - $take_gold , onhand = onhand + $take_gold , dbalance = dbalance - $take_diamond , diamond = diamond + $take_diamond , rbalance = rbalance - $take_rubie , rubie = rubie + $take_rubie WHERE uname='$uname'"; mysql_query($sql) or die (mysql_error()."<p>$sql</p>"); echo "<META HTTP-EQUIV=\"Refresh\"CONTENT=\"0; URL=mainview.php?diamond=account\">"; } } ?> I have executed this code around 10 times on all 3 of the withdrawals with high and low numbers and it worked great? I see the code u wrote I am going to give it a try? I just still dont know what Im doing really but I go so fast in my head I cant slow down I think thats some of my problem.
  6. Ok just copied and pasted logged on it worked good when I tried to take more out than was in there then I tried to take like 60 or so and this is what I got as an error code. Now im flustered stilll lol but I will learn what is wrong I hope.
  7. Thanks for the reply I am checking out here in a moment and the extra code I thought needed to be removed as well just wasn't sure if it would hurt or not thanks for cleaning for me too.
  8. <?php session_start(); $_SESSION['uname'] == $uname; $uname = $_SESSION['uname']; // Define Form Variables $take_gold = 0 + $_POST['take_gold']; $take_diamond = 0 + $_POST['take_diamond']; $take_rubie = 0 + $_POST['take_rubie']; // Connect and Select data from database include ('includes/config.php'); $sql="SELECT * FROM $tbl_name WHERE uname='$uname'"; $result=mysql_query($sql); // Put info into array while($row=mysql_fetch_assoc($result)) { // Assign Variable to array element after the array is created. $bank = $row['bank']; $dbalance = $row['dbalance']; $rbalance = $row['rbalance']; // Test the money if($take_gold > $bank){ echo "Your not Allowed to do that!! STOP Hit your browser back button please."; } if($take_diamond > $dbalance){ echo "Your not Allowed to do that!! STOP Hit your browser back button please."; } if($take_rubie > $rbalance){ echo "Your not Allowed to do that!! STOP Hit your browser back button please."; } else{ $sql="UPDATE $tbl_name SET bank = bank - $take_gold , onhand = onhand + $take_gold , dbalance = dbalance - $take_diamond , diamond = diamond + $take_diamond , rbalance = rbalance - $take_rubie , rubie = rubie + $take_rubie WHERE uname='$uname'"; mysql_query($sql) or die (mysql_error()."<p>$sql</p>"); echo "<META HTTP-EQUIV=\"Refresh\"CONTENT=\"0; URL=mainview.php?diamond=account\">"; } } ?> I am using Smarty template engine as well I have wracked my brains and been to the php.net site and countless others?? What gives?? Need some help here. Players who play this game can take out millions and more leave a negative balance I want to prevent this?? Is there a way to do it that Im not getting?? Thanks in Advance, Kryll ???
  9. Ahh man is ok I was just looking at that page lol ha if I would just be patient I knew I would find something eventually. Was just being lazy my bad. Thanks again You were helpful.
  10. Sorry didnt mean to make any trouble thanks for the quick reply.
  11. Does anyone know a good place for free php hosting as well as being able to use Smarty and have the ability to use .zip file or something similar like 7-zip? I cant find any decent ones that permit these?? Thanks,
  12. Ok I know Im a real noob but I have seen things like what you are talking about (I think). Their solution is to use cron jobs to update info for their pages?? I have used this with a linux setup as well as windows when I set up a game called Alien Assault Traders. Just a thought! Thanks,
  13. Thank's for the quick reply the topic is solved here is the resulting code: <?php $uname = $_POST['uname']; $address = $_POST['addy']; // set path of database file $db = $_SERVER['DOCUMENT_ROOT']."/../email.db"; // open database file $handle = sqlite_open($db) or die("Could not open database"); sqlite_query($handle, "INSERT INTO list (name, address) Values ('$uname', '$address')"); sqlite_close($handle); ?> Thatl do Thatl do! Thanks again!
  14. I am using a basic setup of Apache 2 (the latest) and php (also the latest) that I have installed and configured. my ohoh info came back ok and I ran 1 test svript and retrieved data from an sqlite db. My pronlem is I want to learn the Sqlite db and Im having a hard time trying to connect and add info from a form into the db. Here is the error I get from my php script Warning: sqlite_query() expects at least 2 parameters, 1 given in C:\mywebs\htdocs I have pasted that into google without getting any usable results. I have checked the Sqlite home page but they are mostly about Sqlitr3 and that is pdo which I dont understand yet. I have checked the php home site and nothing I can use from there. So I tried to use some of the code from Mysql here is the code I used: <?php $uname = $_POST['uname']; $address = $_POST['addy']; // set path of database file $db = $_SERVER['DOCUMENT_ROOT']."/../email.db"; // open database file $handle = sqlite_open($db) or die("Could not open database"); sqlite_query("INSERT INTO list (name, address) Values ($uname, $address)"); sqlite_close($handle); ?> I have also done a search from this forum with just the search term Sqlite with only 1 result. Is there anyone who knows how I can use sqlite or is it better to stick with Mysql. Personally I like the idea of less is more but. Thanks,
  15. Thanks for checking it out for me. I am looking into the fix for that. I'm not sure where to look but I will find it.
  16. Sorry about that I had a problem last night and needed to move my stuff here at the house here is the url. I checked it. so it should work. http://homeforge.homeip.net/~terry/cbchat/ Sorry bout that!! Kryllster
  17. You were right it was used as part of a .php script i was including from another page. I elimiated the script and now I no longer get the error. Thank's I imagine that comes from bad code but will check on it more I think after I read that book!!
  18. <?php //Include page header include('includes/header.php'); include('includes/navigate.php'); //Get the page variable $page = $_GET['dune']; //Our switch statement to get the right content switch($page) { case "home": //For each page of content just add a case block $content = "includes/home.php"; //The file with the page contents. DO not include the header and footer HTML in these files it is already added. break; //Stop the case block, if you do not have this you will get an error. case "home": $content = "includes/home.php"; break; case "about": $content = "includes/about.php"; break; case "quotes": $content = "includes/quotes.php"; break; case "graphics": $content = "includes/graphics.php"; break; case "protocol": $content = "includes/protocol.php"; break; default: //If the variable didn't match any of the above cases do this. $content = "includes/home.php"; break; } //Include the selected content. include($content); //Include page footer include('includes/footer.php'); ?> Is this javascript?? Just wondering?? This is the code im using
  19. I have made a chat script using frames, and used to have a problem with refresh until I set up a few other details for my little script. I dont use an I frame yet I will be working towards that soon. Here is my script comment and suggestions welcome and appreciated!! http://crimson.awardspace.com/cbchat/ Thanks,
  20. I have recently been working with smarty and learning some new stuff like switch and _GET. The problem is when I go to validate my pages I get this error: Deprecated method document.getSelection() called. Please use window.getSelection() instead. Is this a concern to anyone or is it just a bunch of bunk and if not how do I fix it? I cant find anything on google about the second one. Except that people are reporting it but no solution? Thoughts, solutions?? Thanks in advance,
  21. I just tested it it works fine now Im not sure what the problem is/was but I'm good for now!!
  22. Well I had problems all night with my system so I have a linux server up now just haven't tested it yet. The Way I see it most of the web is Apache nowadays (at least I think so) that this would be better. I got tired of messin with the windows and really the only reason I still am using windows is cause of games. Thanks for all the help.
  23. Yeah It's in config but you know I have always had problems with e>novative>wamp I installed it cause it was quicker but what I need is some sort of wamp that is a little more flexible I think anyways??? And I would like to eventually write code from scratch myself any good or should I say great beginners sites or docs or tutes i could get pointed to would help as well!! Thanks for all the help btw,
  24. Ok just a blank page, well I used Smarty a little when I was working on a project for another person and was really just learning but I got sick and wasnt available for a few months so I never took it any further. Im just wondering why it woks on 1 server and not the other. I do use the CPED method Copy, Paste, Edit or Delete. Lol but I am learning as I go.
  25. Ok here is the first original code that worked with WAMP5 (please don't laugh) oh another thing is I am using frames if that would have anything to do with it?? <?php session_start(); $_SESSION['uname'] == $uname; include ('config.php'); $uname = $_SESSION['uname']; // Select data from database $sql="SELECT * FROM $tbl_name WHERE uname='$uname'"; $result=mysql_query($sql); // Put info into array Hopefully while($row=mysql_fetch_assoc($result)) { echo "<html>"; echo "<head>"; echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"gamestyle.css\" />"; echo "</head>"; echo "<body>"; echo "<center>"; echo $uname; echo "<br>"; echo "<img src=\"images/Gallery/Elf.jpg\" align=\"center\">"; echo "</center>"; echo "<br>"; echo "<img src=\"images/staff.gif\" align=\"center\">"; echo "<br>"; echo "<font color=\"#b22222\">Character Info</font>"; echo "<br>"; echo "<img src=\"images/staff.gif\" align=\"center\">"; echo "<br>"; echo "<small>"; echo "Race: "; echo "<font color=\"#b22222\">"; echo $row['race']; echo "</font>"; echo "<br>"; echo "Class: "; echo "<font color=\"#b22222\">"; echo $row['fclass']; echo "</font>"; echo "<br>"; echo "Level: "; echo "<font color=\"#b22222\">"; echo $row['levl']; echo "</font>"; echo "<br>"; echo "Hit Points: "; echo "<font color=\"#b22222\">"; echo $row['hitp']; echo "</font>"; echo "<br>"; echo "<img src=\"images/staff.gif\" align=\"center\">"; echo "<br>"; echo "</small>"; echo "<font color=\"#b22222\">Inventory</font><br>"; echo "<img src=\"images/staff.gif\" align=\"center\">"; echo "<br>"; echo "<small>"; echo "Armor: "; echo "<font color=\"#b22222\">"; echo $row['armor']; echo "</font>"; echo "<br>"; echo "Weapon: "; echo "<font color=\"#b22222\">"; echo $row['weapon']; echo "</font>"; echo "<br>"; echo "Gold Onhand: "; echo "<font color=\"#b22222\">"; echo $row['onhand']; echo "</font>"; echo "<br>"; echo "Diamonds: "; echo "<font color=\"#b22222\">"; echo $row['diamond']; echo "</font>"; echo "<br>"; echo "Rubies: "; echo "<font color=\"#b22222\">"; echo $row['rubie']; echo "</font>"; echo "<br>"; echo "<img src=\"images/staff.gif\" align=\"center\"><br>"; echo "<a href=\"chat/cdchat.php#bottom\" target=\"_blank\">[ Crimson Chat ]</a><br>"; echo "</small>"; echo "</body>"; echo "</html>"; } ?>
×
×
  • 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.