Re: pdo doesn´t give me output
| From: | Dan Scott | Date: | Mon, 19 Feb 2007 16:10:16 +0000 |
| Subject: | Re: pdo doesn´t give me output | ||
| References: | 1 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-4568@lists.php.net to get a copy of this message | ||
Hi Marko:
I'm not really sure where the zend DLL dependency you described came
from; it sounds like your environment is kind of messed up. But
anyways...
First, PDO throws exceptions on connection errors. Wrap your code in
try {} catch {} blocks to find out more info about what's going on.
Second, if what you pasted is your real code, then you're not
successfully connecting to the Oracle database. Your PDO constructor
needs to be something like:
$dbh = new PDO('oci:dbiname=databaseName', 'web2', 'password');
or
$dbh = new PDO('oci://hostname:portNumber/databaseName', 'web2', 'password');
See http://php.net/manual/en/ref.pdo-oci.connection.php (although the
short version appears to be documented incorrectly here -- I'll fix
that in a minute).
So try something like:
<?
try {
$dbh = new PDO('oci:dbname=databaseName', 'web2', 'password');
$stmt = $dbh->prepare("SELECT U_NAME from USERID");
if ($stmt->execute()) {
while ($row = $stmt->fetch()) {
echo $row[0]['U_NAME'];
}
}
}
catch (PDOException $e) {
print $e;
}
?>
... and you should get more information about the problem you're running into.
Dan
On 19/02/07, Marko Jankovic <jankovic.marko@chello.at> wrote:
hello,
my name is marko.
first i had a lot of troubles with the dll´s. now i got it to work.
it didn´t work because it needs zend. now it has zend dll´s and the php modules are working. therefore zend doesn´t work anymore.
no idea really.
but now the dll´s work with php pdo and so on.
the problem i have now i get no output from my script. its an easy script only making connection and executing query.
i have the feeling it stops after the connection (new pdo ....).
i tried some echo´s between to see how far it comes. but after the connection it doesnt give any response. i kicked the echos out for you.
<?
$dbh = new PDO('oci:', 'web2', 'password');
$stmt = $dbh->prepare("SELECT U_NAME from USERID");
if ($stmt->execute()) {
while ($row = $stmt->fetch()) {
echo $row[0]['U_NAME'];
}
}
?>
please tell me what to do. i´m trying now some days.
thanks marko