GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 12-Mar-2008, 00:00
kingsley kingsley is offline
New Member
 
Join Date: Feb 2008
Posts: 3
kingsley is on a distinguished road

Accessing my database in Db2 using PHP


i have a problem with my code although it looks perfectly ok but it does not create the result set i need to access my database. when i try to run it by typing localhost/test1.php it connects to the database but returns no result set and doesnt recognize my select statement.

What is worng with my code, can anyone help me pls.

name of php file: test1.php



PHP Code:

<?php
$database = 'manu';
$user = 'db2admin';
$password = 'boyfunky';
 
$conn = db2_connect($database, $user, $password);
 
if ($conn) {
echo "Connection succeeded.";
db2_close($conn);
}
else {
echo "Connection failed.";
}
 
 
 
$select= "SELECT containerid, arrival FROM info";
$result= db2_exec($connection,$select);
 
if($result){
echo "Result Set created."."\n";
}
else {
echo "Result Set not created."."\n";
 
}
while ($row=db2_fetch_array($result))
{
 
$containerid=odbc_result($rs,"containerid");
$arrival=odbc_result($rs,"arrival");
}
db2_close($connection);
 
?>

Last edited by admin II : 12-Mar-2008 at 05:27. Reason: Please surround your PHP code with [php] your code [/php]
  #2  
Old 12-Mar-2008, 09:54
TurboPT's Avatar
TurboPT TurboPT is offline
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,140
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: problem accessing my database in Db2 using PHP


There seems to be confusion between $conn and $connection

If $conn succeeds, it is being closed immediately. (probably NOT what is intended)

$connection does not appear to be set in the script anywhere, so what is db2_exec() expected to do with it?
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
 
 

Recent GIDBlogProblems with the Navy (Chiefs) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache / PHP problem, maybe output length? HaganeNoKokoro Apache Web Server Forum 3 07-Aug-2008 05:42
Problem with executing PHP in webpage fdgloworm Apache Web Server Forum 0 13-Feb-2006 12:43
Please help! Insert into database problem robsmith MySQL / PHP Forum 1 24-Apr-2005 04:44
accessing database records on 2 dialogs da_cobra MS Visual C++ / MFC Forum 0 28-Feb-2005 14:32
Parsing PHP code that's stored in a database. JdS MySQL / PHP Forum 3 13-May-2004 10:15

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 15:10.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.