SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Guru laflair13's Avatar
    Join Date
    Nov 2004
    Location
    TN
    Posts
    629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting error message.

    I am getting these messages and cant figure out the problem


    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/sexx/public_html/gen_users/gen_users.php on line 81

    Fatal error: Call to undefined function: template() in /home/sexx/public_html/gen_users/gen_users.php on line 113

    Code looks like this

    PHP Code:
    $tmp=mysql_fetch_array(mysql_query("Select Max(id) as maxid from ".C_MYSQL_MEMBERS_MAIN));
    $next_id=$tmp['maxid']+1;
    $need_id=$next_id+USERS_NUMBER;
    for(
    $i=$next_id;$i<=$need_id;$i++)
    {
        
    srand ((float) microtime() * 10000000);
        
    $rma=array_rand ($male_array);
        
    $rfa=array_rand ($female_array);
        
    $rsa=array_rand ($surname_array);
        
    $year=rand(YEAR_FROM,YEAR_TO);
        
    $age=date("Y") - $year;                           
        
    $month=rand(1,12);
        
    $day=rand(1,28);
        
    $gender=rand(1,2);
        
    $sgender =  ($gender == 1)? 1;

        
    $usr= ($gender == 1) ? ucfirst($male_array[$rma]).$i ucfirst($female_array[$rfa]).$i;
        
    $fname = ($gender == 1) ? ucfirst($male_array[$rma]) : ucfirst($female_array[$rfa]);
        
    $height = ($gender == 1) ? rand(12,19) : rand(7,17);
        
    $weight $height 2// Aprox. value :)
        
    $lname=ucfirst($surname_array[$rsa]);
        
    $purpose=rand(1,4);
        
    $country=rand(1,150);
        
    $picture=rand(1,C_PICS*C_PICS_PROB);
        
    $rate = (C_DEF_RATE) ? 0;
        
    $descr_array=array(
        
    'FNAME'=>$fname,
        
    'LNAME'=>$lname,
        
    'COUNTRY'=>$wcr[$country],
        
    'AGE'=>$age,
        
    'SGENDER'=>$wg[$sgender]
        );
        
    $descr template(DESCR,$descr_array);
        
    $pic=($picture C_PICS) ? '' '0'
    Any help would be appreciated.

    Thanks in advance
    Thanks In Advance

    David

  2. #2
    SitePoint Evangelist LemoNade's Avatar
    Join Date
    Aug 2005
    Location
    Southampton, UK
    Posts
    500
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To get rid of the first error, change the top line to the following 2 lines:

    PHP Code:
     $tmp mysql_query("Select Max(id) as maxid from ".C_MYSQL_MEMBERS_MAIN);
    $tmp mysql_fetch_array($tmp); 
    Unfortunately you cannot nest a mysql_query call inside a mysql_fetch_array call.

    I'm not sure about the template error though.

    Hope this helps,

    -Will

  3. #3
    SitePoint Guru laflair13's Avatar
    Join Date
    Nov 2004
    Location
    TN
    Posts
    629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright. I fixed the first error. but still getting this one


    Fatal error: Call to undefined function: template() in /home/sexx/public_html/gen_users/gen_users.php on line 112
    Thanks In Advance

    David

  4. #4
    SitePoint Wizard silver trophy Jelena's Avatar
    Join Date
    Feb 2005
    Location
    Universum, 3rd Corner
    Posts
    3,000
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Are you sure you included the file that has function template in the above file?
    -- Jelena --

  5. #5
    SitePoint Guru laflair13's Avatar
    Join Date
    Nov 2004
    Location
    TN
    Posts
    629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just figured that out. No I am getting no database selected.


    PHP Code:
    <?php
    ############################################################
    # \-\-\-\-\-\-\     AzDG  - S C R I P T S    /-/-/-/-/-/-/ #
    ############################################################
    # AzDGDatingPlatinum      Version 1.6.3                    #
    # Written by              AzDG (support@azdg.com)          #
    # Created 24/10/02        Last Modified 24/10/02           #
    # Scripts Home:           http://www.azdg.com              #
    ############################################################
    # File name               gen_users.php                    #
    # File purpose            Generate unreal users            #
    # File created by         AzDG <support@azdg.com>          #
    ############################################################

    //MySQL database settings 
    $db_host "localhost";  //default: localhost
    $db_name "sexx_hunt";
    $db_login ="sexx_admin";
    $db_pswd "mammaw";
    ############# Edit your users #############

    # Users number to generate - do not recommend to generate more than 100000 users
    define('USERS_NUMBER','100');

    # Year from - birthday
    define('YEAR_FROM','1960');

    # Year to - birthday
    define('YEAR_TO','1987');

    # Male Names divide by comma
    define('MALE_NAMES','adam,adrian,alan,albert,alex,anthony,arman,bartram,benedict,bernard,bill,billie,bobby,bradford,calvin,carl,dan,denny,derrick,edd,eric,ferdinand,frank,frederic,garold,george,gerry,gilbert,gustaf,howard,jason,jimmy,jo,johnathan,johny,jon,kean,kristofer,lambert,leonard,malvin,matias,michael,poul,ralf,robert,sam,sebastien,spence,teddy,victor');

    # Female Names divide by comma
    define('FEMALE_NAMES','adelina,adriana,albina,alexandra,alice,alison,amanda,angela,ania,anna,ashely,avril,bella,bridget,britney,carey,carol,catherin,christina,daisy,deborah,dona,elena,emmy,ester,feodora,gabriela,ginni,isabel,jasmin,joan,juliana,juliet,kassandra,ketty,lara,linda,margaret,meagan,miranda,nichole,paola,raychel,rosanna,sandra,sherilyn,stephanie,vanessa,violetta');

    # Surnames divide by comma
    define('SURNAMES','crawford,harrison,harwell,davidson,anderson,marietty,lambert,edmon,edwardson,edwinson,martin,clide,bright,stevenson,johnson,mayson,smitt,taker,abraham,addison,jackson,chesterton,alan,miln,trevers,barri,darrel,drizer,lindgren,james,osbourne,rourke,willis,broston,terner,smitt,adams,hopkins,pitt');

    # Description
    define('DESCR',
    '
    Hello all. My name is {FNAME} {LNAME}.<BR>
    I`m living in the {COUNTRY}.<BR>
    <BR>
    I`m {AGE} years old.<BR>
    <BR>
    I want to find honest and decent {SGENDER} in the {COUNTRY} or any another country.<BR>
    <BR>
    Good luck! :)'
    );

    # Password for all users
    define('PASSWORD','123456');

    # Email for all users
    define('MAIL','nospam@mail.com');

    # How many pictures for each gender you have? By default - 50 for each gender
    define('C_PICS','50');

    # Probability of user have photo, by default each 3-rd user have photo, set it to 1 and each user will have photo, but it will increase your disk size
    define('C_PICS_PROB','3');


    ################################################
    ### Program Part - Do not edit anything here ###
    ################################################


    $male_array=explode(',',MALE_NAMES);
    $female_array=explode(',',FEMALE_NAMES);
    $surname_array=explode(',',SURNAMES);

    function 
    gen($char1,$char2,$count)
    {
        
    $gen preg_replace("/(.)/e""chr(rand(ord('".$char1."'),ord('".$char2."')))"str_repeat('.'$count));
        return 
    $gen;
    }

    set_time_limit(0);
    $pass=PASSWORD;
    $email=MAIL;
    $city='';
    $tmp mysql_query("Select Max(id) as maxid from ".C_MYSQL_MEMBERS_MAIN); 
    $need_id=$next_id+USERS_NUMBER;
    for(
    $i=$next_id;$i<=$need_id;$i++)
    {
        
    srand ((float) microtime() * 10000000);
        
    $rma=array_rand ($male_array);
        
    $rfa=array_rand ($female_array);
        
    $rsa=array_rand ($surname_array);
        
    $year=rand(YEAR_FROM,YEAR_TO);
        
    $age=date("Y") - $year;                           
        
    $month=rand(1,12);
        
    $day=rand(1,28);
        
    $gender=rand(1,2);
        
    $sgender =  ($gender == 1)? 1;

        
    $usr= ($gender == 1) ? ucfirst($male_array[$rma]).$i ucfirst($female_array[$rfa]).$i;
        
    $fname = ($gender == 1) ? ucfirst($male_array[$rma]) : ucfirst($female_array[$rfa]);
        
    $height = ($gender == 1) ? rand(12,19) : rand(7,17);
        
    $weight $height 2// Aprox. value :)
        
    $lname=ucfirst($surname_array[$rsa]);
        
    $purpose=rand(1,4);
        
    $country=rand(1,150);
        
    $picture=rand(1,C_PICS*C_PICS_PROB);
        
    $rate = (C_DEF_RATE) ? 0;
        
    $descr_array=array(
        
    'FNAME'=>$fname,
        
    'LNAME'=>$lname,
        
    'COUNTRY'=>$wcr[$country],
        
    'AGE'=>$age,
        
    'SGENDER'=>$wg[$sgender]
        );

        
    $pic=($picture C_PICS) ? '' '0';
        
    $picture=($picture C_PICS) ? '' $gender '_' $picture '.jpg';
                
    mysql_query("INSERT INTO ".C_MYSQL_MEMBERS_MAIN." VALUES ('', '".$usr."','".$fname."','".$lname."','".$year."-".$month."-".$day."','".$gender."','".$purpose."','".$country."','".$city."','".$height."','".$weight."','".$sgender."','".$pic."',NOW(''),NOW(''),'".$rate."','0','0','7','0')") or die(mysql_error());
            
    $last_id mysql_fetch_array(mysql_query("SELECT LAST_INSERT_ID() AS last_id"));
            
    $last_id $last_id['last_id'];
            
            
    mysql_query("INSERT INTO ".C_MYSQL_MEMBERS_EXT." VALUES ('".$last_id ."','','','','','','','0','0','0','0','0','0','0','0','','','','','','".$descr."','0','0','0','0','0','0','0','0','0','0','18','50','1','22','1','44','0','','7')") or die(mysql_error());
            
    mysql_query("INSERT INTO ".C_MYSQL_MEMBERS_SEC." VALUES ('".$last_id ."','".$pass."','".$email."','".ip2int(ip())."','0','7')") or die(mysql_error());
            
    $newpath id2path($last_id);
            if(
    $pic == '0') @copy(C_PATH.'/addons/photos/'.$picture,C_PATH.'/members/uploads/'.$newpath.'0');

    }
    printm("Users from ID=".$next_id." to ID=".$need_id." have been generated.<BR><BR>Remove this addon for security reasons.",2);
    include_once 
    C_PATH.'/footer.php';
    ?>
    Thats strange
    Thanks In Advance

    David

  6. #6
    SitePoint Wizard silver trophy Jelena's Avatar
    Join Date
    Feb 2005
    Location
    Universum, 3rd Corner
    Posts
    3,000
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I don't see anywhere that you connect and select database.

    Add something like this after MySQL database settings.
    PHP Code:
    if(!($db = @mysql_pconnect($db_host$db_login$db_pass)))
        die(
    "Cannot connect to the base server.");
    if(!@
    mysql_select_db($db_name$db))
        die(
    "Database doesn't exist!!!"); 
    -- Jelena --

  7. #7
    SitePoint Guru laflair13's Avatar
    Join Date
    Nov 2004
    Location
    TN
    Posts
    629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Almost..I am getting this now

    Cannot connect to the base server.
    Thanks In Advance

    David

  8. #8
    SitePoint Guru laflair13's Avatar
    Join Date
    Nov 2004
    Location
    TN
    Posts
    629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking

    Quote Originally Posted by laflair13
    Almost..I am getting this now

    Cannot connect to the base server.
    Nevermind. I failed to realize I had to fill in the blanks. Good thing for that php for dummies..

    But I am getting database doesnt exist?
    Thanks In Advance

    David

  9. #9
    SitePoint Guru laflair13's Avatar
    Join Date
    Nov 2004
    Location
    TN
    Posts
    629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by laflair13
    Nevermind. I failed to realize I had to fill in the blanks. Good thing for that php for dummies..

    But I am getting database doesnt exist?

    I am so lost...

    Column count doesn't match value count at row 1

    Don't even know what that is?
    Thanks In Advance

    David

  10. #10
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    that error is produced when the number of fields you are trying to insert doesn't match the nuber of fields in the database table.

    Carefully count the number of '','','','' you have in your lines to make sure they match the number of fields.

    Cheers

    Spike
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •