Jump to content

Orio

Staff Alumni
  • Posts

    2,491
  • Joined

  • Last visited

    Never

Posts posted by Orio

  1. I realized, as I was doing searches.... that if I searched for: a**

     

     

    Why would you input something like that? It's like using in SQL "... LIKE 'something%%' ...". I can't see what you're trying to achieve using double wildcards and that's why the function is not build for such input.

     

    Orio.

  2. Also, I mean, no offense, but I don't think you really understand what being an atheist means... Simply not observing certain 'traditions' or rites or practices or beliefs does not make you an atheist.  I'm not saying you aren't an atheist, just saying...Do you believe in God or a god or some higher power or any other kind of supernatural stuff?  Atheists only believe what science can prove.

     

    No, I don't believe there's a higher power. But that doesn't prevent me from celebrating our holidays with my family, or from having a big dinner with family/friends every Friday evening.

    You can call me "traditional", but at least here in Israel being traditional means more than what I've stated above (for an example- eating only kosher food or going to the synagogue every Friday/Saturday). That's why I am classifying myself as an atheist.

     

    Orio.

  3. Was he atheist or theist?

     

    Do atheist middle-easterns/arabs even exist?

     

    I know I live in a small country so maybe you all forgot about it... But I am an atheist- from Israel, so as far as I know I am a middle-eastern.

    Quite popular here by the way, most of the (Jewish) Israeli people are atheists. I mean we all do celebrate our holidays etc', but most of the Israelis don't go as far as eating only kosher food or not using electricity/cars at Saturday.

     

    Orio.

  4. From your post I can't really understand how your numbers are stored. Database? An array? Something else?

    If it's in an array, you could use array_count_values() and then just go over them using a foreach (If you want to sort it, use ksort() first):

     

    <?php
    
    $numbers = array(1,5,2,1);
    
    $count = array_count_values($numbers);
    ksort($count);
    foreach($count as $key => $val)
    echo "Number {$key} appears {$val} times";
    
    ?>

     

     

    Orio.

  5. That piece of code is familiar... It's like I've written it :P

    I don't really understand where you're having problems. Maybe you can post/PM me the link so I could see it?

     

    Anyway, for debugging purposes, check the output given by:

     

    <?php
    
    if($pagenum === "last")
    {
       $query = "Select COUNT(*) as C from forumtutorial_posts where parentid='$id'";
       $result = mysql_query($query);
       $data = mysql_fetch_array($result);
       $pagenum = floor($data['C'] / $page_rows) + 1;
       die ("Count is: ".$data['C']."<br>page_rows: ".$page_rows."<br>Pagenum: ".$pagenum);
    }
    
    ?>

     

    Orio.

  6. You can't compare strings of dates. You need to convert them into time stamps.

     

    Try this:

     

    <?php
    
       $date = time();
       $res = mysql_query("SELECT id, myspaceid, nick, image, expire_time FROM `vip` WHERE game = $game_no order by id asc");
       while($associate = mysql_fetch_array($res)) {
          
          $id = $associate['id'];
          $expire_time = $associate['expire_time'];
       if($date > strtotime($expire_time)) {
          $delete = mysql_query("DELETE FROM `vip` WHERE `expire_time` = $expire_time");
          } else {
    
    ?>

     

     

    Orio.

  7. In my opinion this is what you have to do:

     

    Use ignore_user_abort() and set_time_limit(0) and just redirect your user to some other page so he could continue and do whatever he wants. This way the user won't have to be stuck in the updating page.

    This way, if you want to notify the user if the process was finished successfully you could do something like this:

    Add a column to your users table called "alert". Default value is 0. At the end of your long script, update the alert column to 1 if the task was completed successfully. Other values could symbolize different errors that could occur. The rest of your pages (let's say in your header or whatever, something that is included in all of the other pages), the alert column would be checked to see if a certain task was finished successfully or if it failed. A message would show up in that case (as a javascript pop up for an example). You'd have to update back the alert column to 0 of course.

    This notifying system is somewhat similar to SMF's PM notification system (which asks you if you want to open the message in a new window when you receive one).

     

    Anyway, this solution seems to me much cleaner and nicer.

     

    Orio.

  8. Just added some brackets for the ORs:

     

    <?php
    
    echo boldWords(array("one", "t*"), "One is before two and three is too.");
    
    function boldWords($words, $string)
    {
       foreach($words as $k => $w)
       {
          $w = '('.str_replace('\*', '.*?)', preg_quote($w), $count);
          if(!$count)
             $w .= ')';
          $words[$k] = $w;
       }
       $regex = "~(".implode('|', $words).")\b~i";
    
       return preg_replace($regex ,'<strong>$0</strong>',$string);
    }
    
    ?>

     

     

    Orio.

  9. Sanitize the words with preg_quote.

     

    Good point. But that will require a small fix:

     

    <?php
    
    echo boldWords(array("one", "t*"), "One is before two and three is too.");
    
    function boldWords($words, $string)
    {
       foreach($words as $k => $w)
       {
          $w = '('.str_replace('\*', '.*?)', preg_quote($w), $count);
          if(!$count)
             $w .= ')';
          $words[$k] = $w;
       }
       $regex = "~".implode('|', $words)."\b~i";
    
       return preg_replace($regex ,'<strong>$0</strong>',$string);
    }
    
    ?>

     

     

    Orio.

  10. The problem is that these values don't exist unless a form submission was made. You have to make sure that what you're echoing exists, IE:

     

    <?php	if(isset($_POST['fname'])) echo $_POST['fname'];	?>

     

     

    Orio.

     

     

  11. This worked for me:

     

    <?php
    
    echo boldWords(array("one", "t*"), "One is before two and three is too.");
    
    function boldWords($words, $string)
    {
    foreach($words as $k => $w)
    {
    	$w = '('.str_replace('*', '.*?)', $w, $count);
    	if(!$count)
    		$w .= ')';
    	$words[$k] = $w;
    }
    $regex = "~".implode('|', $words)."\b~i";
    
    return preg_replace($regex ,'<strong>$0</strong>',$string);
    }
    
    ?>

     

    Enjoy :)

     

    Orio.

×
×
  • 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.