I have an index.php that includes config.php. Now I’m using $.get() when I click a button to load a form:
$.get('form.php', function (form) {
$(form).insertAfter();
});
This form requires config.php for some input values; however, when the form has loaded, I receive the php error:
Notice: Undefined variable: config in form.php on line 27
Line 27 of form.php: if ($config['spam_protect']) {
I realize the config.php has already been instantiated when the page initially loads, thus I suspect this to be the problem I’m having. I’ve tried including config.php within the form.php file to no avail. Tips or tricks anyone?
Thanks!
The message is quite clear:
$configisn’t loaded, maybe because your config file doesn’t load correctly.Note that if you make an Ajax request, the script requested in that request is an entirely new PHP instance. You may need to include
config.phpin that one as well.