Code works perfectly with PHP 4.0.0 and fails in 4.0.1pl2...
| From: | Darron Froese | Date: | Tue, 25 Jul 2000 17:23:34 +0000 |
| Subject: | Code works perfectly with PHP 4.0.0 and fails in 4.0.1pl2... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-8097@lists.php.net to get a copy of this message | ||
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