By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,667 Members | 2,084 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,667 IT Pros & Developers. It's quick & easy.

Call to undefined function: query()

P: n/a
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 "WebDataBase-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.inc";
require_once "visitsontheweb.inc";

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

function VKDataInDB(&$connection)
{
//Book Page 641

$connection=DB::connect($dsn, true);
$cust_id=getCust_id($_SESSION["loginUsername"]);

// 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("SELECT max(vk_id) FROM visitkarte");
if (DB::isError($result))
trigger_error($result->getMessage(), E_USER_ERROR);
$row = $result->fetchRow(DB_FETCHMODE_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={$_SESSION['strasse']},
homepage=(),
email={$_SESSION['email']},
kategorie={$_SESSION['kategorie']},
hintergrund=(1),
";

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

// Unlock tables
$result=$connection->query("UNLOCK 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 "$connection" 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

Sep 28 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
muelli75 schrieb:
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 "WebDataBase-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.inc";
require_once "visitsontheweb.inc";

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

function VKDataInDB(&$connection)
{
//Book Page 641

$connection=DB::connect($dsn, true);
$cust_id=getCust_id($_SESSION["loginUsername"]);

// 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("SELECT max(vk_id) FROM visitkarte");
if (DB::isError($result))
trigger_error($result->getMessage(), E_USER_ERROR);
$row = $result->fetchRow(DB_FETCHMODE_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={$_SESSION['strasse']},
homepage=(),
email={$_SESSION['email']},
kategorie={$_SESSION['kategorie']},
hintergrund=(1),
";

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

// Unlock tables
$result=$connection->query("UNLOCK 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 "$connection" 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

Hi,

auch wenns Deutsch ginge ;)

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

-Kirsten
Sep 29 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.