The above page presents the following information...
Example 1695. Handling connection errors
<?php
$DBName = "sqlite:db.sq3";
$user = "admin";
$pass = "admin";
try {
$dbh = new PDO($DBName, $user, $pass);
$dbh->exec('CREATE TABLE FOO(id INDEX PRIMARY KEY, name TEXT);');
$dbh = null; // Error or warning. This is the only line I didn't change.
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
?>
The $dbh = null; line coughs up an error. That's one of the only lines I
did not change from the example presented on that page. It appears
that the documentation is incorrect. Is that correct?
The code runs, but I'm left confused about why that line exists.
Could one use unset($dbh); to kill it? What's the recommended way
to destroy a PDO object?
Thanks.
--
Jim Carlock 2 1797
Oops.
I cancelled the message, but someone may have downloaded it.
Please disregard the message. I tried to duplicate the problem,
and it ended up as another problem.
[15-Jun-2007 19:09:35] PHP Notice: Object of class PDO could not be converted to int in index.php on line 117
That notice occured on the if() line below...
$oPDO = new PDO($sDBName, $sUserID, $sPassword);
if (($oPDO) & (strlen($sSQL) 0)) {
and not on the...
$oPDO = null;
line.
If someone replies to the message I'll repost it. If not, perhaps
I still have something here to question. Specifically the line that
sets $oPDO to null. The webpage in question only presents it
one time and few (if any) of the other examples use that line.
My apologies about sending folks off on a wild goose chase in
the previous message. :-)
--
Jim Carlock
Post replies to the group.
On Sat, 16 Jun 2007 01:24:42 +0200, Jim Carlock <an*******@127.0.0.1
wrote:
Oops.
I cancelled the message, but someone may have downloaded it.
Please disregard the message. I tried to duplicate the problem,
and it ended up as another problem.
[15-Jun-2007 19:09:35] PHP Notice: Object of class PDO could not be
converted to int in index.php on line 117
That notice occured on the if() line below...
$oPDO = new PDO($sDBName, $sUserID, $sPassword);
if (($oPDO) & (strlen($sSQL) 0)) {
& = && ?
& is a bitwise operator, I suspect it tries to cast $oPDO to an integer to
check this, which cannot be done. It can however be cast to a boolean,
which is what && does.
--
Rik Wasmus This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ravi |
last post by:
Hi All,
I am trying to execute a select statement using the DBI module
of perl in a for loop. I am getting a strange behaviour, the select
statement is excuting correctly only for the last element...
|
by: JONL |
last post by:
Have been connecting to oracle using the following with success
my $dbHandle = DBI->connect($sConnectString, $sUsername, $sPassword );
adding ,\%attr after password permits me to set the db handle...
|
by: designsimply |
last post by:
I am trying to http post some xml to to a remote server using php. When
I try to submit xml using PEAR's HTTP_Client::post() to the remote
server, I get back the following "Invalid Document Format"...
|
by: Mike Curry |
last post by:
I am looking for a simple sample of using sockets to download a page
into a string. If anyone knows where I could get a sample, or post one
here, that would be great.
|
by: kumar |
last post by:
Hi friends,
I am using PHP version 4.2 in RHEL4 system.
I am sending multipart binary data using libcurl from client
application and a php script at the server side recieves it. But...
|
by: Bonzol |
last post by:
I am trying to bring code over from 2003,
I am trying to do the following involving the following file
DBhandler.vb
Dim DBH as new DBhandler
DBH = new DBHhandler
works in 1.1, but not in 2.0...
|
by: mamod20 |
last post by:
Please advise, I have the following example and want to know the best
way to use $dbh->disconnect; and $sth->finish;
--------------
$sql_host="localhost";
$sql_dataname = "database";...
|
by: Reporter |
last post by:
Here is an example from the PHP Manual
<?php
if ((!isset($_SERVER)) || (1==1)) {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
echo 'Text to send...
|
by: gautamga |
last post by:
Hi All i have created the script which calls method from other script lib and while executing i get and error Can't call method "prepare" on an undefined value at...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |