You are here: Re: [PHP] undefined index « PHP « IT news, forums, messages
Re: [PHP] undefined index

Posted by Philip Hallstrom on 06/16/05 22:52

> I have a bit of code that splices up a cookie into 4 bits so the information
> can be displayedin a neat way in a table
>
>
>
> if ($quantity == 0){
>
> }
> else {
>
> $pieces = explode(" ", $quantity);
> $formatted_price = sprintf('%0.2f', $pricecode);
> echo "<table width=\"240\" border=\"0\" cellpadding=\"2\"
> cellspacing=\"5\"><tr><td valign=\"top\" align=\"right\"
> width=\"40\">$pieces[0]</td><td align=\"left\" width=\"60\"></td><td
> align=\"left\" width=\"200\">$pieces[1] $pieces[2] $pieces[3]
> $pieces[4]</td><td valign=\"top\" align=\"left\"
> width=\"80\">$formatted_price</td></tr></table>";
>
> }
> }
>
> The trouble is I get a NOTICE that tells me the indexes 1 to 4 have not been
> defined. how do I do this.

What is the output of:

print_r($pieces) if placed right after the explode() line? Maybe
$quantity isn't what you think it is...

 

Navigation:

[Reply to this 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

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