Hi,
I am not exactly certain what has happend recently to me but it seems that the scope of certain variables has changed. Here is an example
<?
include_once($_SERVER['DOCUMENT_ROOT'].'/php_include/db_incl.php');
$addcategory = $_POST['input_category'];
$deletecategory = $_POST['category_delete'];
$DB = 'Buttons';
$DB_Table = 'categories';
if ( !db_connect($DB) )
echo '<p>Could not connect to database.</p>';
$query = "INSERT INTO $DB_Table (category) VALUES ('$addcategory')";
mysql_query($query) or die (mysql_error());
?>
<html> .............
<?
if($deletecategory)
{ $deletecategory = mysql_real_escape_string(strip_tags($deletecategory));
mysql_query("DELETE from $DB_Table where category='$deletecategory'") ;
}
?>
...........</html>
So that is a small example of code that used to work fine, and is typical of several pages i have. So all of a sudden no pages in that format were allowing any of the mysql queries in the second php block. I didn't change anything in the pages, they just stopped working. I don't believe i changed any system settings either. So I tracked down the problem and I now have to put
$DB_Table = 'categories'; in the second php block now and it works fine again. Is there any reason for this? here would now be the full code
<?
include_once($_SERVER['DOCUMENT_ROOT'].'/php_include/db_incl.php');
$addcategory = $_POST['input_category'];
$deletecategory = $_POST['category_delete'];
$DB = 'Buttons';
$DB_Table = 'categories';
if ( !db_connect($DB) )
echo '<p>Could not connect to database.</p>';
$query = "INSERT INTO $DB_Table (category) VALUES ('$addcategory')";
mysql_query($query) or die (mysql_error());
?>
<html> .............
<?
$DB_Table = 'categories';
if($deletecategory)
{ $deletecategory = mysql_real_escape_string(strip_tags($deletecategory));
mysql_query("DELETE from $DB_Table where category='$deletecategory'") ;
}
?>
...........</html>
Any help is appreciated. Chuck