PHP Programming > General PHP Help

What's wrong with this query?

<< < (9/9)

traydavid:
I did not...thanks.  Been kind of busy at work and not posting a lot.  I tried a few new things and I'll post them to update everyone. 

Here is the validation form for the admin login:


--- PHP Code: ---<?php
session_start();
include ("..login.php");
login();
$userid = $_POST['userid'];
$password = $_POST['password'];
$query = "SELECT * from admins where userid = '$userid' and password = ('$password')";
$result = mysql_query($query);
if (mysql_num_rows($result) == 0)
{
   echo "<h2>Sorry, your account was not validated.</h2><br>\n";
   echo "<a href=\"admin.php\">Try again</a><br>\n";
} else
{
   $_SESSION['store_smalladmin'] = $userid;
//THE NEXT LINE DIRECTS SUCCESSFUL LOGINS WHERE TO GO NEXT, IN THIS CASE TO THE ADMIN PAGE
//This function must appear before any HTML code is sent to the browser. 
//You can't have any echo statements before the header() function.
   header("Location: admin.php");
}
?>
--- End code ---


As you can see, the cookie is set holding the userid.  Here is the page that is referred to after login:


--- PHP Code: ---<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<?php
   include("../adminlogin.php");
   include("../showproducts3.php");
   login();
?>
<body>
<table width="100%" border="0">
  <tr>
    <td id="header" height="90" colspan="3">
  </tr>
 
</td>
    <td id="main" width="60%" valign="top">
<?php
               if (!isset($_REQUEST['content']))
               {

 if (!isset($_SESSION['store_admin']))
                      include("adminlogin.html");
                   else
                      include("adminmain.inc.php");        
               }
               else
               {
                   $content = $_REQUEST['content'];
                   $nextpage = $content . ".inc.php";
                   include($nextpage);
               } 
?></td>
 
  </tr>
  
  <tr>
</td>
  </tr>
</table>
</body>
</html>
--- End code ---


I'm having an error that states that the 'nextpage' is not defined.  I've included a page that is referenced in the above page that may or may not have something to do with it.  It's the showproducts3 page that is referenced:


--- PHP Code: ---<?php


   function showproducts3($custid, $page, $currentpage, $newpage)
   {
      $query = "Select count(prodid) from products where custid = $custid";
      $result = mysql_query($query);
      $row = mysql_fetch_array($result);
      if ($row[0] == 0)
      {
         echo "<h2><br>Sorry, there are no entrees in this category</h2>\n";
      }
      else
      {
         $thispage = $page;
         
         $recordsperpage = 5;
         $offset = ($thispage - 1) * $recordsperpage;
         $totpages = ceil($totrecords / $recordsperpage);

         echo "<table width=\"100%\" cellpadding=\"1\" border=\"1\">\n";


         echo "<tr><td><h2>Image</h2></td>\n";
         echo "<td><h2>Name</h2></td>\n";
         echo "<td><h2>Price</h2></td>\n";
         echo "<td><h2>Store </h2></td>\n";
 echo "<td><h2>Phone</h2></td>\n";
         echo "<td><h2>Description</h2></td>\n";
         echo "<td><h2>Special</h2></td></tr>\n";

         $query = "SELECT * from products WHERE custid=$custid LIMIT $offset,$recordsperpage";
         $result = mysql_query($query);
         while($row=mysql_fetch_array($result, MYSQL_ASSOC))
         {
//not really concerned with this area right now as these below can change
    $custid = $row['custid'];
            $prodid = $row['prodid'];
            $description = $row['description'];
            $price = $row['price'];
            $name = $row['name'];
      $onsale = $row['onsale'];
    
            
 
            echo "<tr><td>\n";
               echo "<img src=\"showimage.php?id=$prodid\" width=\"80\" height=\"60\">";
            echo "</td><td>\n";


               echo "<b><a href=\"$newpage&id=$prodid\">$name\n</b>";
            echo "</td><td>\n";
            echo "$" . $price . "\n";
            echo "</td><td>\n";
             echo "<a href=\"index.php?&content=showstoreinfo&custid=$custid\">";
 
            echo "<font size=\"2\"><u>$storename</u></font>\n";

    
            echo "</td><td>\n";
            echo $phone . "\n";
            echo "</td><td>\n";
            echo $description . "\n";
            
            echo "</td><td>\n";
            if ($onsale)
               echo "On sale!\n";
            else
               echo "&nbsp;\n";
            
         }


         echo "</table>\n";

   // Code to implement paging
         if ($thispage > 1)
         {
            $page = $thispage - 1;
            $prevpage = "<a href=\"$currentpage&custid=$custid&page=$page\">Previous page</a>";
         } else
         {
            $prevpage = " ";
         }

         if ($thispage < $totpages)
         {
            $page = $thispage + 1;
            $nextpage = "<a href=\"$currentpage&custid=$custid&page=$page\">Next page</a>";
         } else
         {
            $nextpage = " ";
         }

         if ($totpages > 1)
            echo $prevpage . "  " . $nextpage;

      }
   }
?>
--- End code ---


The error says that next page is not defined...?

Thanks for any help. 


ErnieAlex:
Well, traydavid, the following code is where the error is (as you stated!):
               {
                   $content = $_REQUEST['content'];
                   $nextpage = $content . ".inc.php";
                   include($nextpage);
               }
So, just change this for now so it shows the value of $nextpage and then we can see what is wrong.
(Also, there are no () needed for includes...)
               {
                   $content = $_REQUEST['content'];
                   $nextpage = $content . ".inc.php";
                   die ("<br>" . $nextpage . "<br>");
                   include $nextpage;
               }

Tell us the results of where the error is... 

Navigation

[0] Message Index

[*] Previous page

Go to full version