Jump to content

Muddy_Funster

Members
  • Posts

    3,372
  • Joined

  • Last visited

  • Days Won

    18

Everything posted by Muddy_Funster

  1. Just work out the floor of the square root??? <?php $result = floor(sqrt(x))); echo $result; ?>
  2. I have a very strong feeling you are way off tack on this. Could you break down where the info is coming from and how it is populated? Also why you need to store it in this format and what you want to do with it once it recovered.
  3. not tested, but I think this could do it (seems logical to me at any rate, but that seldom counts for much...): <?php $a = array($field1, $field2, $field3, $field4, $field5, $field6); foreach($a as $k => $v) { if(empty($v)) { unset($a[$k]); } if(!$a[$k+1]){ //if there isn't another record after this one: $a[$k-1] .= ' And '.$v; // the record before this one has ' And '.$v ($v the value of this record) appended to it unset($a[$k]); // this record is then dropped as it's value has been appended to the previous one } } $_SESSION['mycache'] = "<h2>You have built</h2> " . implode(", ",$a); ?> I'm just not sure how it's going to handle any empty values at the end of the array. It may be that you need to concatenate the last two array values after the loop, but before the explode...
  4. even this fails to display? $data = "path to file checked by logging into WINSCP and looking at properties. Is a .txt file"; echo $data;
  5. If you bind the session to their IP+account I dont see why you would want/need to time them out every hour.
  6. erm...huh? What is all that? where is all that? how is all that making it's way into your web headers? Could you post some sample code (using the code/php tags) that relates to your problem area?
  7. You missed the $ off the start of search_for in the $query string.
  8. what's the output of print_r($result) you should get something like "Resource #5" also, you have no error capture on your actual query, use an or die ("error:".mysql_error()) on that line too.
  9. I'm confused, you said you wanted to use two tables, your example only shows one.
  10. use mysql_fetch_array() or mysql_fetch_assoc() not mysql_fetch_row(). If you use mysql_fetch_assoc() then you will need to use the actual column names within the square brackets and single quotes rather then the numerical array key value. while ($row = mysql_fetch_array($result)) { echo"<tr><td>{$row['0']}</td><td>{$row['1']}</td>...<td>{$row['n']}</td></tr>"; }// remember to close your table after the results are written out
  11. Noisy output is my fault - I left the following lines of code in from when I was debuging it (because I didn't have time to set up a DB as well): print_r($_POST); echo "<br><br>"; print_r($fields); remove them and it should be fine. First thing I would suggest is seriously spend time designing your project. I know from experience it's all to easy to fling together some tables and start to code as soon as the concept is rounded off. I also know from the same experiance that it's a proper headache if that impulse is not resisted. Your table structure seems off to me, looking at the limited information available and having no idea of the context, it seems to me that you would have been better served having a single "postionHeld" column rather than a bool column for every possibility individualy. As I said though, this is mainly for another thread, you can also PM me if you want to ask anything directly, although opeing a thread will generaly get more (and better!) input.
  12. ok, this is still kinda messy, but I think it should at least work this time: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Test Document</title> </head> <body> <p> <?php $fields = array('SPM'=> 0, 'PM' => 0, 'CEST'=> 0, 'EST'=> 0, 'PE'=> 0, 'SI'=> 0, 'OTH'=> 0); $fields[$_POST['field']] = 1; $fname = $_POST['fname']; $lname = $_POST['lname']; $phone = $_POST['phone']; $Company = $_POST['Company']; $Email = $_POST['Email']; $SPM = $fields['SPM']; $PM = $fields['PM']; $CEST = $fields['CEST']; $EST = $fields['EST']; $PE = $fields['PE']; $SI = $fields['SI']; $OTH = $fields['OTH']; mysql_connect ('server.mysql.com', 'user', '********') or die ('Error: ' . mysql_error()); mysql_select_db ("database"); $query="INSERT INTO ContactList (fname, lname, phone, Company, Email, SPM, PM, CEST, EST, PE, SI, OTH) VALUES ('$fname', '$lname', '$phone', '$Company', '$Email', '$SPM', '$PM', '$CEST', '$EST', '$PE', '$SI', '$OTH')"; mysql_query($query) or die ('Error registering'); echo " Successful!"; print_r($_POST); echo "<br><br>"; print_r($fields); ?> </p> <p><a href="query.php">Back to Query</a></p> </body> </html> I'm not sure why you have designed it this way, but that's for another thread Let me know how you get on with this.
  13. nah, fanway woulda moved it if he thought it would be better. Truth is most of the people here look up both forums anyways. Let me look closer at the code and see what I can come up with.
  14. From the sound of it I think you would be better suited to using a switch : http://php.net/manual/en/control-structures.switch.php
  15. No, he meens the fact that you have your field list in the INSERT query built using single quotes. I didn't even notice and thought they were backticks.
  16. try changing your query line to this for now: $query="INSERT INTO ContactList ('fname', 'lname', 'phone', 'Company', 'Email', 'SPM', 'PM', 'CEST', 'EST', 'PE', 'SI', 'OTH') VALUES ('$fname', '$lname', '$phone', '$Company', '$Email', '$SPM', '$PM', '$CEST', '$EST', '$PE', '$SI', '$OTH')";
  17. could you copy and paste your exact page code as it is in your .php file please (html as well)?
  18. else { $year_var = '4'; $renewaldate = strtotime($subscriptiondate); $next_year = date('Y-m-d',strtotime( "+$year_var year",$renewaldate)); echo $next_year; } should do it - remember to change to double quotes
  19. Turn on IIS sevices on your AD server?
  20. fourthly, I get that line you marked as being line 29, with the whole script closing on line 36... is that the entyre script exactly as it apears in your php file?
  21. the php colour is an easy one, you are using code tags (the words "code" and "/code" writen within the square brackets) I'm using php tags (the words "php" and "/php" within the square brackets) now to the comments: <?php $field1 = "Farms to " . $_POST['farms_population']; $a = array("$field1", "$field2", "$field3", "$field4", "$field5", "$field6"); $a = array_unique($a); // removes all keys and values from array where the same VALUE is found, leaving only the first (lowest value Key) instance for ($i=0;// set the initial value of $i to 0 (zero) $i < (count($a) -1); // while $i is less then how many $keys are in the array - we use the -1 because the count() function starts at 1 and not 0 !!this check will be performed every run through the loop, and if it returns true the loop will run again, be carefull not to use a single = in here as you will get an infinate loop...!! $i++)// this making it keep adding by 1 (incramenting the value in $i) { if($a[$i+1] != '')// if the value in the NEXT $key along is not blank DO perform the following code block: { $a[$i] = $a[$i]." and";// each $field turns into the $field plus with the and added. (technical term: we concatonate the value in $a[$i] and the string value " and") } //not including an else statement implicitly tells PHP that there is nothing to do in the event that the if evaluates to false } $_SESSION['changed'] = "You have changed " . implode(" ",$a); echo $_SESSION['changed']; ?> if you need anything else let us know.
  22. you will need javascript (is one flavour or another) for that kind of onBlur effect to process.
  23. I think with this little tweek... <?php $field1 = "Farms to " . $_POST['farms_population']; $a = array("$field1", "$field2", "$field3", "$field4", "$field5", "$field6"); $a = array_unique($a); for ($i=0; $i < (count($a) -1); $i++){ if($a[$i+1] != ''){ $a[$i] = $a[$i]." and"; } $_SESSION['changed'] = "You have changed " . implode(" ",$a); echo $_SESSION['changed']; ?> how does that do?
  24. can be a little cheeky and add this: <?php $field1 = "Farms to " . $_POST['farms_population']; $a = array("$field1", "$field2", "$field3", "$field4", "$field5", "$field6"); $a = array_unique($a); for ($i=0; $i < (count($a) -1); $i++){ if($a[$i] != ''){ $a[$i] = $a[$i]." and"; } $_SESSION['changed'] = "You have changed " . implode(" ",$a); echo $_SESSION['changed']; ?> scratch that, that's not going to help...
×
×
  • 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.