Warning: SQL error: , SQL state in SQLConnect in test.php on line 5
| From: | Chris Lee | Date: | Mon, 21 May 2001 11:55:19 +0000 |
| Subject: | Warning: SQL error: , SQL state in SQLConnect in test.php on line 5 | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-9493@lists.php.net to get a copy of this message | ||
Dear All,
Language: PHP v4.05
OS: RedHat Linux 7.1
WebServer: Apache 1.3.20 w/mod_php
DB2: db2connect-7.1
DB Server: IBM AS/400 DB2
Connect to db2/as400 under the console of DB2 Connect works!
However, connect to db2/as400 via PHP fail sometime with the following
error, what's the problems?
Warning: SQL error: , SQL state in SQLConnect in test.php on line 5
- test.php --------------------------------------------------------
<?php
putenv("LD_LIBRARY_PATH=/home/db2inst1/sqllib/lib");
putenv("DB2INSTANCE=db2inst1");
$sql = "select * from PATRICK.TEMP";
$cnx = odbc_connect("linux", "LINUX", "LINUX");
$cur = odbc_exec ($cnx, $sql);
$Fields = odbc_num_fields($cur);
print "<table border='1' width='100%'><tr>";
// Build Column Headers
for ($i=1; $i <= $Fields; $i++){
printf("<th bgcolor='silver'>%s</th>", odbc_field_name( $cur,$i));
}
// Table Body
$Outer=0;
while( odbc_fetch_row( $cur )){
$Outer++;
print "<tr>";
for($i=1; $i <= $Fields; $i++){
printf("<td>%s</td>", odbc_result( $cur, $i ));
}
print "</tr>";
}
print "</table>";
print "<b> Your request returned $Outer rows!</b>";
// odbc_close( $cnx);
?>