473,396 Members | 1,995 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,396 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 9063
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.