Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-03-2010, 12:46 PM   PM User | #1
Stooshie
Regular Coder

 
Stooshie's Avatar
 
Join Date: Mar 2008
Location: Dundee, Scotland
Posts: 376
Thanks: 9
Thanked 39 Times in 39 Posts
Stooshie is on a distinguished road
Question php mysql using PEAR adodb connecting but returning null ressult

Hi there,

We have recently changed servers and I am having a problem getting php to return results from MySql using the PEAR adodb extension.

PhpMyAdmin connects and returns results fine and I can even go to a SQL box, type in some SQL and get a result back.

However, when I write my own php it connects but the return value from the query is null and I get an error when I try to return FetchRow() from it.

Interestingly the Exception is NOT called.
PHP Code:
    include("adodb/adodb.inc.php");

    
$DB_Test = &NewADOConnection('mysql');

    
$DB_Test->PConnect("localhost","username""password""db");

    
$sql "
        SELECT
            MAX(id) as max_id
        FROM
            table
    "
;

    try
    {
        
$result $DB_Test->Execute($sql);
        
$row $result->FetchRow();
        
$table_id $row["max_id"];
    }
    catch(
Exception $e)
    {
        echo(
$e->getMessage());
    }
    echo(
$table_id); 
When I do print_r on $DB_Test it seems to be populated OK
Code:
    [databaseType] => mysql
    [dataProvider] => mysql
    [hasInsertID] => 1
    [hasAffectedRows] => 1
    [metaTablesSQL] => SHOW TABLES
    [metaColumnsSQL] => SHOW COLUMNS FROM `%s`
    [fmtTimeStamp] => 'Y-m-d H:i:s'
    [hasLimit] => 1
    [hasMoveFirst] => 1
    [hasGenID] => 1
    [isoDates] => 1
    [sysDate] => CURDATE()
    [sysTimeStamp] => NOW()
    [hasTransactions] => 
    [forceNewConnect] => 
    [poorAffectedRows] => 1
    [clientFlags] => 0
    [substr] => substring
    [nameQuote] => `
    [compat323] => 
    [_genIDSQL] => update %s set id=LAST_INSERT_ID(id+1);
    [_genSeqSQL] => create table %s (id int not null)
    [_genSeqCountSQL] => select count(*) from %s
    [_genSeq2SQL] => insert into %s values (%s)
    [_dropSeqSQL] => drop table %s
    [database] => ivimeds
    [host] => localhost
    [user] => masteruser
    [password] => masteruser
    [debug] => 
    [maxblobsize] => 262144
    [concat_operator] => +
    [length] => length
    [random] => rand()
    [upperCase] => upper
    [fmtDate] => 'Y-m-d'
    [true] => 1
    [false] => 0
    [replaceQuote] => \'
    [charSet] => 
    [metaDatabasesSQL] => 
    [uniqueOrderBy] => 
    [emptyDate] =>  
    [emptyTimeStamp] =>  
    [lastInsID] => 
    [hasTop] => 
    [readOnly] => 
    [genID] => 0
    [raiseErrorFn] => 
    [cacheSecs] => 3600
    [memCache] => 
    [memCacheHost] => 
    [memCachePort] => 11211
    [memCacheCompress] => 
    [arrayClass] => ADORecordSet_array
    [noNullStrings] => 
    [numCacheHits] => 0
    [numCacheMisses] => 0
    [pageExecuteCountRows] => 1
    [uniqueSort] => 
    [leftOuter] => 
    [rightOuter] => 
    [ansiOuter] => 
    [autoRollback] => 
    [fnExecute] => 
    [fnCacheExecute] => 
    [blobEncodeType] => 
    [rsPrefix] => ADORecordSet_
    [autoCommit] => 1
    [transOff] => 0
    [transCnt] => 0
    [fetchMode] => 
    [null2null] => null
    [_oldRaiseFn] => 
    [_transOK] => 
    [_connectionID] => Resource id #7
    [_errorMsg] => 
    [_errorCode] => 
    [_queryID] => 
    [_isPersistentConnection] => 1
    [_bindInputArray] => 
    [_evalAll] => 
    [_affected] => 
    [_logsql] => 
    [_transmode] => 
    [databaseName] => ivimeds
Is there anything missing from the $DB_Object? has anyone come across this before?

The versions I am using are:

PHP Version: 5.2.10
MySQL Server version: 5.0.89-community

Andrew.
__________________
Regards, Stooshie
O
Stooshie is offline   Reply With Quote
Old 02-03-2010, 07:55 PM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,247
Thanks: 59
Thanked 3,998 Times in 3,967 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Well, not to ask a silly question...

I have no idea what PEAR is, but if it uses Microsoft's ADODB, then I assume this is intended for a Windows server, yes?

And if that is so, then have you installed MyODBC to connect MySQL to ADODB?
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 02-04-2010, 10:03 AM   PM User | #3
Stooshie
Regular Coder

 
Stooshie's Avatar
 
Join Date: Mar 2008
Location: Dundee, Scotland
Posts: 376
Thanks: 9
Thanked 39 Times in 39 Posts
Stooshie is on a distinguished road
Hi there,

PEAR is a collection of PHP extensions.

The adodb is an extension which allows you to connect to many different types of database. It is written in PHP and can be run on any server using PHP. Our server is *nix.

It works on our old server so I am trying to find out what settings could be different and nothing except some very minor PHP and MySQL upgrades (e.g. PHP 5.2.10 rather than 5.2.6).
__________________
Regards, Stooshie
O
Stooshie is offline   Reply With Quote
Old 02-04-2010, 06:19 PM   PM User | #4
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,247
Thanks: 59
Thanked 3,998 Times in 3,967 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Fascinating. They use the same acronym the MS uses. "ADODB". Wonder what it stands for in PEAR? ("ActiveX Data Objects" or something like that with MS.)
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Reply

Bookmarks

Tags
adodb, mysql, null, php, result

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:57 AM.


Advertisement
Log in to turn off these ads.