|  | Posted by darren on 06/14/05 16:48 
Thanks Joseph,
 Don't really understand what I've done but it works.
 
 Darren
 
 "Joseph Melnick" <jmelnick@jphp.com> wrote in message
 news:U-udnXX38YCZVTPfRVn-rA@rogers.com...
 > Hello Darren,
 >
 > I think that the offending line Is the If statement below as
 > $_GET["cat_id"] may not exist:
 >        if ( $_GET["cat_id"] == "$cat_id") {
 >
 > to fix this you could use a statement like th one below.
 >        if (array_key_exists("cat_id",$_GET) and $_GET["cat_id"] ==
 > "$cat_id") {
 >
 > Cheers
 >
 > Joseph Melnick
 > JM Web Consultants
 > http://www.jphp.com/
 >
 >
 >
 >
 > "darren" <darren@NOSPAMemdnet.co.uk> wrote in message
 > news:d8mcf1$4vk$1@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com...
 >> Thanks,
 >>
 >> I put the quotes in and I am now left with 3 error messages:-
 >>
 >> Notice: Undefined index: cat_id in c:\program
 >> files\easyphp1-7\www\phpshop\seestore.php on line 26
 >>
 >> Notice: Undefined index: cat_id in c:\program
 >> files\easyphp1-7\www\phpshop\seestore.php on line 26
 >>
 >> Notice: Undefined index: cat_id in c:\program
 >> files\easyphp1-7\www\phpshop\seestore.php on line 26
 >>
 >>
 >> <?php
 >> //connect to database
 >> $conn = mysql_connect("localhost", "darrenludlam", "dazza5972") or
 >> die(mysql_error());
 >> mysql_select_db("phpshop",$conn)  or die(mysql_error());
 >>
 >> $display_block = "<h1>My Categories</h1>
 >> <P>Select a category to see its items.</p>";
 >>
 >> //define variables
 >> //$cat_id="0";
 >>
 >> //show categories first
 >> $get_cats = "select id, cat_title, cat_desc from store_categories order
 >> by cat_title";
 >> $get_cats_res = mysql_query($get_cats) or die(mysql_error());
 >>
 >> if (mysql_num_rows($get_cats_res) < 1) {
 >>   $display_block = "<P><em>Sorry, no categories to browse.</em></p>";
 >> } else {
 >>   while ($cats = mysql_fetch_array($get_cats_res)) {
 >>        $cat_id  = $cats["id"];
 >>        $cat_title = strtoupper(stripslashes($cats["cat_title"]));
 >>        $cat_desc = stripslashes($cats["cat_desc"]);
 >>
 >>        $display_block .= "<p><strong><a
 >> href=\"$_SERVER[PHP_SELF]?cat_id=$cat_id\">$cat_title</a></strong><br>$cat_desc</p>";
 >>
 >>        if ($_GET["cat_id"] == "$cat_id") {
 >>           //get items
 >>           $get_items = "select id, item_title, item_price from
 >> store_items where cat_id = $cat_id order by item_title";
 >>           $get_items_res = mysql_query($get_items) or die(mysql_error());
 >>
 >>           if (mysql_num_rows($get_items_res) < 1) {
 >>                $display_block = "<P><em>Sorry, no items in this
 >> category.</em></p>";
 >>           } else {
 >>                $display_block .= "<ul>";
 >>
 >>                while ($items = mysql_fetch_array($get_items_res)) {
 >>                   $item_id  = $items[id];
 >>                   $item_title = stripslashes($items[item_title]);
 >>                   $item_price = $items[item_price];
 >>
 >>                   $display_block .= "<li><a
 >> href=\"showitem.php?item_id=$item_id\">$item_title</a></strong>
 >> (\$$item_price)";
 >>                }
 >>
 >>                $display_block .= "</ul>";
 >>           }
 >>       }
 >>   }
 >> }
 >> ?>
 >> <html>
 >> <HEAD>
 >> <TITLE>My Categories</TITLE>
 >> </HEAD>
 >> <BODY>
 >> <? print $display_block; ?>
 >> </BODY>
 >> </HTML>
 >>
 >> Many thanks
 >>
 >> Darren
 >>
 >> "rush" <pipa@rush.avalon.hr> wrote in message
 >> news:d8m8j9$b9i$1@ss405.t-com.hr...
 >>> "darren" <darren@NOSPAMemdnet.co.uk> wrote in message
 >>> news:d8m3nf$bau$1@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com...
 >>>> Hello I have just copied the code below from a book and I get the
 >>> following
 >>>> errors but the code does actually work.  Is it a problem with relative
 >>>> paths?
 >>>
 >>> nope, it is problem with undeclared string constants.
 >>>
 >>> Older versions of php would let you write something like:
 >>>
 >>> $a = some_my_stuff ;
 >>>
 >>> if some_my_stuff was not declared at this point as constant, php would
 >>> autodeclare it to be 'some_my_stuff'
 >>>
 >>> So number of people got used to write some simple string constants (like
 >>> some_my_stuff) without quotes, which was rather sloppy habit. To
 >>> mittigate
 >>> situations never versions of php started complaining about it.
 >>>
 >>> Best thing you can do is to go through your list of errors, and on each
 >>> line
 >>> mentioned you will find some unquoted string constant (also mentioned in
 >>> error message). Put quotes aroind it, and you are done.
 >>>
 >>> rush
 >>> --
 >>> http://www.templatetamer.com/
 >>> http://www.folderscavenger.com/
 >>>
 >>>
 >>
 >>
 >
 >
  Navigation: [Reply to this message] |