[TYPO3-dev] non typo3 Database Selection error !!

Martin Kutschker martin.t.kutschker at n0spam.blackbox.net
Sat Jan 6 11:10:11 CET 2007


nirmalya Mondal schrieb:
> Hello,
> In my own extension its needed to select another database that is not 
> typo3 database. For this i've written this code
> ---------------
>  function databaseConnection(){
> 
>         $extnConf = 
> unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['fivee_oscommerce']); 
> 
>         $host         = $extnConf[db_host];
>         $user         = $extnConf[db_user];
>         $password     = $extnConf[db_password];
>         $dbasename     = $extnConf[db_name];
>         $connDb = @mysql_connect($host,$user,$password)or die('Not 
> Connected:' .mysql_error());
>                
>        
>             $selectDb = mysql_select_db($dbasename,$connDb) or 
> die('Database selection Failed' .mysql_error());
>                    
>     }   
> 
> ERROR:
> Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL 
> result resource in /myWebDirectory/t3lib/class.t3lib_db.php on line 802
> -----------------
> when i've commented out
> "//$selectDb = mysql_select_db($dbasename,$connDb) or die('Database 
> selection Failed' .mysql_error());" this line no error message is 
> displaying.
> This extension is generating its output properly.

What do you want to do? Are you trying to access your DB via the 
routines of t3lib_db? If so, study the class and see how the connection 
should be established. Hint: the class stores the connection resource.

Masi




More information about the TYPO3-dev mailing list