[PHPwestoz] problem with includes

Keith Moss khan at swcombine.com
Mon Feb 22 22:32:08 EST 2010


Ah I see it's time once again for the annual post to the mailing list :)

include_once should indeed work the situation you describe.

What was the code around line 31 of journal_pdo.php that was throwing the
foreach error?

On 22 February 2010 13:30, Gnitnop G <gnitnop at ymail.com> wrote:

>
> Hi All!
>
> I seem to be having a problem with php includes. sketching out my problem
> with an example will look something like this:
>
> I have 3 main php pages A.php, B.php and C.php.
> I have 3 include files; (1) dbconnect.php, (2) login1.php (3) login2.php
>
> All main pages; A.php, B.php and C.php includes (1) & (2) in their own page
> login1.php includes (3)
> login2.php AGAIN includes (1) - (for its local database service)
>
> Basically, in a nutshell, what I'm trying to achieve here is for a user to
> be able to login from any main page; i.e. A,B or C; and login1.php has the
> form that gets included in these pages, apart from these pages already
> including dbconnect.php.
> login1.php then includes login2.php which also includes dbconnect.php for
> its own use.
>
> So the problem I'm having here is I get the following error when I try to
> login from any of the 3 main pages:
>
> [Mon Feb 22 12:06:40 2010] [error] [client 127.0.0.1] PHP Fatal error:
> Cannot redeclare dbconnect() (previously declared in C:\\Program
> Files\\Apache Group\\Apache2\\htdocs\\xxxxxxx\\includes\\dbconnect.php:2) in
> C:\\Program Files\\Apache
> Group\\Apache2\\htdocs\\xxxxxxx\\includes\\dbconnect.php on line 22,
> referer: http://localhost/xxxxxxx/A.php
>
> I get the same error when clicking from AB or C. Only the referer page in
> the trace changes and the rest are all the same each time.
>
> Then, I tried include_once for all .php's but then I run into empty
> for-each'es as one below:
>
> [Mon Feb 22 12:26:49 2010] [error] [client 127.0.0.1] PHP Warning:  Invalid
> argument supplied for foreach() in C:\\Program Files\\Apache
> Group\\Apache2\\htdocs\\kookaburraartgallery\\journal_pdo.php on line 31,
> referer: http://localhost/xxxxxxxx/B.php
>
> Can someone help me with this maze, plz.
>
> thanks
> greymatter
>
>
>
>
>
>
> _______________________________________________
> PHPwestoz mailing list
> PHPwestoz at lists.linux.org.au
> http://lists.linux.org.au/listinfo/phpwestoz
>
>


-- 
Cheers,
Keith
Australia is merely an island of Antarctica, and of no further significance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.linux.org.au/pipermail/phpwestoz/attachments/20100222/9808029c/attachment.htm 


More information about the PHPwestoz mailing list