Bug #17649: Scope bug, variable doesn't die as it should
| From: | scarlac2000 at hotmail dot com | Date: | Fri, 07 Jun 2002 22:35:43 +0000 |
| Subject: | Bug #17649: Scope bug, variable doesn't die as it should | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-9804@lists.php.net to get a copy of this message | ||
From: scarlac2000@hotmail.com
Operating system: Windows NT 5 (windows 2000 Pro)
PHP version: 4.2.1
PHP Bug Type: Variables related
Bug description: Scope bug, variable doesn't die as it should
The problem:
PHP doesn't seem to kill my variable ($allow) correctly.
I dunno if i'm just to tired, it's 30 min past midnight, so bare with me.
I just found out and consulted another reliable guy, he just told me to
get used to it.. I thought it would be good if you guys knew.
My Setup:
Normal Win32 setup, no changes to standart php.ini, running apache
1.3.24.
database content:
mysql> select * from permission_table
+----+------------+---------+-------+
| id | actiontype | groupid | allow |
+----+------------+---------+-------+
| 1 | changenews | 0 | 0 |
| 2 | changenews | 5 | 1 |
| 6 | changenews | 4 | 0 |
+----+------------+---------+-------+
------ SCRIPT START ------
<?
include("root.php");
include("$root/dbopen.php");
mysql_select_db("spacenet");
$res = mysql_query("SELECT * FROM permission_table") or
die(mysql_error());
?>
<script language="JavaScript">
<!--
function setvars(allow,id)
{
document.perm_form.allow.value=allow;
document.perm_form.id.value=id;
}
//-->
</script>
<form name="perm_form" action="./func_change_permission.php"
method="post">
<table border="1" summary="permissions">
<tr>
<td>id</td>
<td>groupid</td>
<td>actiontype</td>
<td>allow</td>
<td colspan="2"> </td>
</tr>
<?
while($row = mysql_fetch_array($res))
{
echo "<tr>\n";
echo "\t<td>$row[0]</td>\n";
echo "\t<td>".$row["groupid"]."</td>\n";
echo "\t<td>$row[1]</td>\n";
if($row["allow"]=="1")
$allow = "checked";
else // this else is essential, without it, PHP forgets to reset (kill)
$allow, so $allow is always = "checked"
$allow = "";
echo "\t<td><input type=\"checkbox\" value=\"1\"
name=\"val_$row[id]\"
$allow >".$row["allow"]."</td>\n";
echo "\t<td><a
href=\"func_remove_permission.php?id=$row[0]\">[fjern]</a></td>\n";
echo "\t<td><a href=\"#\"
onclick=\"setvars(document.perm_form.val_$row[id].checked,$row[id]);document.perm_form.submit()\">[Gem]</a></td>\n";
echo "</tr>\n";
}
?>
</table>
<input type="hidden" value="<?=mysql_num_rows($res)?>"
name="num_rows">
<input type="hidden" value="" name="allow">
<input type="hidden" value="" name="id">
<input type="submit" value="Gem" title="Gem ændringer">
</form>
<form action="./func_add_permission.php" method="post">
<b>Add permissions:</b>
<table border="0">
<tr>
<td>Actiontype: </td><td><input type="text"
name="actiontype"
value=""></td>
</tr>
<tr>
<td>Allow: </td><td><input type="checkbox" name="allow"
value="1"
></td>
</tr>
<tr>
<td>Group ID: </td><td><input type="text" name="groupid"
value=""
></td>
</tr>
</table>
<input type="submit" value="Gem" >
</form>
<?
include("$root/dbclose.php");
?>
------ END OF SCRIPT -------
--
Edit bug report at http://bugs.php.net/?id=17649&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=17649&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=17649&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=17649&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=17649&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=17649&r=support
Expected behavior: http://bugs.php.net/fix.php?id=17649&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=17649&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=17649&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=17649&r=globals