Jump to content

Alex

Staff Alumni
  • Posts

    2,467
  • Joined

  • Last visited

Everything posted by Alex

  1. This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=336554.0
  2. $_VERSION = new version(); I'm not sure that will give you an error, but in PHP 5 objects are passed by reference by default so you don't need the &.
  3. If you check the manual for array_slice, you'll see what the parameters mean. In my example, I use 1 for the second parameter because it denotes which position to start taking values from. We want to skip the first, 0th element, so we start at 1. The third parameter is how far away from the end we want to stop. We want to stop collecting values 1 away from the end, so we choose -1. For example, you can try this code: $input = array("a", "b", "c", "d", "e"); print_r(array_slice($input, 1, -1)); // array('b', 'c', 'd')
  4. Depends on how you define "middle values". If you mean any values that aren't at the absolute ends, then yes you could do that (or in the case of only 3 or 4 elements). But if you're only looking for the middle 1 or 2 values inside an array of length greater than 4, then you'll need more information than just the maximum and minimum values of the array, without sorting of course. Yes, that's correct. For example, in the case of an array with length 7. $s / 2 will give us 3.5, and the floor function will round that value down, to 3. Giving us $arr[3], which is the middle value in that array (0, 1, 2, 3, 4, 5, 6). edit: Well, in that case it's not even necessary to know the min and max values of the array. You can simply sort the array, and create a new array ignoring the first and last elements. For example: $arr = array(5, 92, 5, 42, 19); sort($arr); print_r(array_slice($arr, 1, -1)); array_slice
  5. Not sure what you're asking. Can you try to reformat your question?
  6. Then you can still use cssfreakie's solution, just use sort on the array beforehand. So something like: $arr = array(5, 92, 5, 42, 19); sort($arr); if(($s = sizeof($arr)) % 2 == 0) { echo "Middle values are: " . $arr[$s / 2] . " and " . $arr[$s / 2 - 1]; } else { echo "Middle value: " . $arr[floor($s / 2)]; }
  7. It's a decent start, and I can see a lot of work has gone into it, but it's very insecure. You need to be doing validations on everything. It only took me about 30 seconds to find my first exploit: You're not doing validation on who can delete what. Anyone can call your post_remove() javascript function, or query ajax/post_remove_add.php and delete any post they want.
  8. Hey Alex, as far as I know the alternative syntax will still work with our without the shorttags. It definitely works for control structures. http://us3.php.net/manual/en/ini.core.php#ini.short-open-tag
  9. To change out of short tags.. <?=$index1?> For example, should be <?php echo $index1; ?>
  10. Typically dish washers have two racks. The "top rack" is... the top one.
  11. You can just store the errors in a log file, and load the errors into an array using file when you need.
  12. I'm not really sure what you're trying to do there, but you should be selecting the article you're after through the query. Something like this: $sql = "SELECT id, post FROM articles WHERE id='" . mysql_real_escape_string($_GET['article']) . "'"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); $r = mysql_fetch_assoc($result); echo $r['post']; mysql_real_escape_string That's just an example of how to fetch the data. In your actual application you'll probably want some checking to make sure that an article exists and if it doesn't show some error. Oh, and using shorttags is never a good idea.
  13. This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=336191.0
  14. In order to determine if there has been an increase in natural disasters you would need to look over an extended period of time, and because over that extended period of time technology has improved our ability to detect natural disasters significantly (e.g. increased number of and quality of seismographs), it's not as simple as seeing more recorded events. For example, if you look at the amount of recorded earthquakes over the past 50 years without taking into account the increased number of seismographs it would seem as if we have an eminent problem on our hands. We don't. Remember those headlines a few months ago (?) where groups of animals were being found dead? Large numbers of birds falling out of the sky, tons of fish turning up floating in a lake, etc... Everyone was screaming that they were all related and were signs of the Apocalypse. Actually, these events aren't rare at all. In fact, they happen all the time, everyday. The only reason it became big news is because of the increased awareness of the public as a whole. All you need is a bunch of people posting on twitter about unrelated events and suddenly you have some false connection between a bunch of seemingly similar, but unrelated things.
  15. The reason for the unprecedented amount of natural disasters is our unprecedented ability to detect natural disasters. Right...so in 2010 we did not have the same unprecedented ability to detect natural disasters? You're right. It's definitely fair to extrapolate the apocalypse based on two data points: 2010 & 2011.
  16. The reason for the unprecedented amount of natural disasters is our unprecedented ability to detect natural disasters.
  17. It would be the only thing you needed if you just wanted to request the page and do nothing else. But you want to request the page with the post data ($_POST['text']), and put the result of that request (whatever that file outputs) in a div, then you'll need something different. "somedivid" would be the id of the div that you want to post the result of the response in, assuming that's what you want to do. If I was mistaken and you don't want to do anything with the result of the request just remove the last parameter, the success function, from the $.post() call. Making it: $.post(url, {'text': term});
  18. You'll need to specify the data to be sent in the request, and a callback function to be called when the response returns. Something like this: $.post(url, {'text': term}, function(data) { $('#somedivid').html(data); });
  19. You can mark it as solved yourself using the button on the bottom of the page.
  20. You misspelled session_start(): <?php session_strat(); echo $_SESSION['text'];?> You would also have to put session_start(); before any other output. To access the form you need to use document.forms['shareform'] not document.['shareform']
  21. That should be the value of the onclick attribute, not href.
  22. This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=335839.0
  23. This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=335836.0
  24. So then maybe something like this: $sql = mysql_query("SELECT Tasks.Task as Task from Tasks WHERE Tasks.ID NOT IN (SELECT Complete.TaskID FROM Complete WHERE Complete.UserID = '1')" or die(mysql_error()); while($fetch = mysql_fetch_array($sql)) { echo $fetch['Task']; }
  25. Well, it depends on what you want to echo out. The TaskID? The "Task" field, or what? You'll also have to specify which UserID we're dealing with here, don't forget that.
×
×
  • 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.