note 49381 rejected from function.unset by cece

From: Date: Wed, 26 Jan 2005 09:36:05 +0000
Subject: note 49381 rejected from function.unset by cece
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-84007@lists.php.net to get a copy of this message
Note Submitter: sam at bouguerra dot com ---- This is driving me crazy can anybody please help me and save my life!!!! the problem is that everytime I refresh the page the variable $categories_input is always set eventhough I unset it :(( and it get gets into the database!!!! here is the code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <h1>Update your Categories</h1> <? session_start(); function foo() { unset($GLOBALS['categories_input']); } ?> <body> <form method="GET" action="<?php echo $PHP_SELF; ?>" > <? //connect to the database mysql_connect("localhost", "", "") or die(mysql_error()); //select or connect to the table mysql_select_db("") or die(mysql_error()); //if the button insert is clicked if(isset ($categories_input ) && $categories_input != "default" ) { $categ = addslashes($categories_input); $query ="insert into categories_num (category) values ('".$categ."') "; $result = mysql_query($query); foo(); } $query ="select * from categories_num"; $result = mysql_query($query); $num_results = mysql_num_rows($result); //echo "<p> The number of categories in the database is " .$num_results. "</p>"; echo "<table border='0'>"; for ($i =0, $j = 1; $i<$num_results; $i++, $j++) { $row = mysql_fetch_array($result); $the_id = $row["catid"] ; echo "<tr><td>"; print "<input type=radio name=catid value= $the_id >"; echo "</td><td>"; echo htmlspecialchars(stripslashes($row["category"])); echo "</td></tr>"; } echo "</table>"; ?> <br> Add a new category </br> <input type="text" name="categories_input" value="default" size="40" > <br> <input type="submit" name="add" value="submit"> </form> </body> </html>

« previous php.notes (#84007) next »