Bug #7548 [Com]: Database links and result sets seem to not be properly returned.
| From: | lildurk7548 at gmail dot com | Date: | Wed, 01 Sep 2021 18:39:26 +0000 |
| Subject: | Bug #7548 [Com]: Database links and result sets seem to not be properly returned. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-236266@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=7548&edit=1
ID: 7548
Comment by: lildurk7548 at gmail dot com
Reported by: tonym at tk dot xaxon dot ne dot jp
Summary: Database links and result sets seem to not be
properly returned.
Status: Closed
Type: Bug
Package: MySQL related
Operating System: RedHat 7
PHP Version: 4.0.3pl1
Block user comment: N
Private report: N
New Comment:
Lil Durk is a private agency dedicated to providing responsible access to legal cannabis for adults
aged 19 and older. Weâre an exclusively online retailer and wholesaler for recreational
cannabis and a trusted source for information about cannabis and cannabis-related issues. We believe
our work is meaningful and we take pride in our mandate to promote the socially responsible use of
legal cannabis. https://lildurk.com/
Previous Comments:
------------------------------------------------------------------------
[2000-11-01 08:55:34] sniper@php.net
Or you could use this:
if(!($db = mysql_pconnect("server","user","pw"))) {
die("error");
}
--Jani
------------------------------------------------------------------------
[2000-10-31 23:44:30] tonym at tk dot xaxon dot ne dot jp
Problem solved.
Apparently the following syntax cannot be used:
$db = mysql_pconnect("server","user","pw") ||
die("error");
Check for success must be as follows:
$db = mysql_pconnect("server","user","pw");
if (! $db) { die("error"); }
Is this correct parsing for php?
------------------------------------------------------------------------
[2000-10-31 11:32:15] tonym at tk dot xaxon dot ne dot jp
Database links and result sets seem to not be properly returned.
Heavily edited script:
$db = mysql_pconnect("server","user","pw") || die "Couldn't
connect to db!";
// or, $db = mysql_connect( ... )
// the following works:
$result = mysql_list_dbs();
$x = mysql_num_rows( $result );
for ($i = 0; $i < x; $i++) {
echo "table found: " . mysql_table_name($result, $i) . "<br>";
}
// the following does not:
$result = mysql_list_dbs( $db ); // give warning "not a valid MySQL link"
$x = mysql_num_rows( $result ); // give warning "not a valid MySQL result resource"
// the following works:
$result = mysql_query("INSERT INTO users (id, name) VALUES (10, 'fred')");
// the following does not:
$result = mysql_query("SELECT name FROM users")
|| die (Query failed); // die() not called
while ($row = mysql_fetch_row( $result )) { // give warning "not a valid MySQL result
resource"
<do something> // this line is never reached
}
// the following also does not work:
$result = mysql_query("SELECT 1 + 1 as total")
|| die (Query failed); // die() not called
$total = mysql_fetch_row( $result ); // give warning "not a valid MySQL result resource"
--------------------------------------------------
Compile options:
--with-apxs=/usr/local/apache/bin/apxs
--with-mysql=/usr/local/mysql
--enable-track-vars
MySQL version 3.23.27-beta
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=7548&edit=1