Jump to content

Roy766

Members
  • Posts

    28
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Roy766's Achievements

Member

Member (2/5)

0

Reputation

  1. No need for edits or deletions. If it becomes absolutely necessary I can manually edit the data, but it shouldn't be for the purpose of the site (only one person will be adding content, and he'll be copying the content from a document previously proofread and edited because he'll be printing it out as well as uploading it). In addition, there's no need to store very much content in the "new" table; any row after the most recent twenty can be automatically cleared. It's simple but efficient and works perfectly for the system I need.
  2. Figured out a work around; add each new post to the table "new" and limit the number of rows displayed on the "New" page. Doesn't work by date but the "most recent X rows" method actually makes more sense.
  3. Hello all! I have a database with six different tables in it ("word", "idea", etc.). Each table has a timestamp column and what I want to do is have a page that lists all the rows entered within a certain time frame (a "New" page). In order to do this, though, I would have to query all six tables and then echo the rows created within a certain time frame. Is this possible? Thanks in advance! Also, if anyone has a suggestion on how to return all rows from a certain date onwards, that would be appreciated too.
  4. Hi all! Sorry if this is in the wrong section, but I'm not really sure if this would relate to PHP, CSS, JS, or just basic HTML. Just one basic question: I want to have a sort of background image, and then put smaller images on top of it. Think of it sort of like a game: where I have a map and some sprites on top of them. Sorry for the really stupid question, but I really have no idea how to do this :-\
  5. Hi, all! I'm not to good with PHP and I was wondering if anyone could help. I have a simple text box and a submit button. I want a little series of text underneath that text box that echoes every word (separated by a space), on its individual line. For example, if a user types in "I am awesome" in the box and presses the button, the output would read: I Am Awesome Anybody have any suggestions? Thanks in advance!
  6. Putting it before an HTML Tag? Then it just comes out as plain text. Putting it after the PHP tag without a line break? That's what I did. Not putting code before it? Also what I did. ??? Please expand. I'm a bit slow with this.
  7. Hi everybody! I'm somewhat new to sessions, so this question may seem really stupid to all of you PHP gods. Anyways, I'm trying to send a basic PHP variable between two pages through the use of sessions, and then I do some basic computations on the second page. The math I get on the second page is right, but I get these annoying error messages at the top of the page: First page: Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/www/roy766.freehostia.com/armygame.php:6) in /home/www/roy766.freehostia.com/armygame.php on line 8 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/www/roy766.freehostia.com/armygame.php:6) in /home/www/roy766.freehostia.com/armygame.php on line 8 Second page: Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/www/roy766.freehostia.com/armygame2.php:6) in /home/www/roy766.freehostia.com/armygame2.php on line 7 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/www/roy766.freehostia.com/armygame2.php:6) in /home/www/roy766.freehostia.com/armygame2.php on line 7 If someone could help it would be greatly appreciated! Thanks in advance! Side-note: session_register(); session_start(); $_SESSION['budget'] = $budget; session_start(); $budget = $_SESSION['budget'];
  8. Well, I decided to try and write a simple script to measure how bad I am at MySQL. Apparently, very bad. My idea is simple: You type text into a textbox, it redirects you to a different page, at which the data is sent to the database, and then all of the data is echoed on the main page. Problem is, it doesn't work, and I'm not experienced enough to determine why. All I get when I try to echo is "resource id #2". Here's my code: Main page (forum.php) <html> <head> <title>Forum thingy....</title> </head> <body> <?php mysql_connect("mysql4.freehostia.com", "*******", "******") or die(mysql_error()); mysql_select_db("aiddre_db") or die(mysql_error()); $result = mysql_query("SELECT * FROM royforum_list"); while($row = mysql_fetch_assoc($result)){ echo $result; } ?> <form name="submitcomment" method="post" action="submitcomment.php"> <input type="text" name="commentval"> <input type="submit" value="Submit"> </body> </html> Redirected page (submitcomment.php): <?php mysql_connect("mysql4.freehostia.com", "aiddre_db", "mioki766") or die(mysql_error()); mysql_select_db("aiddre_db") or die(mysql_error()); $commentvalue = $_POST['commentval']; $sql = "INSERT INTO royforum_list (comment) VALUES ('$commentvalue')"; $result = mysql_query($sql); echo "Comment posted. Please <a href='forum.php'>return to the forum-ish thing.</a>" ?> Any suggestions?
  9. I'm sorry if I have to use some other language. If so, could a mod please move this? Anyways, I've got a couple of text boxes on my page, and I want it so that there's another text box that automatically updates when one of the other text boxes changes. Any suggestions on how to do this?
  10. Again with this game, I know. I'm trying to make a text box that automatically updates based on the values of the other text boxes. Problem is, it comes up blank :'( Here's what I've got: <html> <head> <title>Combat Game</title> </head> <body> <script language="VBScript"> Sub TotalCosts TotalCost.Value = 200 - swordfootmen.Value - lancefootmen.Value - mountedswordsmen.Value - mountedlancemen.Value - bowmen.Value - horses.Value - catapaults.Value; End Sub </script> You may spend up to 150 gold. For unit prices and stength, consult <a href=unitstuff.php>this graph.</a> <form> Sword-wielding footmen:<input type="text" name="swordfootmen" onChange="TotalCosts"><br> Lance-wielding footmen:<input type="text" name="lancefootmen" onChange="TotalCosts"><br> Mounted sword wielders:<input type="text" name="mountedswordsmen" onChange="TotalCosts"><br> Mounted lance wielders:<input type="text" name="mountedlancemen" onChange="TotalCosts"><br> Bow-wielding footmen:<input type="text" name="bowmen" onChange="TotalCosts"><br> Horses:<input type="text" name="horses" onChange="TotalCosts"><br> Catapults:<input type="text" name="catapults" onChange="TotalCosts"><br> <input type="submit" value="Attack!"><br> <br> <br> Total money left: <input type="text" name="TotalCost" ReadOnly="True"> </form> <?php $sfcost = $_REQUEST['swordfootmen'] * 3; $lfcost = $_REQUEST['lancefootmen'] * 3; $mswcost = $_REQUEST['mountedswordsmen'] * 5; $mlwcost = $_REQUEST['mountedlancemen'] * 5; $bcost = $_REQUEST['bowmen'] * 2; $hcost = $_REQUEST['horses']; $ccost = $_REQUEST['catapults'] * 12; $totalcost = $sfcost + $lfcost + $mswcost + $mlwcost + $hcost + $bcost + $ccost; $sfatk = $_REQUEST['swordfootmen'] * rand(1, 5); $lfatk = $_REQUEST['lancefootment'] * rand(2, 4); $mswatk = $_REQUEST['mountedswordsmen'] * rand(3, 5); $mlwatk = $_REQUEST['mountedlancemen'] * rand(3, 4); $hatk = $_REQUEST['horses']; $batk = $_REQUEST['bowmen'] * rand(1, 4); $catk = $_REQUEST['catapults'] * rand(6, 10); $totalatk = $sfatk + $lfatk + $mswatk + $mlwatk + $batk + $hatk + $catk; $compatk = rand(10, 200); if ( $totalcost > 200 ) { echo "You spent too much money! <br />"; } else { echo "Your total attack force is " . $totalatk . "<br />"; echo 'The computers total attack force is ' . $compatk . "<br />"; if ( $compatk > $totalatk ) { echo 'Sorry, the computer wins...'; } else { echo 'You win! Congratulations!'; } } ?> <br> <br> </body> </html>
  11. How could I make it so that the browser checks for a whole number from a textbox? So that if the user types in 13.99 into a textbox, it echoes 'Please enter a whole number!', or something along those lines?
  12. Do you mean to put that in an echo...? Or just throw it in the code? Cuz either way it still doesn't seem to work...
  13. Let me give an example with my previously corrected script: <?php $sfcost = $_REQUEST['swordfootmen'] * 3; $lfcost = $_REQUEST['lancefootmen'] * 3; $mswcost = $_REQUEST['mountedswordsmen'] * 5; $mlwcost = $_REQUEST['mountedlancemen'] * 5; $hcost = $_REQUEST['horses']; $totalcost = $sfcost + $lfcost + $mswcost + $mlwcost; $sfatk = $_REQUEST['swordfootmen'] * 2; $lfatk = $_REQUEST['lancefootment'] * 2; $mswatk = $_REQUEST['mountedswordsmen'] * 4; $mlwatk = $_REQUEST['mountedlancemen'] * 4; $hatk = $_REQUEST['horses']; $totalatk = $sfatk + $lfatk + $mswatk + $mlwatk + $hatk; $compatk = rand(10, 150); if ( $totalatk > 150 ) { echo "You spent too much money!"; } else { echo "Your total attack force is " . $totalatk; } echo 'The computers total attack force is ' . $compatk; if ( $compatk > $totalatk ) { echo 'Sorry, the computer wins...'; } else { echo 'You win! Congratulations!'; } ?> (Don't try just executing that. Requires the HTML to function...) When you win, you get: Exactly like that. All on one line. I'd like it with some line breaks inbetween there.
  14. I'm trying to make a line break in my php echoes...and it's not working... All my google and yahoo searches are telling me to use echo '\n'; ...but that just puts "\n" between the lines... Help!
  15. When I finished editing my post, you had replied with the error I found. One of the problems of having a large forum :-\
×
×
  • 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.