Fork me on GitHub

Creates new row but no info in it.  Bottom

  • I dunno what I have done wrong here... When I try to add a new item, a new row is created but there is no info in it.

    When I print_r($args) in the beginning of the _create file i get;
    Array ( [categoryid] => [parentstoryid] => [title] => [summary] => [story] => [ratingid] => [image] => [char1] => [char2] => [genre] => [author] => [email] => [date] => [updated] => [roundrobin] => [unvalidated] => [counter] => [keywords] => )

    Where should I check for error?
  • You can print_r() at various points in the module. Just follow the progression of the data with print_r()...that should help determine where the data is being lost. Without the code, that's about all one could say.
  • Here is the code.. I'm so sick of this problem now cry cry

    function Writer_stories_create($args)
    {

    list($categoryid,
    $parentstoryid,
    $title,
    $summary,
    $story,
    $ratingid,
    $image,
    $char1,
    $char2,
    $genre,
    $author,
    $email,
    $date,
    $updated,
    $roundrobin,
    $unvalidated,
    $counter,
    $keywords) = pnVarPrepForStore($categoryid,
    $parentstoryid,
    $title,
    $summary,
    $story,
    $ratingid,
    $image,
    $char1,
    $char2,
    $genre,
    $author,
    $email,
    $date,
    $updated,
    $roundrobin,
    $unvalidated,
    $counter,
    $keywords );

    extract($args);

    if (!pnSecConfirmAuthKey()) {
    pnSessionSetVar('errormsg', pnVarPrepHTMLDisplay(_BADAUTHKEY));
    pnRedirect(pnModURL('Writer', 'stories', 'view'));
    return true;
    }

    if (!pnModAPILoad('Writer', 'stories')) {
    pnSessionSetVar('errormsg', pnVarPrepHTMLDisplay(_LOADFAILED11));
    pnRedirect(pnModURL('Writer', 'stories', 'view'));
    return true;
    }

    $storyid = pnModAPIFunc('Writer',
    'stories',
    'create',
    array('categoryid' => $categoryid,
    'parentstoryid' => $parentstoryid,
    'title' => $title,
    'summary' => $summary,
    'story' => $story,
    'ratingid' => $ratingid,
    'image' => $image,
    'char1' => $char1,
    'char2' => $char2,
    'genre' => $genre,
    'author' => $author,
    'email' => $email,
    'date' => $date,
    'updated' => $updated,
    'roundrobin' => $roundrobin,
    'unvalidated' => $unvalidated,
    'counter' => $counter,
    'keywords' => $keywords));

    if ($storyid) {
    // Success
    pnSessionSetVar('statusmsg', pnVarPrepHTMLDisplay(_EXAMPLECREATED));
    }

    // This function generated no output, and so now it is complete we redirect
    // the user to an appropriate page for them to carry on their work
    pnRedirect(pnModURL('Writer', 'stories', 'view'));

    // Return
    return true;
    }

    __________________________________________________

    function Writer_storiesapi_create($args)
    {

    extract($args);

    // Argument check - make sure that all required arguments are present,
    // if not then set an appropriate error message and return
    if ((!isset($categoryid)) ||
    (!isset($parentstoryid)) ||
    (!isset($title)) ||
    (!isset($summary)) ||
    (!isset($story)) ||
    (!isset($ratingid)) ||
    (!isset($image)) ||
    (!isset($char1)) ||
    (!isset($char2)) ||
    (!isset($genre)) ||
    (!isset($author)) ||
    (!isset($email)) ||
    (!isset($date)) ||
    (!isset($updated)) ||
    (!isset($roundrobin)) ||
    (!isset($unvalidated)) ||
    (!isset($counter)) ||
    (!isset($keywords))) {
    /*(isset($categoryid) && !is_numeric($categoryid)) ||
    (isset($parentstoryid) && !is_numeric($parentstoryid)) ||
    (isset($ratingid) && !is_numeric($ratingid)) ||
    (isset($roundrobin) && !is_numeric($roundrobin)) ||
    (($unvalidated) && !is_numeric($unvalidated)) ||
    (isset($counter) && !is_numeric($counter))) */
    pnSessionSetVar('errormsg', _MODARGSERROR1);
    return false;
    }

    if (!pnSecAuthAction(0, 'Writer::', "$categoryid::", ACCESS_ADD)) {
    pnSessionSetVar('errormsg', _MODULENOAUTH);
    return false;
    }

    $dbconn =& pnDBGetConn(true);
    $pntable =& pnDBGetTables();

    $Storiestable =&$pntable['writer_stories'];
    $Storiescolumn =&$pntable['writer_stories_column'];

    $nextId = $dbconn->GenId($Storiestable);

    list($categoryid,
    $parentstoryid,
    $title,
    $summary,
    $story,
    $ratingid,
    $image,
    $char1,
    $char2,
    $genre,
    $author,
    $email,
    $date,
    $updated,
    $roundrobin,
    $unvalidated,
    $counter,
    $keywords) = pnVarPrepForStore($categoryid,
    $parentstoryid,
    $title,
    $summary,
    $story,
    $image,
    $ratingid,
    $char1,
    $char2,
    $genre,
    $author,
    $email,
    $updated,
    $roundrobin,
    $unvalidated,
    $counter,
    $keywords);

    $SQL = "INSERT INTO $Storiestable (
    $Storiescolumn[storyid],
    $Storiescolumn[categoryid],
    $Storiescolumn[parentstoryid],
    $Storiescolumn[title],
    $Storiescolumn[summary],
    $Storiescolumn[story],
    $Storiescolumn[image],
    $Storiescolumn[ratingid],
    $Storiescolumn[char1],
    $Storiescolumn[char2],
    $Storiescolumn[genre],
    $Storiescolumn[author],
    $Storiescolumn[email],
    $Storiescolumn[updated],
    $Storiescolumn[roundrobin],
    $Storiescolumn[unvalidated],
    $Storiescolumn[counter],
    $Storiescolumn[keywords])
    VALUES (
    '".(int)$nextId."',
    '".(int)$categoryid."',
    '".(int)$parentstoryid."',
    '".$title."',
    '".$summary."',
    '".$story."',
    '".$image."',
    '".$ratingid."',
    '".$char1."',
    '".$char2."',
    '".$genre."',
    '".$author."',
    '".$email."',
    '".$updated."',
    '".(int)$roundrobin."',
    '".(int)$unvalidated."',
    '".(int)$counter."',
    '".$keywords."'
    )";

    $dbconn->Execute($SQL);

    if ($dbconn->ErrorNo() != 0) {
    pnSessionSetVar('errormsg', _EXAMPLECREATEFAILED);
    return false;
    }

    $storyid = $dbconn->PO_Insert_ID($Storiestable, $Storiescolumn['storyid']);

    pnModCallHooks('item', 'create', $storyid, 'storyid');

    return $storyid;
    }
    cry cry
  • i been error checking all weekend heheheh




    from the way you describe your problem the first place i would check is the SQL statement.



    print_r($SQL);
    die;


    right below the statement, and then run whe output in phpMyAdmin.

This list is based on users active over the last 60 minutes.