Jump to content

jcbarr

Members
  • Posts

    219
  • Joined

  • Last visited

Everything posted by jcbarr

  1. No just once, and if the information is correct you set the session variable to a certain value. Then on every subsequent page you check the value of that session variable. If it does not match what you initially set it to then you either kill the script or redirect the user via the header function.
  2. Could an admin possibly move this to the freelance forum? Thanks
  3. If you are checking the session variables on every page then that will fix the problem. If the user does not log in successfully and establish a session then they cannot access the page. There are a ton of good tutorials on the web about this. Basically in every page you need to have session_start() at the top of every page before any other code or lines. Then verfiy the session variables and if they don't match use the die() function to kill the page and display an error message.
  4. I have this array http://cbl-baseball.com/stats.php named $cleanPstats Here is the code that I used to generate it; <?php $stats = file("all_stat.htm"); foreach ($stats as $line){ $line = strip_tags($line); if (trim($line) != "") $newStats[] = $line; } //echo "<pre>"; //print_r($newStats); //echo "</pre>"; foreach ($newStats as $player){ $pstats = explode(" ", $player); foreach ($pstats as $line){ if (trim($line) != "") $cleanPstats[] = trim($line); } } echo "<pre>"; print_r($cleanPstats); echo "</pre>"; ?> Now here comes the tricky part...this might be too much to ask but I'll ask anyway, and if no one has the time for thats okay. That array is huge. It contains season and career stats for each player on every team. The team is listed first, then the season batting, season pitching and then the career batting and career pitching for each player. What I'm looking to do is to somehow figure a way to enter this information in to a database by executing this script while keeping the association between the player and the team and also differentiating season stats from career stats. I would of course have two tables, one for season stats and one for career, or even 4 to separate pitching from batting as well. The problem is that I have no idea how to go about this. There is a lot of useless information in that array that can be taken out. Such as stat names, overall team statistics. I'm only interesting in the 19 batting stats (excluding the 20th and or 21st) and the pitching stats for each player. Any ideas on how to go about this?
  5. That did it Frost, sorry Kerblam, didn't try yours when I found that his worked. Now just to find out how to actually do something with this stuff... I'm hoping to be able to put it in to a database or something, thanks for the help. I'm sure I will be posting here again soon enough, I'm still a noob when it comes to manipulating arrays.
  6. I have a file that I dumped in to an array. I then used strip_tags to remove all the tags from each element. My question is this, how do I get rid of the empy ones? I tried many different methods that I found on php.net and nothing would work, I just kept coming up with the same array over and over again. The code is very basic right now; <?php $stats = file("all_stat.htm"); foreach ($stats as $line){ $newStats[] = strip_tags($line); } echo "<pre>"; print_r($newStats); echo "</pre>"; ?> Click this link to actually see a print of the array http://cbl-baseball.com/stats.php
  7. Here is the deal if anyone cares. Apparently it had to do with my browser settings at home. My browser was apparently not loading the page again it was just using a cached version or something like that. I get to work and the thing works without a hitch, so I guess everything is okay now.
  8. Okay, nevermind. It's back to not working. It worked the first time after I uploaded and now it won't work again...who knows what the hell is going on...
  9. Figured it out, can't submit a form variable with the .txt or whatever, took off the .txt and it works now. Now just to test to make sure it is writing to the file. Thanks for the help guys.
  10. That isn't where the problem lies, the file is opening fine and populating the text area, so I know that the filename is right, when I view source it even shows up in the input tag, but it won't pass it to the script when the form is submitted.
  11. Any ideas why this script isn't picking up the $editdraft variable that is being sent via the form at the bottom of the script? <html> <head> <title>Draft Admin</title> </head> <body><BR><BR><BR><BR><BR> <center> <a href=admin.php?CREATE=Y>CREATE DRAFT FILE</a> <P> <a href=admin.php?EDIT=Y>EDIT DRAFT FILE</a> <P> <?php //Gather Variables $create = $_GET['CREATE']; $edit = $_GET['EDIT']; $make = $_POST['make']; $year = $_POST['year']; $type = $_POST['type']; $draft = $_POST['draft']; $editdraft = $_POST['editdraft']; echo $editdraft; //Create Draft File Form if (!empty($create)){ echo <<<END <b><h2>CREATE DRAFT</h2></b> <form method="post" action="admin.php"> <input type="hidden" name="make" value="Y"> <input type="text" name="year" value="Type Year Here"> <select name="type"><option value="FA">Free Agent</option> <option value="AM">Amateur</option> </select> <input type="submit" value="Create Draft"> </form> END; } //Create TXT File For Draft if ($make=="Y"){ $filename = "$year$type"; $ext = ".txt"; fopen("drafts/$filename$ext", "w+"); echo "$filename has been created. Click <a href=admin.php>here</a> to refresh page."; } //Make Select Edit Form if ($edit=="Y"){ ?> <B><h2>SELECT DRAFT FILE TO EDIT</b></h2> <form name="form1" method="post" action="admin.php"><select name=draft onchange=form1.submit()><option value=''></option> <?php $dir = "drafts"; $dh = opendir($dir); while (false !== ($filename = readdir($dh))) { $files[] = $filename; } sort($files); foreach ($files as $drafts){ if ($drafts !== '.' && $drafts !== '..'){ $drafts = substr($drafts, 0, 6); echo "<option value='$drafts'>$drafts</option>"; } } ?> </select> </form> <?php } //Make Edit Form if (!empty($draft)){ $ext = ".txt"; $filename = "$draft$ext"; $text = file_get_contents("drafts/$filename"); echo <<<END <form name='form2' method='post' action='admin.php'> <input type="hidden" name="editdraft" value="$filename"> <TEXTAREA NAME="edit" ROWS=50 COLS=50>$text</TEXTAREA> <BR> <INPUT TYPE="reset"> <INPUT TYPE="submit" NAME="submit" VALUE="Submit"> </FORM> END; } //Write To Draft File if (!empty($editdraft)){ $handle = fopen("$editdraft", "w+"); fwrite($handle, $edit); fclose($handle); echo "$editdraft has been edited. Click <a href=admin.php>HERE</a> to refresh page."; } ?> </center> </body> </html>
  12. search php.net for scandir() they have several php 4 compliant workarounds listed on the same page. I use one currently but don't have access to the file to show you right now.
  13. Check for any entries in the database for that year, if none are found then the increment equals 001 if one is found, select the max and add 1. If you need help with the code show us what you currently have and we might be able to help you edit it.
  14. W3C is probably the best out there. I mean they do set the standards for the whole internet...
  15. HTML - http://validator.w3.org/
  16. Only thing I see wrong is that you would have to echo the variable in this line; menu1[0]='<a href=viewsubforum.php?sfid=<?php echo "$sfid'>$sfname</a>'"; ?>
  17. The column that they are entering it in, what is the format of it?
  18. I thought that nl2br only worked when echoing data, not when inserting it in to a database... I have always just had the user fill out a text box where they hit enter for a new line. Then insert it in to a TEXT field in my table. Then when I display it I use nl2br. I have never had any problems with that.
  19. In most cases simply enclosing order in ` ` will work as well. I had to do this for one of my tables in the past. Putting something in ` ` will make the server treat it as a name rather than a recgonized command or reserved word.
  20. If you want to change that value, then undo the auto-increment setting on the column. If you want a number the corresponds to the row number then create a nother column in order to do that, one that will be static.
  21. I was referring to using the word date, if you put `date` it will not treat it as a reserved word and you won't have those sorts of problems. Not sure if that will help you or not though...
  22. I have run in to this before, you just have to make sure you put ` ` around it.
  23. <?php $string = strtoupper($string); ?> That will convert everything to upper case. Then you can use a replace function to remove any non letter characters, I'm not the right one to show you how to do that because I'm not an expert on regular expressions yet. But look in to preg_replace
  24. I've used date_default_timezone_set() without any problems in the past.
×
×
  • 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.