Jump to content

meltingpoint

Members
  • Posts

    194
  • Joined

  • Last visited

Everything posted by meltingpoint

  1. Maybe try switch() <?php switch($id) { case "1": echo "We are in 1 or 2"; break; case "2": echo "We are in 1 or 2"; break; case "3": echo "We are in 3 or 4"; break; case "4": echo "We are in 3 or 4"; break; default: echo "Not in 1 to 4"; } ?>
  2. And actually...........the table html is a little mixed up. It should look like; echo "<table border=1>"; echo "<tr>"; echo "<th> ID </th> <th>Part </th><th> Count </th><th> Price</th>"; echo "</tr>"; echo "<tr>"; echo "<td>".$hold[$X][0]."</td><td>".$hold[$X][1]."</td><td>".$hold[$X][2]."</td><td>".$hold[$X][3]."</td>"; echo "</tr>"; echo "</table>";
  3. <?php $inf = 'infile.txt'; $id = 'AC1000';//--------this would be the $id variable passed by the form ($_POST) or by a link ($_GET) if(!file_exists($inf)) { echo "Sorry- could not find file"; } // $record_count =0; // $openedfile =fopen($inf, "r"); if(!$openedfile) { echo "File could not be OPENED. Please notify the Administrator"; echo "</tr>"; exit; } // flock($openedfile, LOCK_EX) or die("Error!- Could not obtain exclusive lock on the file to edit. Please try again"); while(!feof($openedfile)) { $record_count++; $hold[$record_count] = explode(":", trim(fgets($openedfile))); if($hold[$record_count][0] == $id) $X = $record_count;//-----sets $X to array that contains your match } flock($openedfile, LOCK_UN); fclose($openedfile); // //---Now all your data is in an array $hold where each line of you file is represented as so // $hold[0] which would look like $hold[0][0] = AC1000, $hold[0][1] = Hammers, $hold[0][2] = 122, $hold[0][3] = 12.50 // $hold[1] $hold[1][0] = AC1001, $hold[1][1] = Wrenches, $hold[1][2] = 5, $hold[1][3] = 5.00 //......etc // if(empty($X)) { echo "Error: Part number not found."; exit; } else { echo "<table border=1>"; echo "<th> ID <th> Part <th> Count <th> Price"; echo "<tr><td>".$hold[$X][0]."</td><td>".$hold[$X][1]."</td>"; echo "<td>".$hold[$X][2]."</td><td>".$hold[$X][3]."</td></tr>"; echo "</table>"; } ?> Run and tested. Worked for me. Hope that helps.
  4. $Myarray = array( 1,0,0,1,1,1,0,1); $other_array = array(0, $Myarray[0] , $Myarray[1] , $Myarray[2] , $Myarray[3] , $Myarray[4] , $Myarray[5] , $Myarray[6]); print_r($Myarray); echo "<br>"; print_r($other_array); Result: Array ( [0] => 1 [1] => 0 [2] => 0 [3] => 1 [4] => 1 [5] => 1 [6] => 0 [7] => 1 ) Array ( [0] => 0 [1] => 1 [2] => 0 [3] => 0 [4] => 1 [5] => 1 [6] => 1 [7] => 0 ) **is there a reason to loop through it if the number of elements never change? Wouldn't the above suit your need?
  5. Outside or inside the web root would depend on if the files have sensitive data or not. If no- then inside is fine. You could accomplish this with simple form validation. Have them fill out a form with the necessary information and if it is all filled out- then re-direct them to the page to download the file. Validation- if they don't enter an email address and name- then an error message is displayed and the form is not submitted.
  6. hahahaha----------what a goof moment. My unlink() was outside the script for if it was successful it went to the message page and therefore was never being called. How funny. Well-------------that's how it goes sometimes. Cheers all.........lol.........lol
  7. Below is my exact code. I can get the unlink() to work in other scripts- but not this one. Anyone see anything that would make unlink() not work? $file1, $file2 etc...are defined in the config file as exampled above. // switch($database) { case "maindb": $filetorestore = 'databases/BACKUPmaindatadb.txt' and $restored = $file2; break; case "homedb": $filetorestore = 'databases/BACKUPdchomedb.txt' and $restored = $file3; break; case "petsdb": $filetorestore = 'databases/BACKUPlostanimals.txt' and $restored = $file8; break; case "vehiclesdb": $filetorestore = 'databases/BACKUPvehicleslist.txt' and $restored = $file11; break; case "bikesdb": $filetorestore = 'databases/BACKUPbikelist.txt' and $restored = $file7; break; case "licensesdb": $filetorestore = 'databases/BACKUPbikelicenses.txt' and $restored = $file12; break; case "parkingdb": $filetorestore = 'databases/BACKUPparkingpermission.txt' and $restored = $file9; break; case "dispatchnotesdb": $filetorestore = 'databases/BACKUPdispatchnotes.txt' and $restored = $file6; break; case "usersdb": $filetorestore = 'databases/BACKUPuserpermissions.txt' and $restored = $file10; break; case "categoriesdb": $filetorestore = 'databases/BACKUPcategories.txt' and $restored = $file5; break; case "spcattndb": $filetorestore = 'databases/BACKUPspcattndatabase.txt' and $restored = $file13; break; default: $filetorestore = $file100; break; } // if(empty($filetorestore)){ $message = "<center>ERROR!- no database was selected/detected to be Backed-UP. Please try again. If problem persists- notify the Web/IT Administrator.</center>"; include("dcloginmessagepage.php"); exit; } // sleep(1);//---------------supposed fix for IIS Servers that copy() does not work well with------------ // if(!copy($filetorestore, $restored)) { $message = "<center>The RESTORATION of the Database was UNSUCCESSFUL!- Please notify the Administrator.</center>"; include("dcloginmessagepage.php"); exit; } else { $message = "<center>RESTORATION of the Database was sucessfull.</center>"; include("dcloginmessagepage.php"); exit; } // unlink($filetostore); // // //-----------------------------------------------------------------------------------------------------------------------------
  8. echo does indeed echo out as above = storagefolder/mydatabase.txt because this script may wind up in any directory or subdirectory - I was trying to use relative link. Using absolute may prove problematic.
  9. I have a config file that lists a file like so.. $file1 = 'storagefolder/mydatabase.txt'; How can I delete the file "mydatabase.txt" that is in another directory 'storagefolder' ? unlink($file1); gives an error that says not such file or directory
  10. bentweiner- All very good suggestions. I kinda migrate towards this one myself; http://www.designdetector.com/tips/flat-file-database-demo2.php Chris Hester put together a series of 5 demo/tutorials on flat files that are really good. using array_unshift() for sorting made my life much easier. Cheers-
  11. cssfreakie- It is indeed the WYSIWYG editor that is causing the problem for when I build a standard php page setting the div1 and div2 and including a page with in that- it all works fine. So I will have to experiment to see if I can override the WYSIWYG editor. Meanwhile- I will work on your example. Thanks very much for the help.
  12. Did not work. Still inherited the color of the included page. Frustrating....................
  13. just how to create a container with the WYSIWYG program is the question. The problem is that no matter what I do- the page that is including another page always inherits the background color of the page it is including, even if I separate via div.
  14. index.php : is a page made with a WYSIWYG program, has the text -Berkshire Systems LLC, has an html box which is a division named "background" and the pages color is white as set in the page properties page1.php: is a page made with a WYSIWYG program, has the text -This is the included page, has <link rel="stylesheet" type="text/css" href="test_style.css"/> placed between the head tags and its default color is white as set in the page properties. test_style.css has the following body {background-color: grey;} when viewing page1.php (www.taskforcecentral.com/dev2/page1.php) you get the page which displays the proper text as described above and the back ground is grey. when viewing index.php (www.taskforcecentral.com/dev2/index.php) all of the page(s) are grey instead of the only the div "background" being grey and the rest of the index being white. So the index.php includes the page1.php and inherits the grey background as defined in the test_style.css. So that is where I am at. The created div of "background" which contains the included page1.php changes the whole page instead of just the background of the div- background.
  15. Well- it is the page background that is being inherited. So the background from one is over riding the other. How then to do as you suggested if it is the background specifically that I want different on each page? Thanks in advance.
  16. page1.php (static html page properties) page2.php (references an external css style sheet) When I include page2.php inside page1.php via php - page1 adopts the css style of page2 Is there a way to stop this? Frustrated.
  17. Google- Flat File Membership or Flat File Login script There is no reason that a good flat file membership login script cannot be implemented. I have created a couple and they work very well. I have seen many on the net that I have examined and used bits and pieces to make a comprehensive or more secure membership / login script. So, have a look around with the above google query and see what suites your needs. While I agree that the "Cadillac" method would be MySQL- that is not the only method.
  18. <?php $to = "myemailwashere@website.com"; $subject = "Custom Order Message"; $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; $from = $_REQUEST['name']; $budget = $_REQUEST['budget']; $colors[] = $_REQUEST['colors']; $headers = "From: $email"; // if( !eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*". "@([a-z0-9]+([\.-][a-z0-9]+))*$",$email)) { header( "Location: order/invalidemail.html" ) ;//-------re-direct if invalid exit;//----------stops the script here so it will not send if invalid } //--------If it was valid- we continue on and send the mail and //--------echo out a message that the order was sent successfully mail($to, $from, $subject, $message, $budget, $headers) ; // echo "Your custom order query was sent successfully."; // ?>
  19. Try turning off "Compatibility View"..........had that screw up some of my css one time.
  20. It is impossible to tell without the code from the page that processes your form. Can you post that?
  21. Hey- nice idea with the array. So......should work... <?php $action = $_POST['action']; if(!in_array($action, array('edit', 'delete'))) { echo "ERROR- you must choose an appropriate form Action. Please try again"; } ?> I did not know that you could use in_array() in that way. Excellent! I will try it and see if it works. Thanks
  22. Form has combo box that lets users pick - Delete or Edit with corresponding values of delete and edit sent via $_POST. I want to validate that either one or the other has been picked. Doing this will keep from someone trying to inject some other crud. So I tried ; <?php if($action !== 'delete' || 'edit'){ echo "ERROR- you must choose an appropriate form Action. Please try again.";} ?> It does not seem to work. Before I go on, is my syntax / coding correct? If I do it like below- it works. <?php if($action !== 'delete' or $action !== 'edit'){ echo "ERROR- you must choose an appropriate form Action. Please try again.";} ?> Just trying to figure out the proper coding method. Tks
  23. mjdamato- That worked like a charm. Completely forgot about array_search()! Ugh. Thanks again.
  24. thorpe- Thanks for that. However, I am implementing unset() and it is not working. If I am using it wrong- please elaborate.
  25. <?php $OLDcategory = ($_POST['cat_to_chg']); $NEWcategory[] = ($_POST['new_cat']); // $cats = file("categories.txt");// // $newcats = array_merge($NEWcategory, $cats); print_r($newcats); //Array ( [0] => New Cat [1] => Utilities [2] => Police Agencies(Other) [3] => GP Schools [4] => Detroit Schools [5] => Tow Trucks [6] => Cabs [7] => Alarm Companies [8] => Hospitals [9] => Animal Shelters ) // foreach($newcats as $key =>$value) { if($value == $OLDcategory) { unset($newcats[$key]);} } ?> I can get it to add the $NEWcategory to the array just fine. I am stuck however, on removing the $OLDcategory from the array. My foreach() is not working. Any suggestions?
×
×
  • 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.