Jump to content

Ken2k7

Members
  • Posts

    5,196
  • Joined

  • Last visited

    Never

Posts posted by Ken2k7

  1. preg_replace will work. It can take in arrays as arguments so you can just put up 2 arrays. First array is the regexp and the second array is the replacement. So for example:

     

    $bb = array(
         '#\[b\](.+?)\[/b\]#i',
         '#\[i\](.+?)\[/i\]#i',
    );
    
    $replacement = array(
         '<b>$1</b>',
         '<i>$1</i>',
    );
    
    $new_str = preg_replace($bb, $replacement, $str);
    

  2. You need usort. Read about it.

     

    function c ($a, $b) {
    if (!array_key_exists('order', $a) || !array_key_exists('order', $b)) return 2;
    if ($a['order'] == $b['order']) return strcmp($a['title'], $b['title']);
    return $a['order'] < $b['order']? -1 : 1;
    }
    
    usort($myarray, 'c');
    var_dump($myarray);
    

  3. I actually spotted an error in my update. Missing a parenthesis.

     

    UPDATE members SET last_report_n = CONCAT_WS('-', RIGHT(last_pirep, 4), LEFT(last_pirep, 2), RIGHT(LEFT(last_pirep, LOCATE('.', last_pirep, 3), 2)));

  4. Cool now thats look a lot eaiser however how can I write that code? If I have over 50 records?

    Do you understand the code or SQL statements we posted up? Apparently you just run them.

  5. Breaking it down:

    $xR = array(3 => "ar", "br", 6 => "cr", "de", 10 => "en", "fr");

    That gives this:

     

    [3] => "ar"

    [4] => "br"

    [6] => "cr"

    [7] => "de"

    [10] => "en"

    [11] => "fr"

     

     

    $xR[8] = "ge";
    

    That says position at 8 will be "ge":

     

    [3] => "ar"

    [4] => "br"

    [6] => "cr"

    [7] => "de"

    [10] => "en"

    [11] => "fr"

    [8] => "ge"

     

     

    $xR[] = "hr";
    

    Since the last index stopped at 11 when you created the array, the next one is 12, not 9. $xR[8] = "ge"; doesn't do any increment. It just says to store the value of "ge" at index 8. You can run $xR[8] = "ge"; 100 times and it won't change the index because that's just replacing a value.

     

     

    [3] => "ar"

    [4] => "br"

    [6] => "cr"

    [7] => "de"

    [10] => "en"

    [11] => "fr"

    [8] => "ge"

    [12] => "hr"

     

     

  6. I don't see why I can modify my profile, signature, avatar to my liking but not my username.

    It's pretty simple actually.  If you're allowed to change your name, then everyone else is going to want to change theirs too. 

     

    It's just like your mailing address or telephone number... or PO Box #.  You can't just up and say "Hey, I'd like my digits to be 123 instead of 56185145486156-2" (Assuming 123 just happened to be available)  Even if you argue against that and say "Yes you can!?".. You'd still have to sacrifice some money for that actual change to happen.  There's no merit badge privilege out there that awards you those changes for free. 

    [ot]Unless your in witness protection, but then still you have no real say so in the digits you get.[/ot]

    I did make the case to allow certain members the right to change it, like the Supporter group or those who are active, helpful, etc. Not newcomers with 1 to 2 posts.

     

    Also, it's just like already mentioned.  If you changed your username (and everyone else too), then who would know who is who around here?

    How would the mods keep track of the new-coming spammers easily?

    How would the freelancers keep an eye out for their clients that are online; and vice versa?

    How would a person know who to say "thank you" to, when their problem is finally solved?

    1. How many people would care? If I ask a question, I'd post it up on the forum. Whoever answers it, answers it. I can't PM anyone for help according to the rules, so there's no need for me or anyone else to keep track. Many forums allow their members to change their username. I don't see them having issues with this.

     

    2. New-comers should not have the privilege.

     

    3. You can hide your online status anyways. That doesn't do anything. Clients usually get PMed by the freelancer. Assuming the DB is set up correctly, they can view the PM if they haven't deleted it. But then again, if you're the freelancer and you changed your name without telling the client, that's the freelancer's fault and the client has the right to go somewhere else. Obviously the freelancer doesn't care about the client enough to mention it or even possibly take the job seriously enough.

     

    4. Well, assuming the DB is set up correctly, the name in the posts should change. That's not a problem.

  7. Well, it's kind of dumb the way you did it. The call_images.php will select from people and you loop through to display the image. Problem is, you didn't specify which one in your SQL so it will grab them all and since your while loop exits after the first iteration, it will always print the first image.

     

    Since you're passing the file path to the call_images.php, why aren't you using it? The path is right there. There's no need to run a query.

     

    I agree with Muddy_Funster that you shouldn't select * from your database table, unless the table only has 2 columns lol.

     

    couple of things to try.

    [*]Stop selecting * from your databases (you get this one for free - especialy when you use it on two pages right after each other  :P

    [*]mysql_fetch_array[''] returns a numeric header for each row.  Use mysql_fetch_assoc[''] to use associated table filed headers.

    1. Select from tables, not databases.

    2. mysql_fetch_array returns both if the optional parameter is not passed to specify the type.

  8. Unquote the input variable.  You have it showing as '17' which tells MySQL that it's a sting.  when you try to compare a sring to a numeric field value it get's upset.

     

    You should only quote string field variables (varchar, text, enum etc) and never quote numeric (int, float, decimal etc).

    You forgot to mention MySQL database/table/column names or MySQL keywords. Don't quote those either. I've seen many people do that.

  9. I wonder if this will work:

     

    UPDATE members SET last_report_n = CONCAT_WS('-', RIGHT(last_pirep, 4), LEFT(last_pirep, 2), RIGHT(LEFT(last_pirep, LOCATE('.', last_pirep, 3), 2));

  10. So if it's mm.dd.yyyy, chop it up into yyyy-mm-dd. What's confusing about it? =\

     

    <?php
    
    $get = mysql_query("SELECT id, `last_pirep` FROM members");
    while($row = mysql_fetch_assoc($get)){
    
    $id = $row['id'];
    $od = str_replace('.', '-', strrev($row['last_pirep']));
    
    mysql_query("UPDATE members SET last_report_n='" . $od . "' WHERE id = " . $id . " LIMIT 1");
    
    }
    
    echo'UPDATED Sucessfully!'
    
    ?>

    That would be backwards lol, well the values that is.

  11. The rule was put in place so there is no doubt who everybody is. Other people have no chance of knowing who is who if people change their names all the time. Certainly the fact that you've been around for a while would speak against changing your username because you have a reputation as opposed to someone with just one or two posts.

    I created this account back when I was new to PHP and was learning for the first time. I just picked the first thing that came to mind just to get in and ask a question. But being around here and having loved this place for a long time, I'd like to change my username to something I'd like. Ken2k7 doesn't sound too fitting lol.

     

    And this name change should not be available to those who have one or two posts.

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