Zikula: A Flexible Open Source Content Management System
home | forum | contact us

Dizkus

Bottom
add user to table
  • Posted: 08.01.2006, 07:33
     
    cannibus
    rank:
    Helper Helper
    registered:
     November 2004
    Status:
    offline
    last visit:
    20.09.08
    Posts:
    401
    the table and column names wont come up, any help?



    Code

    // Get datbase setup - note that both pnDBGetConn() and pnDBGetTables()
        // return arrays but we handle them differently.  For pnDBGetConn()
        // we currently just want the first item, which is the official
        // database handle.  For pnDBGetTables() we want to keep the entire
        // tables array together for easy reference later on
        $dbconn =& pnDBGetConn(true);
        $pntable =& pnDBGetTables();

        // It's good practice to name the table and column definitions you
        // are getting - $table and $column don't cut it in more complex
        // modules
        $approvaltable = &$pntable['approval'];
        $approvalcolumn = &$pntable['approval_column'];
        $userstable = $pntable[users];
        $userscolumn = &$pntable['users_column'];
        $grouptable = &$pntable['group'];
        $groupcolumn = &$pntable['group_column'];

        // All variables that come in to or go out of PostNuke should be handled
        // by the relevant pnVar*() functions to ensure that they are safe.
        // Failure to do this could result in opening security wholes at either
        // the web, filesystem, display, or database layers.
        list($gid, $uid) = pnVarPrepForStore($gid, $uid);


        // Get next ID in table - this is required prior to any insert that
        // uses a unique ID, and ensures that the ID generation is carried
        // out in a database-portable fashion
        $userid = $dbconn->GenId($usertable);

        $sql = "INSERT INTO $usertable ($usercolumn[name],
    $usercolumn[uname],
    $usercolumn[email],
    $usercolumn[femail],
    $usercolumn[url],
    $usercolumn[user_avatar],
    $usercolumn[user_regdate],
    $usercolumn[user_icq],
    $usercolumn[user_occ],
    $usercolumn[user_from],
    $usercolumn[user_intrest],
    $usercolumn[user_sig],
    $usercolumn[user_viewemail],
    $usercolumn[user_theme],
    $usercolumn[user_aim],
    $usercolumn[user_yim],
    $usercolumn[user_msnm],
    $usercolumn[pass],
    $usercolumn[storynum],
    $usercolumn[umode],
    $usercolumn[uorder],
    $usercolumn[thold],
    $usercolumn[noscore],
    $usercolumn[bio],
    $usercolumn[ublockon],
    $usercolumn[ublock],
    $usercolumn[theme],
    $usercolumn[commentmax],
    $usercolumn[counter],
    $usercolumn[timezone_offset])
                               VALUES ('"
    . pnVarPrepForStore($item[name]) . "',
    '"
    . pnVarPrepForStore($item[uname]) . "',
    '"
    . pnVarPrepForStore($item[email]) . "',
    '"
    . pnVarPrepForStore($item[femail]) . "',
    '"
    . pnVarPrepForStore($item[url]) . "',
    '"
    . pnVarPrepForStore($item[user_avatar]) . "',
    '"
    . pnVarPrepForStore($item[user_regdate]) . "',
    '"
    . pnVarPrepForStore($item[user_icq]) . "',
    '"
    . pnVarPrepForStore($item[user_occ]) . "',
    '"
    . pnVarPrepForStore($item[user_from]) . "',
    '"
    . pnVarPrepForStore($item[user_intrest]) . "',
    '"
    . pnVarPrepForStore($item[user_sig]) . "',
    '"
    . pnVarPrepForStore($item[user_viewemail]) . "',
    '',
    '"
    . pnVarPrepForStore($item[user_aim]) . "',
    '"
    . pnVarPrepForStore($item[user_yim]) . "',
    '"
    . pnVarPrepForStore($item[user_msnm]) . "',
    '"
    . pnVarPrepForStore($item[pass]) . "',
    '"
    . pnVarPrepForStore($item[storynum]) . "',
    '',
    0,
    0,
    0,
    '"
    . pnVarPrepForStore($item[bio]) . "',
    0,
    '',
    '',
    '"
    . pnVarPrepForStore($item[commentlimit]) . "',
    '0',
    '"
    . pnVarPrepForStore($item[timezoneoffset]) . "')";
    print_r($sql);
    die;
        $dbconn->Execute($sql);

        // Check for an error with the database code, and if so set an
        // appropriate error message and return
        if ($dbconn->ErrorNo() != 0) {
            pnSessionSetVar('errormsg', _CREATEFAILED);
            return false;
        }
  • Posted: 08.01.2006, 16:17
     
    ainigma32
    rank:
    Professional Professional
    registered:
     January 2004
    Status:
    offline
    last visit:
    22.03.06
    Posts:
    958
    It's a typo

    Code

    $userstable = $pntable[users];
    and

    Code

    $userid = $dbconn->GenId($usertable);
    Note the missing s in $usertable
  • Posted: 08.01.2006, 21:09
     
    Topiatic
    rank:
    Professional Professional
    registered:
     November 2003
    Status:
    offline
    last visit:
    23.11.08
    Posts:
    1677
    And don't stop there... it happens again.

    --
    Under Construction!
  • Posted: 09.01.2006, 10:51
     
    cannibus
    rank:
    Helper Helper
    registered:
     November 2004
    Status:
    offline
    last visit:
    20.09.08
    Posts:
    401
    never even see dat.

Extensions Moderation

Main Menu

Extensions Database

Documentation

Development

Login

Donate to Zikula