Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. You don't have any delimiters in your regex (the thing that tells pcre where the beginning and end of the pattern is, like /../). You should have gotten an error message from that, so maybe you have error reporting turned off. Other than that, it should have worked. Another way to write it is like so: echo preg_replace("/<[^>]*>/","",$string);
  2. so are we going to make threads and posts, every time a browser is bugged? And is everybody and they moms going to chime in and say they have the same problem? Geez, go post in the browser's support forum. What are we supposed to do about it?
  3. You would store the info in a session variable. Session variables persist from page to page.
  4. There was no function in that spreadsheet, and as far as I can tell, there is no pattern to be made from those numbers, in which to create a function.
  5. no, like what you have in your while loop: $title = fgets($f, 4000); while($line = fgets($f, 4000)) { ... }
  6. $pph = round($pph, 2);
  7. if it's the first line in the file, do an fgets 1 time before the while loop.
  8. Hmm...tbh I think you should rethink your script structure in the first place, but whatever. My take: asort($array); foreach($array as $name => $num) { $count[$num]++; } foreach ($count as $c) { $t = array_splice($array,0,$c); ksort($t); $array = array_merge($array, $t); }
  9. where are you getting the array keys from? Do they have to be the array keys? Could the names be array an element instead?
  10. A Content Management System is just that: a system, made up of lots of code that does a million different things. It's not a single brick in a wall, or even the wall; it's a whole house. And it sounds like you're at the brick level. When it comes to advice or code, there is no quick and easy magic wand, unless that magic wand is called money and it's waved at someone else.
  11. As revraz stated, the idea is to cycle through the categories, which are no doubt stored in your database. It looks like $option_list is already a generated string of options, so there's already a query and a loop for that in your code somewhere. All you need to do is follow that example, except with checkboxes instead of option tags. Or if you were wanting to replace the dropdown with the checkboxes, just alter that code (also remove the select tags where the generated $option_list string is echoed, obviously). Thing is though, I'm not seeing anything in item.php where the option values are being assigned to $option_list, so you're going to have to look somewhere else.
  12. Is this the only site that happens for?
  13. shouldn't be a problem, unless you're trying to echo it with the double quotes; then it would be trying to interpret it as a variable. But I don't see any echoes up there. Perhaps if you were to be more specific than "it doesn't work"?
  14. Oh okay yeah that's right, because there are certain times when you're going to want to echo out those tags over and over again, like when you...I mean, like when...hmm..nope, I got nothin'.
  15. I imagine putting the html, head and body tags inside that loop are going to cause problems on some level...
  16. You're using the names correctly. The problem is that you're checking to see if it's set, and if it's not, you're setting it to null...that's about as useful as setting a variable to 1 if it's 1.... also you forgot the = in the array assignment $field_list = array("text1", "text2", "etc"); But I assume that was a typo...
  17. The one you said is causing 2 updates to happen... $template->assign_block_vars
  18. So what does that method look like?
  19. Okay well if you're going to try and make a number out of arbitrary stuff being entered in at arbitrary places (random money formats, letters, whatever....), why not just make a really simple. Just extract the numbers. Who cares where they are or what was used. We'll throw in a decimal match, since there is a difference between 100.00 and 1.0000. Then money_format it. preg_match_all("/\d|\./",$string, $match); setlocale(LC_MONETARY, 'en_US'); $num = money_format('%n', implode($match[0]));
  20. (?:\<a.*href="([^"]*)"[^>]*>)[.\W]*(?:\<img.*src="([^"]*)"[^>]*>)
  21. Okay let's back up a minute. Post several examples of what the actual string may look like. The way I understand it is, you have for examples: <a href='url'><img src='image'></a> <a href='url'><img src='image' width='1' height='1'></a> And so you are saying that you want to extract 'url' and 'image' right?
  22. premiso: If you use global inside the function, variable's scope will extend outside the function. The whole point of static variables is that they are 'remembered' after function is executed, but retain the function scope. In addition, recursion is when something calls itself, which is not what you're doing in your solution. justinh: Just thought I'd point out that grammatically, putting (s) at the end of something makes it optional, so technically, you would have time(s) no matter how many times the function is called. In your if..else condition, you would want to display 'time' or 'times'; no parenthesis. Just a minor bitch from the grammar police. <?php function myfuction(){ static $a = 1; if ($a == 1) { echo "this function has been loaded " .$a. " time<br />"; } else { echo "this function has been loaded " .$a. " times<br />"; } $a++; } for($i = 0; $i <= 8; ++$i){ myfuction(); } ?>
  23. <img.*src='([^']*)'[^>]*>
  24. True that. I myself only started giving regex a serious effort about a month ago. It's scary and frustrating and addictive to all hell. And on that note... $var = "04 - blahblahblahblah - thisthatandtheother"; preg_match("/-\s(.*)/",$var,$match); echo $match[1]; That will work, even if your string were like 04 - blahblahblahblah - thisthatandtheother 04 - blahblahblahblah - thisthatandtheother - laksdklsdfj 04 - blahblahblahblah - thisthatandtheother - lksdfjklsjdf - lkasdfjlksfj - kasjdfljlj or hell, anything with an initial "- " - blkajsdlfkjslfskjdf - blkjasdflkj asdlkjfs laksjfdls - asldfkjasdf
  25. die() will only work if there was a problem executing the query. If nothing was found in the db, it returns false, but that's not a failed execute. You need to wrap a condition around your unlink. something like this: <?php $file = $_GET["id"]; $delid = $_GET["delid"]; include "my_sql.php"; mysql_query ("DELETE FROM uploadedimg WHERE name = '$file' AND killcode = '$delid'")or die; ijf (mysql_affected_rows() > 0) { $myFile = "./images/$file"; unlink($myFile); } ?>
×
×
  • 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.