FW: [PHP] Code works perfectly with PHP 4.0.0 and fails in 4.0.1pl2...
| From: | Darron Froese | Date: | Tue, 25 Jul 2000 20:30:09 +0000 |
| Subject: | FW: [PHP] Code works perfectly with PHP 4.0.0 and fails in 4.0.1pl2... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-8130@lists.php.net to get a copy of this message | ||
I just tried this on another machine (DualP3/450, SCSI RAID1, Mandrake 7.1
w/PHP 4.0.1pl2 and 4.0.0 and Apache 1.3.12) with *exactly* the same results
as the other machine (AMD K62, ATA66 RAID5, Mandrake 7.0, w/PHP 4.0.1pl2 and
4.0.0 and Apache 1.3.12).
I do have one clarification to add though:
Under 4.0.1pl2 $current_element always returns the first $row[photoid] in
$images - $images[0]. $prev_element is undefined (that's fine if it's the
first item in the array) and $next_element is undefined as well (not fine).
It works just fine on 4.0.0 on the second machine.
Am I doing something wrong? Is my code screwed up? Is it PHP?
Thanks.
--
Darron
darron@froese.org
----------
From: Darron Froese <darron@froese.org>
Date: Tue, 25 Jul 2000 11:23:34 -0600
To: <php-general@lists.php.net>
Subject: [PHP] Code works perfectly with PHP 4.0.0 and fails in 4.0.1pl2...
It's a PHP DSO with Apache 1.3.12 on Mandrake 7.0.
PHP has been compiled with gcc-2.95 with these configure flags:
Both 4.0.0 and 4.0.1pl2:
./configure \
--with-apxs=/usr/local/apache/bin/apxs \
--with-mysql=/usr/local/mysql-prod \
--with-pdflib \
--enable-ftp \
--with-ldap \
--with-imap=/usr/local/src/imap-4.5 \
--with-zlib \
--with-jpeg-dir=/usr/lib \
--with-tiff-dir=/usr/lib \
--with-zlib-dir=/usr/lib \
--with-png-dir=/usr/lib \
--with-gd \
--with-ttf \
--with-xml \
--enable-trans-sid \
--enable-track-vars=yes \
--enable-magic-quotes=yes
This code works just fine on 4.0.0:
--------- BEGIN CODE ---------
// Build the List for the Back and Forth Buttons
// Connect to the db and pull out all of the info on the
// images in this section.
$db = new gc_db;
$table = "photos";
$query = "SELECT * from $table WHERE photo_section='$web_photo_section'";
$db->db_query($query);
$numRows = $db->affected_rows();
if ($numRows) {
$counter = 0;
while ($row = mysql_fetch_array($db->Query)) {
// Make a array of the items in order
// So that we can do a backward and forwards from where we are.
$images[$counter] = $row[photoid];
$counter++;
}
}
//
// This is where it stops working in 4.0.1pl2 - $current_element always
// returns 1 and $prev_element and $next_element are *always* undefined.
// It works perfectly in 4.0.0.
//
if (in_array("$web_photoid", $images)) {
$current_element = current($images);
$prev_element = prev($images);
}
if (in_array("$web_photoid", $images)) {
$next_element = next($images);
}
//
// As a result of the last section not working, these items never print.
//
if ($prev_element) {
print "<A
HREF=\"/includes/php/med-image.php?web_photoid=$prev_element&web_photo_secti
on=$web_photo_section\" TARGET=\"body\">Prev</A> ";
}
if ($next_element) {
print "<A
HREF=\"/includes/php/med-image.php?web_photoid=$next_element&web_photo_secti
on=$web_photo_section\" TARGET=\"body\">Next</A> ";
}
--------- END CODE ---------
It builds a little back and forward buttons so that you can flip between the
items in the database - it DOESN'T work in 4.0.1pl2.
For whatever reason, under 4.0.1pl2, $current_element *ALWAYS* returns 1,
while $prev_element and $next_element are null - no matter what record I'm
on.
Under 4.0.0, when $current_element is 1, $next_element is 2 and
$prev_element is undefined like it should be.
Is it an error with my code? Or an error/bug with PHP?
I've gone back to 4.0.0 in the meantime.
--
Darron
darron@froese.org