473,230 Members | 4,185 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,230 software developers and data experts.

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 "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
1 9007
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Netocrat | last post by:
Any comments on the correctness of the statements 1, 2a, 2b, 3 and 4 in the code below? If they are correct, then the definition of an object as well as that of an lvalue is broken in C99 by the...
3
by: dumbledad | last post by:
Hi All, I know this comes up lots but I have tried the previously posted solutions and they are not working for me. I have a new installation of MySQL and PHP running on Windows Server 2003 SP2...
3
by: news | last post by:
Hi all, hope you can help me. I have recently set up a mysql database of local pubs, with a web form to add new listings (using PHP to generate an INSERT query). I've just been doing a bit of...
11
by: Felix Kater | last post by:
Hi, I can compile and run this code (see below) which twice calls the function f, first with too less, second with too much arguments. But is it legal and free of memory leaks and other...
2
by: salvadorvp | last post by:
Hi, I have the following code that gives me this odd error message at a line of code inside the PEAR libraries: "Fatal error: Call to undefined function: MDB2_Driver_mssql::getMessage(). in...
9
by: CryptiqueGuy | last post by:
Consider the variadic function with the following prototype: int foo(int num,...); Here 'num' specifies the number of arguments, and assume that all the arguments that should be passed to this...
7
by: lumo2000 | last post by:
hello i am not able to get mysql running. you can get my server/php settings/details here: http://damn-i-have.no-ip.com/phpinfo.php i already enabled the following stuff in my php.ini NOTE:...
9
by: Yannick | last post by:
Hi everyone - I am not quite sure to understand what is really going on when a function defined in one translation unit calls a function defined in a different translation unit without knowing...
1
by: Beamor | last post by:
function art_menu_xml_parcer($content, $showSubMenus) { $doc = new DOMDocument(); $doc->loadXML($content);//this is the line in question $parent = $doc->documentElement; $elements =...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.