Insert data into php

Discussion in 'PHP' started by er1cw, Sep 28, 2006.

  1. #1
    Hi,

    I have a script that look like this

    
    <? 
    $ACC=user1;
    $PASS=pass1;	?>
    PHP:
    I would like the system randomly choose user2, user3, user4, etc.. into $ACC and also pass2, pass3, pass4, etc.. into $PASS at the same time. May i know how can i do that ?
     
    er1cw, Sep 28, 2006 IP
  2. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #2
    mad4, Sep 28, 2006 IP
  3. er1cw

    er1cw Peon

    Messages:
    114
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Erm, i don thinkg that's what i want. How can i match pass1 to user1 and pass2 to user2 and etc etc.. while the system will pick $ACC by random ?
     
    er1cw, Sep 28, 2006 IP
  4. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Just call rand once, store it in a variable and use that variable, instead.

    Something like:
    $random_number = rand();
    $acc = 'user' . $random_number;
    $pass = 'pass' . $random_number;

    Be sure to start using quotes around your strings... you'll end up in a world of strange bugs if you don't.
     
    TwistMyArm, Sep 28, 2006 IP
  5. er1cw

    er1cw Peon

    Messages:
    114
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    K. thanks.. it helps
     
    er1cw, Sep 28, 2006 IP