[PHPwestoz] problem with includes

Kim Richardson krichardson at viewdale.com.au
Tue Feb 23 02:27:21 EST 2010


The output of $conn->query($sql) would be a result set pointer, not an
actual array.

Try

$result=$conn->query($sql);
if($result->num_rows>0)
{
   while($row=$result->fetch_assoc())
   {
           ... do your magic here
   }
}

On 22/02/2010 9:58 PM, Gnitnop G wrote:
> 30     <div id="artdescription">
>  <?php
>  foreach ($conn->query($sql) as $row) {
>  ?>
>         <h2><?php echo $row['title']; ?></h2>
>           <p><?php $extract = getFirst($row['article']);           
>             echo $extract[0];
>             if ($extract[1]) {
>              
>               echo '<a
> href="abstractexplanation.php?article_id='.$row['article_id'].'">
> More</a>';
>               } ?></p>
>       <?php } ?>
> 41    </div>
>  
>  
> ps: according to my sketched-out example, that last error should look
> like this:
>  
> [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\\xxxxxxxx\\B.php on line 31, referer:
> http://localhost/xxxxxxxx/B.php
>  
>  
>  
> --- On *Mon, 22/2/10, Keith Moss /<khan at swcombine.com>/* wrote:
>
>
>     From: Keith Moss <khan at swcombine.com>
>     Subject: Re: [PHPwestoz] problem with includes
>     To: "PHP users in Western Australia (or nearby)"
>     <phpwestoz at lists.linux.org.au>
>     Date: Monday, 22 February, 2010, 11:32
>
>     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
>     <http://uk.mc246.mail.yahoo.com/mc/compose?to=gnitnop@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://uk.mc246.mail.yahoo.com/mc/compose?to=PHPwestoz@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.
>
>     -----Inline Attachment Follows-----
>
>     _______________________________________________
>     PHPwestoz mailing list
>     PHPwestoz at lists.linux.org.au
>     <http://uk.mc246.mail.yahoo.com/mc/compose?to=PHPwestoz@lists.linux.org.au>
>     http://lists.linux.org.au/listinfo/phpwestoz
>
>
>
> _______________________________________________
> PHPwestoz mailing list
> PHPwestoz at lists.linux.org.au
> http://lists.linux.org.au/listinfo/phpwestoz
>   

-- 
---------------
Kim Richardson
Web Applications Developer
Viewdale IT
Tel: 1300 799 516 - Fax: (07) 3319 8932
http://www.ausnix.com.au

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.linux.org.au/pipermail/phpwestoz/attachments/20100222/b51465ad/attachment-0001.htm 


More information about the PHPwestoz mailing list