Forum Moderators: coopster
I have something like:
<? session stuff ?>
HTML
<? populate menu ?>
HTML
<? insert into.. ?>
-------
I have tried putting: include 'db.php'; up top with the session but it won't connect the two times I need it and even if I just put it with the populate menu code it will only work there and not in the "insert into" area.
I also have a variable I define in the populate menu area which I need to redefine again in the insert into area for it work.
Is there something I am missing because this seems very redundant?
Thanks.
variable scope: php doesn't care about switching between php and html 'mode' with regard to variable scope. Even variables in other included files have the same scope provided they're outside function blocks.
<?php $a = 'Alexander'; ?>
<p>hello
<?php echo $a; // same scope ?>
</p>
<div>I said, Hello <?php echo $a; // same scope ?>!</div>
<?php
function foo() {
echo $a; // Different scope
}
?>
<hr>
<?php include "file_that_uses_or_assigns_variable_a_outside_any_function.php"; // same scope ?>
eeek: I don't need two connections. But I have 2 mysql queries and the first one worked but the second one would not and only would if I included an include(db.php) right above it.
cameraman: I would receive I believe something along the lines of "ODBC cant connect ...", but I don't exactly recall.