Re: PHP 4.0 Bug #2416 Updated: strange results accessing hashtables

From: Date: Mon, 04 Oct 1999 08:00:55 +0000
Subject: Re: PHP 4.0 Bug #2416 Updated: strange results accessing hashtables
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-11493@lists.php.net to get a copy of this message
On Fri, Oct 01, 1999 at 04:18:03PM -0000, Bug Database wrote: > ID: 2416 > Updated by: andrei > Reported By: andre.landwehr@bertelsmann.de > Status: Analyzed > Bug Type: Other > Assigned To: > Comments: > > Can you submit the simplest test script which demonstrates > > this problem? > > Full Bug description available at: > http://bugs.php.net/version4/?id=2416 Unfortunately I don´t have the time to develop a short script at the moment and I downgraded the machine again to 3.0.12 since I don´t have a test-server for this. But I attach the page that I experienced the problem with, and some inline comments. Hope it is of any help to you. Take care, Andre

<SCRIPT language="php"> /*****************************************************************************/ /* This just checks permissions for PHP_AUTH_USER and does some layout stuff */ /* Everybody may modify his own dates and view all others in his team */ /*****************************************************************************/ include ("./scripts/syblogincheck.php"); </SCRIPT> <!-- Holidayplanner for project teams of our department --> <TD> <HR> <SCRIPT language="php"> /***********************************************************/ /* Select people working in the same team as PHP_AUTH_USER */ /***********************************************************/ $res = sybase_query ("select vnba015.name from vnba014, vnba015 where vnba014.rac_f=\"$PHP_AUTH_USER\" and vnba015.no=vnba014.no and vnba015.name not like \"admin%\"", $con); $arr = sybase_fetch_array($res); $team = $arr[0]; printf("<H1>View holidayplan of Team %s", $team); while ($arr = sybase_fetch_array($res)) { printf("and %s", $arr[0]); } printf ("</H1>"); </SCRIPT> <HR> <P> Holidays and other dates of the above Team(s) are shown on this page; The meaning of used abbreviations is shown below! Click on the names to alter dates... </P> <TABLE> <TR> <TD>T</TD> <TD>Training</TD> <TD>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> <TD>H</TD> <TD>Holiday</TD> </TR><TR> <TD>F</TD> <TD>Public Holiday</TD> <TD>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD> <TD>M</TD> <TD>Munich</TD> </TR><TR> <TD>N</TD> <TD>New York</TD> </TR> </TABLE> <TABLE border="3" width="100%"> <TH>Name</TH> <TH>Info</TH> <SCRIPT language="php"> /********************************************************/ /* The main script; print a calendar for the next three */ /* months as HTML-Table, each row shows the dates of */ /* one team member with the characters H, F, M, N (see */ /* above for explanation of abbreviations) */ /********************************************************/ for ($i=0;$monthday != date ("m j", mktime(0,0,0,date("m") + 3,date("j"))); $i++) { $timestamp = mktime(0,0,0,date("m"),date("j") + $i); $monthday = date ("m j", $timestamp); $oldmonth = $month; $month = date ("F", $timestamp); $day = date ("j", $timestamp); if ($day == 1) { printf ("<TH colspan=\"%s\">%s</TH>", $daycount, $oldmonth); $daycount = 0; } $daycount++; } printf ("<TH colspan=\"%s\">%s</TH>", $daycount, $month); printf ("</TR>\n<TR><TH></TH><TH></TH>"); unset($monthday); for ($i=0;$monthday != date ("m j", mktime(0,0,0,date("m") + 3,date("j"))); $i++) { $timestamp = mktime(0,0,0,date("m"),date("j") + $i); $monthday = date ("m j", $timestamp); printf ("<TH>%s</TH>", date ("j", $timestamp)); } printf ("</TR>\n"); $res = sybase_query ("select vnba015.name from vnba014, vnba015 where vnba014.rac_f=\"$PHP_AUTH_USER\" and vnba015.no=vnba014.no and vnba015.name=\"$team\"", $con); while ($arr = sybase_fetch_array($res)) { /************************************************************************/ /* Search for all users who are in the same team but are no guest users */ /* (GAST as lastname in table vnba001) */ /************************************************************************/ $res2 = sybase_query ("select vnba014.rac_f from vnba014, vnba015, vnba001 where vnba001.rac_f=vnba014.rac_f and vnba001.lastname!=\"GAST\" and vnba015.name=\"$team\" and vnba014.no=vnba015.no", $con); while ($arr2 = sybase_fetch_array($res2)) { $users[] = $arr2[0]; } } reset ($users); do { unset($dates); $tt = current($users); $res = sybase_query ("select forename, lastname from vnba001 where rac_f=\"$tt\"", $con); $arr = sybase_fetch_array($res); if (strstr($tt, $PHP_AUTH_USER)) // direct comparison does not work... spaces? { printf ("<TR><TD><A href=\"holidayplanner_edit.phtml\">%s&nbsp;%s</A></TD>", $arr[0], $arr[1]); } else { printf ("<TR><TD>%s&nbsp;%s</TD>", $arr[0], $arr[1]); } printf ("<TD><A href=\"holidayplanner_infopage_view.phtml?user=%s\">view</A></TD>", $tt); $today = date ("M j Y h:iA", mktime(0,0,0,date("m"),date("j"))); $res = sybase_query ("select date, value from vnba009 where rac_f=\"$tt\" and date >= \"$today\""); while ($arr = sybase_fetch_array($res)) { $arr[0] = ereg_replace(" ", " ", "$arr[0]"); $arr[0] = ereg_replace(":00:000", "", "$arr[0]"); /**********************************************/ /* Here the hashtable in question gets filled */ /**********************************************/ $dates[$arr[0]] = $arr[1]; } unset($monthday); for ($i=0; $monthday != date ("m j", mktime(0,0,0,date("m") + 3, date("j"))); $i++) { $timestamp = mktime(0,0,0,date("m"),date("j") + $i); $monthday = date ("m j", $timestamp); $day = date ("M j Y h:iA", $timestamp); /***************************************/ /* and here I try to get the data back */ /***************************************/ if ($dates["$day"] != "") { printf ("<TD>%s</TD>", $dates["$day"]); } else { $weekday = date ("w", $timestamp); switch ($weekday) { case 0: printf ("<TD><FONT color=\"000000\">Su</FONT></TD>"); break; case 6: printf ("<TD><FONT color=\"000000\">Sa</FONT></TD>"); break; default: printf ("<TD>__</TD>"); } } } printf ("</TR>\n"); } while (next($users)); unset ($PHP_AUTH_USER); unset ($PHP_AUTH_PW); </SCRIPT> </TABLE> </TD> <? system ("./scripts/footer.sh") /* layout again */ ?>
« previous php.dev (#11493) next »