Wrox Programmer Forums
|
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6
This is the forum to discuss the Wrox book Beginning PHP, Apache, MySQLWeb Development by Michael K. Glass, Yann Le Scouarnec, Elizabeth Naramore, Gary Mailer, Jeremy Stolz, Jason Gerner; ISBN: 9780764557446
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 17th, 2004, 03:56 PM
Authorized User
 
Join Date: Sep 2004
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default Warning Message

Warning: Invalid argument supplied for foreach() in C:\Program Files\Apache Group\Apache2\test\admin.php on line 54


When I click on Admin for board administration I get the above error message. Do you know how I can fix this. Thanks.

 
Old September 17th, 2004, 05:19 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

I don't have the book. Can I see the code?

Sorry for the delay in answering your question.

-Snib <><
http://www.snibworks.com
There are only two stupid questions: the one you don't ask, and the one you ask more than once :-)
 
Old September 17th, 2004, 07:00 PM
Authorized User
 
Join Date: Sep 2004
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

here it is

<?php
require_once 'header.php';
?>

<script type="text/Javascript">
  <!--
  function delBBCode(id) {
    window.location = "transact-admin.php?action=deleteBBCode&b=" + id;
  }
  function delForum(id) {
    window.location = "transact-affirm.php?action=deleteForum&f=" + id;
}
//-->
</script>

<?php
$sql = "SELECT access_lvl, access_name FROM forum_access_levels " .
       "ORDER by access_lvl DESC";
$result = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
  $a_users[$row['access_lvl']] = $row['access_name'];
}

$menuoption = "boardadmin"; // default
if (isset($_GET['option'])) $menuoption = $_GET['option'];

$menuItems = array(
  "boardadmin" => "Board Admin",
  "edituser" => "Users",
  "forums" => "Forums",
  "bbcode" => "BBcode"
  );
echo "<p class='menu'>|";
foreach ($menuItems as $key => $value) {
  if ($menuoption != $key) {
    echo "<a href='" . $_SESSION['PHP_SELF'] . "?option=$key'>";
  }
  echo " $value ";
  if ($menuoption != $key) echo "</a>";
  echo "|";
}
echo "</p>";

switch ($menuoption) {
  case 'boardadmin':
  ?>
    <h3>Board Administration</h3>
    <form id='adminForm' method='post' action='transact-admin.php'>
    <table cellspacing='0' class='forumtable'>
    <tr>
      <th>Title</th><th>Value</th><th>Parameter</th>
    </tr>
  <?php
    foreach ($admin as $k => $v) {
      echo "<tr><td>". $v['title'] . "</td><td>" .
        "<input type='text' name='". $k . "' " .
        "value='" . $v['value'] . "' size='60'>" .
        "</td><td>$k</td></tr>\n";
    }
  ?>
    </table>
    <p class='buttonBar'>
      <input class='submit' type='submit' name="action"
        id="Update" value='Update'>
    </p>
    </form>
  <?php
    break;
  case 'edituser':
  ?>
    <h3>User Administration</h3>
    <div id="users">
    <form name="myform" action="transact-admin.php" method="post">
    Please select a user to admin:<br>
    <select id='userlist' name='userlist[]'>
  <?php
      foreach ($a_users as $key => $value) {
        echo "<optgroup label='". $value . "'>\n";
        userOptionList($key);
        echo "\n</optgroup>\n";
      }
  ?>
    </select>
    <input class="submit" type="submit" name="action"
            value="Modify User">
    </form>
    </div>
  <?php
    break;
  case 'forums':
    ?>
    <h2>Forum Administration</h2>
    <table class='forumtable' cellspacing='0'>
    <tr><th class="forum">Forum</th><th>&nbsp;</th><th>&nbsp;</th></tr>
    <?php
    $sql = "SELECT * FROM forum_forum";
    $result = mysql_query($sql) or die(mysql_error());
    while ($row = mysql_fetch_array($result)) {
      echo "<tr><td><span class='forumname'>" . $row['forum_name'] .
           "</span><br><span class='forumdesc'>" . $row['forum_desc'] .
           "</span></td><td>" . "<a href='editforum.php?forum=" .
           $row['id'] . "'>Edit</a></td><td>" .
           "<a href='#' onclick='delForum(". $row['id'] .
           ");'>" . "Delete</a></td></tr>";
    }
    ?>
    </table>
    <p class='buttonBar'>
      <a href='editforum.php' class='buttonlink'>New Forum</a>
    </p>
   <?php
    break;
  case 'bbcode':
  ?>
    <h3>BBcode Administration</h3>
    <form id='bbcodeForm' method='post' action='transact-admin.php'>
    <table cellspacing='0' class='forumtable'>
    <tr>
      <th class='template'>Template</th>
      <th class='replacement'>Replacement</th>
      <th class='action'>Action</th>
    </tr>
  <?php
    if (isset($bbcode)) {
      foreach ($bbcode as $k => $v) {
        echo "<tr class='row1'><td>" .
          "<input class='mono' type='text' name='bbcode_t". $k . "' " .
          "value='" . $v['template'] . "' size='32'>" .
          "</td><td>" .
          "<input class='mono' type='text' name='bbcode_r". $k . "' " .
          "value='" . $v['replacement'] . "' size='32'>" .
          "</td><td><input type='button' class='submit' " .
          "name='action' id='DelBBCode' value='Delete' " .
          "onclick='delBBCode(".$k.");'>" .
          "</td></tr>\n";
      }
    }
  ?>
    <tr class='row2'><td colspan='3'>&nbsp;</td></tr>
    <tr class='row2'><td>
    <input class='mono' type='text' name='bbcode-tnew' size='32'>
    </td><td>
    <input class='mono' type='text' name='bbcode-rnew' size='32'>
    </td><td>
    <input type='submit' class='submit' name='action'
      id='AddBBCode' value='Add New'>
    </td></tr>
    </table>
    <p class='buttonBar'>
      <input class='submit' type='submit' name="action"
        id="Update" value='Update BBCodes'>
    </p>
    </form>
  <?php
    break;
  default:
}
?>
</script>
<?php require_once 'footer.php'; ?>

 
Old September 29th, 2004, 07:54 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Which foreach is it giving you the error on?

-Snib <><
http://www.snibworks.com
There are only two stupid questions: the one you don't ask, and the one you ask more than once ;)
 
Old September 29th, 2004, 08:55 PM
Authorized User
 
Join Date: Sep 2004
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think its this one but not entirely sure.

foreach ($a_users as $key => $value)

AMP_Engineer






Similar Threads
Thread Thread Starter Forum Replies Last Post
Warning Message (Exception ex) dbcook8 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 December 1st, 2008 05:18 PM
Warning Window Message in Struts!!! petemotu Struts 0 September 25th, 2006 08:48 PM
Warning Message when creating Outlook email Paulsh Access VBA 3 September 5th, 2005 06:27 AM
Warning message NutzyNobs Beginning PHP 1 July 28th, 2005 02:31 PM
Avoid Warning Message on C lose Windows qazi_nomi Javascript 9 September 11th, 2004 11:19 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.