Fork me on GitHub

How to run this DB query with PostNuke DB  Bottom

  • Hi

    How I could run this to add the jokes into PostNuke DB and pnjokes table?
    IF the PN DB is named say Phoenix and the pnjoke stable: nuke_pnjokes_jokes???

    TIA

    Quote



    $SQL = "INSERT INTO $jokestable VALUES ('', 'youngstoorie', 'youngstoorie@hotmail.com', '', 4, 'Blonde in bla bla bla....

    BLA... BLA... BLA...

    $dbconn->Execute($SQL);
    if ($dbconn->ErrorNo() != 0) {
    echo '<font color="#FF0000"> >>> FAILED' . mysql_error() . '

    ';
    pnjokes_fail();
    return false;
    }else{
    echo '<font color="#008000"> >>> COMPLETED';
    }



    TIA
  • You usually need to say:
    $SQL = "INSERT INTO $jokestable (first_field, second_field, third_field) VALUES ('first value', 'second value' third value')";

    Obviously substituting first_field, etc with the actual field names. I don't know anything about the jokes module but if it is an API compliant module then the above code still isn't what should be used. Take a look at the Example module for an example of the API compliant way.

    Another way is to say:
    $SQL = "INSERT INTO $jokestable SET first_field='first value', second_field='second_value', third_field='third_value'";

    I prefer the second method because then it is immediately obvious which fields are getting set with which values.

    Hope that helps.
    -Chris

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