Here is the code:
Code: Select all
$home = AT_HOME;
$query = "select address_opt_id, area_opt_id from {$db_prefix}address where
(address_id = \"$from_id\" or address_id = \"$to_id\")
and address_opt_id != $home";
$rs = mysql_query($query, $conn) or db_error(__FILE__, __LINE__, $query, "");
while ($row = mysql_fetch_assoc($rs))
{
// (process result set)
}
This only happens occasionally, but in the most recent case, I had 33 consecutive "supplied argument is not a valid MySQL result resource" warnings in the Apache log file at the call to mysql_fetch_assoc(), implying that 33 records were returned.
This is the address table:
Code: Select all
$query = "CREATE TABLE {$db_prefix}address (
address_id SMALLINT UNSIGNED AUTO_INCREMENT,
created DATETIME,
address1 VARCHAR(30) NOT NULL, address2 VARCHAR(30) NOT NULL,
town VARCHAR(30) NOT NULL, postcode VARCHAR(8) NOT NULL,
phone VARCHAR(15) NOT NULL, organisation VARCHAR(30) NOT NULL,
address_opt_id SMALLINT NOT NULL,
area_opt_id SMALLINT NOT NULL,
journeys_this SMALLINT UNSIGNED NOT NULL DEFAULT 0,
journeys_last SMALLINT UNSIGNED NOT NULL DEFAULT 0,
journeys_prev SMALLINT UNSIGNED NOT NULL DEFAULT 0,
last_journey DATE NOT NULL DEFAULT 0,
FOREIGN KEY(address_opt_id) REFERENCES {$db_prefix}address_options(address_opt_id),
FOREIGN KEY(area_opt_id) REFERENCES {$db_prefix}area_options(area_opt_id),
PRIMARY KEY(address_id))";
$rs = mysql_query($query) or dberr(__LINE__);
Apache 2.2.6
MySQL 5.0.45
PHP 5.2.5
on Windows Vista.
I really don't understand what the problem is. Please can you help?