html5 - confusion with php function resulting in error on different server -


i have problem dont know how solved, snapshot of php script.

    foreach($result $row){             $admin [] = array('id'=>$row['id'],'username' => $row['username'], 'email' => $row['email'], 'password'=>$row['password']);         }          include 'view_admins.php'; 

and part of view_admins.php thats relevent question

    <article id="admins">//html tag     <?php       foreach($admin $admins)://this line 75      ?>          <form action="" method="post" >             <div>             <p><tr><td><p><?php htmlout($admins['username']); ?></p></td><td>             <input type="hidden" align="center" name="id" value="<?php echo $admins['id'];?>"></td><td>              <input type="submit" name="action" value="edit">             <input type="submit" name="action" value="delete"></p></td></tr>              </div>         </form>         <?php endforeach; ?>         </article> 

when code runs produces "warning: invalid argument supplied foreach() in /home/a2516093/public_html/connect/view_admins.php on line 75"

my confusion code runs fine on localhost when uploaded host produces above mentioned warning, can please tell me causing problem, im still learning php programming highly appreciated.

to understanding $admin should visible in view_admins.php, correct me if im wrong. thank you

i'm guessing you're trying foreach() direct results got mysql_query().

you cannot this. need use mysql_fetch_array() or mysql_fetch_assoc(); define rows.

an example:

$result = mysql_query("your query"); while($row = mysql_fetch_array($result)) {      $admin [] = array('id'=>$row['id'],'username' => $row['username'], 'email' => $row['email'], 'password'=>$row['password']); } 

the reason earlier code worked because of automagic configuration settings fixed invalid code. mysql plugin automatically fetched right attributes while have manually.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -