php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #7548 Database links and result sets seem to not be properly returned.
Submitted: 2000-10-31 11:32 UTC Modified: 2000-11-01 08:55 UTC
From: tonym at tk dot xaxon dot ne dot jp Assigned:
Status: Closed Package: MySQL related
PHP Version: 4.0.3pl1 OS: RedHat 7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tonym at tk dot xaxon dot ne dot jp
New email:
PHP Version: OS:

 

 [2000-10-31 11:32 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-10-31 23:44 UTC] 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-11-01 08:55 UTC] sniper@php.net
Or you could use this:

if(!($db = mysql_pconnect("server","user","pw"))) {
    die("error");
}

--Jani
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sun Jun 28 16:00:01 2026 UTC