LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-22-2003, 03:24 PM   #1
pnh73
Member
 
Registered: Jul 2003
Location: Birmingham, UK
Distribution: Ubuntu,Debian
Posts: 381

Rep: Reputation: 30
PHP MySQL code


I am writing code using PHP and making use of PEAR. When i run my script (i am using scripts from a book) i get the following error:

Quote:
Fatal error: Call to undefined function: query() in /home/linHost/www/dev/_lib/_classes/class.news.php on line 233
Does anybody have any idea why this might be?

TIA
 
Old 09-24-2003, 06:46 AM   #2
nephilim
Member
 
Registered: Aug 2003
Location: Belgium
Distribution: Debian (server), Kubuntu (desktop)
Posts: 248

Rep: Reputation: 30
Looks like you're calling a function that doesn't exist. Could you post the piece of code around line 233, especially the call to function query()?
 
Old 09-24-2003, 11:15 AM   #3
pnh73
Member
 
Registered: Jul 2003
Location: Birmingham, UK
Distribution: Ubuntu,Debian
Posts: 381

Original Poster
Rep: Reputation: 30
Ok here is line 233:

Code:
        if (DB::isError($rsTmp = $this->_oConn->query($sql))) {

            catchExc($rsTmp->getMessage());
            return false;
        }
 
Old 09-24-2003, 12:22 PM   #4
then
Member
 
Registered: Oct 2002
Location: FDR India
Distribution: RH9, Knoppix, MEPIS
Posts: 65

Rep: Reputation: 15
Quote:
Originally posted by pnh73
Ok here is line 233:

Code:
        if (DB::isError($rsTmp = $this->_oConn->query($sql))) {

            catchExc($rsTmp->getMessage());
            return false;
        }
Please help us help you.

* check if there is a function called query() in the file or in include files, if any.
* post the content of the query function.
* has PEAR been setup as per instruction i.e. is it in a place where PHP can find it?

regards
theN
 
Old 09-24-2003, 01:36 PM   #5
pnh73
Member
 
Registered: Jul 2003
Location: Birmingham, UK
Distribution: Ubuntu,Debian
Posts: 381

Original Poster
Rep: Reputation: 30
OK i found the following in common.php in /usr/share/pear/DB
Code:
// }}}
    // {{{ query()

    /**
     * Send a query to the database and return any results with a
     * DB_result object.
     *
     * @access public
     *
     * @param string $query  the SQL query or the statement to prepare
     * @param string $params the data to be added to the query
     * @return mixed a DB_result object or DB_OK on success, a DB
     *                error on failure
     *
     * @see DB::isError
     * @see DB_common::prepare
     * @see DB_common::execute
     */
    function &query($query, $params = array()) {
        if (sizeof($params) > 0) {
            $sth = $this->prepare($query);
            if (DB::isError($sth)) {
                return $sth;
            }
            $ret = $this->execute($sth, $params);
            $this->freePrepared($sth);
            return $ret;
        } else {
            $result = $this->simpleQuery($query);
            if (DB::isError($result) || $result === DB_OK) {
                return $result;
            } else {
                return new DB_result($this, $result);
            }
        }
    }
strangely DB.php (which is the include for the class.news.php file) does not contain an include for common.php
PEAR has been setup with the installatino script provided and has also had the includes for it included in the .htaccess and is a default include shown in phpinfo()

What is going on here?

Last edited by pnh73; 09-24-2003 at 01:37 PM.
 
Old 09-25-2003, 01:36 AM   #6
then
Member
 
Registered: Oct 2002
Location: FDR India
Distribution: RH9, Knoppix, MEPIS
Posts: 65

Rep: Reputation: 15
.

Last edited by then; 09-25-2003 at 01:40 AM.
 
Old 09-25-2003, 01:39 AM   #7
then
Member
 
Registered: Oct 2002
Location: FDR India
Distribution: RH9, Knoppix, MEPIS
Posts: 65

Rep: Reputation: 15
Quote:
function &query($query, $params = array())
I'm stumped by the & in the function definition . Wait for one of the elders to respond to your question.

You could try your luck on the PHP forums at - http://www.phpbuilder.com/, http://www.sitepointforums.com/.

Sorry couldn't be of any help. If you do resolve the problem, please post the answers here.

regards
theN
 
Old 09-25-2003, 06:12 PM   #8
sk8guitar
Member
 
Registered: Jul 2003
Location: DC
Distribution: mandrake 9.1
Posts: 415

Rep: Reputation: 30
hi, i don't know PEAR but i know in php/mysql if your sql command has the wrong syntax it gives you an error "mysql_query() not a function" or something almost exactly like your error. doulbe check tom ake sure the $sql command you are using is actually correct.
 
Old 09-26-2003, 12:30 PM   #9
pnh73
Member
 
Registered: Jul 2003
Location: Birmingham, UK
Distribution: Ubuntu,Debian
Posts: 381

Original Poster
Rep: Reputation: 30
The sql query, AFAIK is correct as this is code that I got from a book and I have seen a working example at http://wrox.mediatemple.net
 
Old 09-26-2003, 06:13 PM   #10
sk8guitar
Member
 
Registered: Jul 2003
Location: DC
Distribution: mandrake 9.1
Posts: 415

Rep: Reputation: 30
did you try the sql query in the sql prompt?
 
Old 09-27-2003, 08:03 AM   #11
pnh73
Member
 
Registered: Jul 2003
Location: Birmingham, UK
Distribution: Ubuntu,Debian
Posts: 381

Original Poster
Rep: Reputation: 30
Running the query, which is
Code:
SELECT news_type_id,news_type FROM holiday_news_types
works fine.

Going to inspect logs etc. see if i can find anthing there. I have seen hints that it may be DSN difinition is incorrect, but i have checked and it seems to be fine.
 
Old 09-29-2003, 10:27 AM   #12
pnh73
Member
 
Registered: Jul 2003
Location: Birmingham, UK
Distribution: Ubuntu,Debian
Posts: 381

Original Poster
Rep: Reputation: 30
Help? Does any1 know anything more?
 
Old 09-29-2003, 01:48 PM   #13
Robert0380
LQ Guru
 
Registered: Apr 2002
Location: Atlanta
Distribution: Gentoo
Posts: 1,280

Rep: Reputation: 47
if mysql_query() doesnt work, then maybe php wasnt compiled with mysql.
 
Old 09-29-2003, 01:56 PM   #14
pnh73
Member
 
Registered: Jul 2003
Location: Birmingham, UK
Distribution: Ubuntu,Debian
Posts: 381

Original Poster
Rep: Reputation: 30
Quote:
Originally posted by Robert0380
if mysql_query() doesnt work, then maybe php wasnt compiled with mysql.
not using mysql_query().... read thread...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Code in MySQL RodimusProblem Programming 1 02-20-2005 03:55 PM
Problem getting PHP to recognize MySQL, Using PHP 4.0 and MySQL 4.0.20 d2army Programming 4 06-27-2004 08:54 PM
php4 mysql, installation, php-pages with mysql info stay empty dnla Linux - Software 2 03-14-2004 02:54 PM
Apache Mysql Php: mysql with php doesn't work breakerfall Linux - Networking 6 12-27-2003 08:59 PM
PHP MySQL code problem pnh73 Programming 3 09-15-2003 01:01 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration