Call to undefined function: query()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • muelli75

    Call to undefined function: query()

    Hi!

    Im getting insane by solving a problem ....

    I try to define a function which uses a code-snippet from another file.
    My base are the codes from the great book "WebDataBas e-Book by H.
    Williams & D. Lane".

    So I try to use


    $result = $connection->query("LOCK TABLES visitkarte WRITE");
    if(DB::isError( $result))
    trigger_error($ result->getMessage() , E_USER_ERROR);


    which works in another .inc very fine.

    Look at my .inc for the function VKDataInDB



    <?php
    require_once "db.inc";
    require_once "DB.php";
    require_once "authenticate.i nc";
    require_once "visitsontheweb .inc";

    // Dieser Errorhandler ist extrem gefährlich da er das root-passwort
    der DB ausgibt!
    //set_error_handl er("customHandl er");

    function VKDataInDB(&$co nnection)
    {
    //Book Page 641

    $connection=DB: :connect($dsn, true);
    $cust_id=getCus t_id($_SESSION["loginUsern ame"]);

    // Lock Table -- 636
    $result = $connection->query("LOCK TABLES visitkarte WRITE");
    if(DB::isError( $result))
    trigger_error($ result->getMessage() , E_USER_ERROR);

    //Query for the highest ID
    $result = $connection->query("SELEC T max(vk_id) FROM visitkarte");
    if (DB::isError($r esult))
    trigger_error($ result->getMessage() , E_USER_ERROR);
    $row = $result->fetchRow(DB_FE TCHMODE_ASSOC);

    // Die nächste verfügbare vk_id errechnen
    $vk_id = $row["max(vk_id) "] + 1;

    //selbst erstellt
    $sql = "INSERT INTO visitkarte cust_id = '{$cust_id}',
    vk_id = '{$vk_id}',
    erstelldatum = NOW(),
    sessionid = '{SID}',
    vorname = '{$_SESSION['vorname']}',
    nachname = '{$_SESSION['nachname']}',
    titel = (),
    plz ='{$_SESSION['plz']}',
    ort ='{$_SESSION['ort']}',
    tel1 ={$_SESSION['telefonnummer']},
    mobil=(),
    strasse={$_SESS ION['strasse']},
    homepage=(),
    email={$_SESSIO N['email']},
    kategorie={$_SE SSION['kategorie']},
    hintergrund=(1) ,
    ";

    //Write data
    mysql_query ($sql) or mysql_error();

    // Unlock tables
    $result=$connec tion->query("UNLOC K TABLES");
    if(DB::isError( $result))
    trigger_error($ result->getMessage() , E_USER_ERROR);

    }
    ?>


    When I call this include.file, i get the following error:

    Fatal error: Call to undefined function: query() in
    /raid-1/APACHE/hausstein/www/visits/includes/vkdbfunc.inc on line 18

    OK, I havent defined "query" in my .incs, but why works it on another
    place? And why must I declare the variable "$connectio n" when I dont
    have to do it on another place.
    My "require"-section is extended like in the basefiles form the book.

    Questions enough for many answers!

    Thanks in advance,

    Martin

  • Kirsten

    #2
    Re: Call to undefined function: query()

    muelli75 schrieb:[color=blue]
    > Hi!
    >
    > Im getting insane by solving a problem ....
    >
    > I try to define a function which uses a code-snippet from another file.
    > My base are the codes from the great book "WebDataBas e-Book by H.
    > Williams & D. Lane".
    >
    > So I try to use
    >
    >
    > $result = $connection->query("LOCK TABLES visitkarte WRITE");
    > if(DB::isError( $result))
    > trigger_error($ result->getMessage() , E_USER_ERROR);
    >
    >
    > which works in another .inc very fine.
    >
    > Look at my .inc for the function VKDataInDB
    >
    >
    >
    > <?php
    > require_once "db.inc";
    > require_once "DB.php";
    > require_once "authenticate.i nc";
    > require_once "visitsontheweb .inc";
    >
    > // Dieser Errorhandler ist extrem gefährlich da er das root-passwort
    > der DB ausgibt!
    > //set_error_handl er("customHandl er");
    >
    > function VKDataInDB(&$co nnection)
    > {
    > //Book Page 641
    >
    > $connection=DB: :connect($dsn, true);
    > $cust_id=getCus t_id($_SESSION["loginUsern ame"]);
    >
    > // Lock Table -- 636
    > $result = $connection->query("LOCK TABLES visitkarte WRITE");
    > if(DB::isError( $result))
    > trigger_error($ result->getMessage() , E_USER_ERROR);
    >
    > //Query for the highest ID
    > $result = $connection->query("SELEC T max(vk_id) FROM visitkarte");
    > if (DB::isError($r esult))
    > trigger_error($ result->getMessage() , E_USER_ERROR);
    > $row = $result->fetchRow(DB_FE TCHMODE_ASSOC);
    >
    > // Die nächste verfügbare vk_id errechnen
    > $vk_id = $row["max(vk_id) "] + 1;
    >
    > //selbst erstellt
    > $sql = "INSERT INTO visitkarte cust_id = '{$cust_id}',
    > vk_id = '{$vk_id}',
    > erstelldatum = NOW(),
    > sessionid = '{SID}',
    > vorname = '{$_SESSION['vorname']}',
    > nachname = '{$_SESSION['nachname']}',
    > titel = (),
    > plz ='{$_SESSION['plz']}',
    > ort ='{$_SESSION['ort']}',
    > tel1 ={$_SESSION['telefonnummer']},
    > mobil=(),
    > strasse={$_SESS ION['strasse']},
    > homepage=(),
    > email={$_SESSIO N['email']},
    > kategorie={$_SE SSION['kategorie']},
    > hintergrund=(1) ,
    > ";
    >
    > //Write data
    > mysql_query ($sql) or mysql_error();
    >
    > // Unlock tables
    > $result=$connec tion->query("UNLOC K TABLES");
    > if(DB::isError( $result))
    > trigger_error($ result->getMessage() , E_USER_ERROR);
    >
    > }
    > ?>
    >
    >
    > When I call this include.file, i get the following error:
    >
    > Fatal error: Call to undefined function: query() in
    > /raid-1/APACHE/hausstein/www/visits/includes/vkdbfunc.inc on line 18
    >
    > OK, I havent defined "query" in my .incs, but why works it on another
    > place? And why must I declare the variable "$connectio n" when I dont
    > have to do it on another place.
    > My "require"-section is extended like in the basefiles form the book.
    >
    > Questions enough for many answers!
    >
    > Thanks in advance,
    >
    > Martin
    >[/color]
    Hi,

    auch wenns Deutsch ginge ;)

    Try to replace $result->getMessage() with $result->getDebugInfo ()
    and see a better error discription.

    -Kirsten

    Comment

    Working...