php.net |  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
 [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 ------
<?
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">&nbsp;</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 -------

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-07 23:29 UTC] sniper@php.net
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 http://www.php.net/support.php

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 17:01:58 2024 UTC