Can someone please explain to me why the following code is not working?
I have looked at online PHP manuals and as far as I can tell the following should work fine, but it does not 🙁
<?php
include $SERVER['DOCUMENT_ROOT'] . '/Library/include/vars.php';
include $Library_Top . 'include/functions.php';
if(isset($POST['CD_TOC']) && isset($POST['Save']) && $POST['Save'] == "Save CD")
{
echo "MySQLHost = " . $MySQLHost . "<br>";
write_cd_to_db();
}
?>
There is bascially a form that gets submitted and when the if statement is true then I want to write the info to a MySQL database. The problem that I am having is that the variables that are included are not getting passed to the function, that is also included.
The echo just prior to calling the function "write_cd_to_db" indicates that the variable $MySQLHost is set, but the same echo in "write_cd_to_db" is showing null.
So, why aren't my variables available in the included function?
Obviously I am not understanding exactly the scoping of variables here. If someone could explain I'd be very grateful.
Do I have to include the variables in the functions.php too?