If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > how connect DB2 With PHP... Fatal Error try Connect.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-23-10, 16:28
clavijo83 clavijo83 is offline
Registered User
 
Join Date: Jun 2010
Posts: 4
how connect DB2 With PHP... Fatal Error try Connect.

hi, i install the pecl extensions of ibm_db2 in my php, but give me fatla error on run my page.

this is the error:
Fatal error: Call to undefined function db2_connect() in C:\AppServ\www\multivpos\configs\bd.php on line 7

i copy the php_ibm_db2.dll in my folder php, C:\AppServ\php5\ext, and i configure the php.ini file, adding line "php_ibm_db2.dll" in php.ini

my php file to connect:
PHP Code:
<?php
$database 
'SAMPLE';
$user 'db2admin';
$password 'apassword';
$hostname 'localhost';
$port 50000;
$connection db2_connect($database$user$password);
if (
$connection)
{
echo 
"Connection succeeded."."\n";
}
else
{
echo 
"Connection failed.<br />";
echo 
'SQLSTATE : ' db2_conn_error() . '<br/>';
echo 
'Message : ' .db2_conn_errormsg(). '<br />';
}
please help me how connect, fix the error.

Last edited by clavijo83; 06-23-10 at 16:31.
Reply With Quote
  #2 (permalink)  
Old 06-27-10, 14:08
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Your PHP installation/web server can't find the library. So you must be missing some step in the installation. I am not using Windows, so I can't be more specific, though.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #3 (permalink)  
Old 06-28-10, 13:41
goldfishhh goldfishhh is offline
Registered User
 
Join Date: Nov 2004
Posts: 54
Another approach is to use ODBC.

Code:
$dsn = "batchquality";
$user = "";
$pass = "";

$conn=odbc_connect($dsn,$user,$pass);
if (!$conn)
  {exit("Connection Failed. Something is messed up in the data file: " . ODBC_ERRORMSG($conn));}
Just config a DSN to connect into your DB and then go.
Reply With Quote
  #4 (permalink)  
Old 06-28-10, 15:22
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Using the ODBC driver is a rather bad idea. That driver has several bugs and doesn't support all data types, for example. So I would only use it as a last resort to see if something fundamental is wrong in the system (like DB2 not installed).
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On