|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17649 Scope bug, variable doesn't die as it should
Submitted: 2002-06-07 18:35 UTC Modified: 2002-06-07 23:29 UTC
From: scarlac2000 at hotmail dot com Assigned:
Status: Not a bug Package: Variables related
PHP Version: 4.2.1 OS: Windows NT 5 (windows 2000 Pro)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: scarlac2000 at hotmail dot com
New email:
PHP Version: OS:


 [2002-06-07 18:35 UTC] scarlac2000 at hotmail dot com
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 ------
$res = mysql_query("SELECT * FROM permission_table") or die(mysql_error());
<script language="JavaScript">
function setvars(allow,id)
<form name="perm_form" action="./func_change_permission.php" method="post">
<table border="1" summary="permissions">
	<td colspan="2">&nbsp;</td>
	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";

			$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";
<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 action="./func_add_permission.php" method="post">
<b>Add permissions:</b>
	<table border="0">
			<td>Actiontype: </td><td><input type="text" name="actiontype" value=""></td>
			<td>Allow: </td><td><input type="checkbox" name="allow" value="1" ></td>
			<td>Group ID: </td><td><input type="text" name="groupid" value="" ></td>
	<input type="submit" value="Gem" >
------ END OF SCRIPT -------


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-07 23:29 UTC]
Sorry, but the bug system is not the appropriate forum for asking
support questions. Your problem does not imply a bug in PHP itself.
For a list of more appropriate places to ask for help using PHP,
please visit

Thank you for your interest in PHP.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Mar 03 21:01:30 2024 UTC