Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. foreach ($replacement as $val) { $r[] = $val['replacement']; } $replacement = $r;
  2. show your form. I'm having trouble trying to figure out why you're using that sprintf.
  3. Look at example3 in the code I posted.
  4. I don't understand how you can work with a database and use a loop but fail to understand the concept of incrementing a variable, but whatever. <?php $x = 0; while(true) { $checked = ($x < 5)? "checked='checked'" : ""; echo "<p><input type='checkbox' name='meal[]' value='{$row['id']}' $checked/>"; $x++; }
  5. <?php if ($_POST['fruit']) { // example1: dump the array print_r($_POST['fruit']; // example2: individual naming. If all 3 were checked, each of these vars would exist echo $_POST['fruit'][0]; echo $_POST['fruit'][1]; echo $_POST['fruit'][2]; // example3: loop through it foreach ($_POST['fruit'] as $fruit) { echo "$fruit <br />"; } // end foreach } // end for ?> <form action = '' method = 'post'> <input type = 'checkbox' name='fruit[]' value='apple'>apple <br /> <input type = 'checkbox' name='fruit[]' value='orange'>orange <br /> <input type = 'checkbox' name='fruit[]' value='banana'>banana <br /> <input type = 'submit' value = 'submit'> </form> Dunno how you're storing the choices in the database, but if you're looking for the answers to be in a single column as a string or whatever, you can implode $_POST['fruit']. Otherwise, you'll have to create another loop inside your loops to go through each element in $_POST['fruit']
  6. ...and yet the movie industry is one of the richest in the world...
  7. forms are easily spoofed. Be sure to check it server side with $_FILES['userfile']['size']
  8. wait sorry that's wrong. Okay what I meant to say is, your inner condition will only execute if your outer one is true, and your outer one will only evaluate true if $field == one of those other things, like $_POST['Age'], not $_POST['experienceRating']. Where are you assigning something to $field?
  9. if your outer condition evaluates true then your inner condition will evaluate false, because in order for your outer condition to evaluate true, $field can't be empty.
  10. I think most people probably didn't bother calling the cops and even cheered him on because they thought it was fake. People do fake stuff like that all the time. I mean come on, it's not even hard to fake. He pilled himself to death. Not exactly high end special effects.
  11. Assuming that you retrieved your date from the database and split it up into vars... echo "<select>"; for($m=1; $m<=12; $m=$m+1){ $selected = ($m == $month)? 'selected' : ''; echo "<option value=\"$m\" name=\"month\" $selected>$m</option>"; } echo "</select>";
  12. You're allowed to make an edit up to like 2-3m after you post (don't remember exact window). But past that, we've disabled it, due to people constantly deleting posts and threads after the fact, or else going back later and editing and then it causes confusion in the whole problem solving process.
  13. coincidentally, I already gave it a shot...
  14. A very wise, awe-inspiring person, to whom I personally deem my hero, summed it up nicely when he said this: OOP Help's been deemed not but crass A forum without any class It's gone on with hitch so destructor the bitch May this horrible problem just pass
  15. that's because you didn't specify posting method in your form, so it defaults to the GET method (through the url). Add method='post' to your form tag
  16. http://www.phpfreaks.com/forums/index.php/topic,37442.0.html
  17. dunno if this is the best way, but it seems to work... preg_match_all("/(\d\.\d[^\d]*)/",$string, $result);
  18. It's amazing what google comes up with.
  19. change to: $result=mysql_query($dbQuery, $db) or die(mysql_error()); Though I already suspect that you're using the wrong variable for the 2nd mysql_query argument. People usually assign mysql_select_db to $db. The 2nd argument to mysql_query (which is optional, btw) should be the connection resource (the variable you assigned mysql_connect to).
  20. <?php $min = 0; $max = 16; $randomNum = 12; if ((in_array($player->house_id, range($min, $max))) && ($player->house_id != $randomNum)) { echo "true"; } ?>
  21. You should only be using stripslashes if magic quotes are ON, and it should be done before mysql_real_escape_string, and as wildteen said, all that is only done on data going into the database, not out ($row['var'] is a common array used when retrieving data, that's why wildteen asked). If you read the mysql_real_escape_string manual entry, it explains how to use it.
  22. If there is no html output before the session_start(), not even blank lines or whitespace, then there's no reason that code shouldn't create that session var.
  23. Well your OP said anything from 0-16, so which is it? 0-16 or 0-16 except some random number like 12?
  24. no. It's in there to prevent an infinite loop. if ($length < makes it stop after there are no more elements in $nodeArray. That 8 should be changed to a count($nodeArray) for more flexibility.
  25. or you can use a switch
×
×
  • 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.