Reply to Re: Newbie - Notice:Undefined index:

Your name:

Reply:


Posted by darren on 06/14/05 13:44

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/
>
>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация