Hello Guys,
I am somewhat new to PHP but have been developing for years.
I have created a function to capture alert values and add them to an array. This function is on the main page admin.php. See code below.
[php]
function AddAlerts($Alert, $Msg, $Page) {
$Alerts[] = '<br /><hr /><img src="template/'. $Alert .'.png" border="0"> <font class="'. $Alert .'">'. $Msg .'</font>';
$query="INSERT INTO AdminLogs (User, IP, Action, Page)
VALUES ('". $_SESSION['User'] ."', '". $_SESSION['IP'] ."', '$Msg', '$Page')
";
$result=mysql_query($query);
if (!$result) {
echo 'Invalid query: '. mysql_error() .'\n Query: '. $result;
}
}
[/php]
The admin.php page will then include a series of other pages based on different variables Gallery, Blog, Events, etc… These pages call the function as such after every action Success or Fail.
[php]
$Alert = ‘Fail’;
$Msg = 'Invalid query: ‘. mysql_error() .’\n Query: '. $query;
$Page = $_SERVER[‘PHP_SELF’];
AddAlerts($Alert, $Msg, $Page);
[/php]
The reason I chose to do it this was was because I have multiple actions that can take such as multiple file uploads and want to display alerts for each.
So when I run through a page that calls the AddAlerts function I can see that the query is being executed but the array is not getting updated. I have placed several counts around the function and it never changes from 0. Not sure how that can be if the query is being executed. Here is the display code.
[php]
if (count($Alerts) > 0) {
foreach ($Alerts as $Msg) {
echo $Msg;
}
}
[/php]
Any help on this would be greatly appreciated. Please let me know if you need anything else.
Thank you,