Jump to content

Strict Standards (Error) in my PHP code


leso9903

Recommended Posts

Hello, I'm receiving this:

 

"Strict Standards: Creating default object from empty value in /opt/lampp/htdocs/uppgift6/pizzeria.html on line 40"

When I try to type out some attributes from an xml-document. As I've understood it I'm putting something in an empty variable(?) - how do I fix this.

<?phpinclude_once("JSON.php");$json = new Services_JSON();$pizzeria = "pizzeria.xml";$writedir = "writehere";$pizzeria = $writedir."/pizzeria.xml";$sxe = simplexml_load_file($pizzeria);$result = array();foreach ($sxe->menu->pizza as $pizza->ingredient) { // $result[] = (string)$pizza->ingredient["units"];      $result[] = (string)$pizza->ingredient["id"];}echo $json->encode($result);?>

XML

<?xml version="1.0" encoding="utf-8"?><pizzeria>  <menu>    <pizza id="5">      <name>Al tonno</name>      <description>A simple pie with Tunafish</description>      <popularity>50</popularity>      <ingredient id="1" units="2" />      <ingredient id="2" units="2" />      <ingredient id="4" units="4" />      <ingredient id="5" units="2" />    </pizza>    <pizza id="1">      <name>Margherita</name>      <description>The simple vegetarian choice</description>      <popularity>99</popularity>      <ingredient id="1" units="2" />      <ingredient id="2" units="3" />    </pizza>    <pizza id="8">      <name>Cappriciosa</name>      <description>A classic pizza with ham and mushrooms</description>      <popularity>450</popularity>      <ingredient id="1" units="1" />      <ingredient id="2" units="2" />      <ingredient id="17" units="3" />      <ingredient id="3" units="2" />    </pizza>    <pizza id="2">      <name>Al funghi</name>      <description>Prepared  with fresh mushrooms</description>      <popularity>143</popularity>      <ingredient id="1" units="2" />      <ingredient id="2" units="2" />      <ingredient id="3" units="2" />    </pizza>    <pizza id="3">      <name>Vesuvio</name>      <description></description>      <popularity>345</popularity>      <ingredient id="1" units="2" />      <ingredient id="2" units="2" />      <ingredient id="17" units="3" />    </pizza>    <pizza id="4">      <name>Calzone</name>      <description>A very popular turnover Pizza.</description>      <popularity>634</popularity>      <ingredient id="1" units="2" />      <ingredient id="2" units="2" />      <ingredient id="17" units="3" />    </pizza>    <pizza id="6">      <name>Opera</name>      <description></description>      <popularity></popularity>      <ingredient id="1" units="2" />      <ingredient id="2" units="2" />      <ingredient id="4" units="3" />    </pizza>    <pizza id="7">      <name>Orientale</name>      <description></description>      <popularity>345</popularity>      <ingredient id="1" units="2" />      <ingredient id="2" units="2" />      <ingredient id="14" units="3" />      <ingredient id="5" units="2" />    </pizza>    <pizza id="9">      <name>Campaniola</name>      <description></description>      <popularity></popularity>      <ingredient id="1" units="2" />      <ingredient id="2" units="2" />      <ingredient id="10" units="1" />      <ingredient id="6" units="2" />      <ingredient id="5" units="2" />    </pizza>    <pizza id="10">      <name>Pineapple</name>      <description></description>      <popularity>678</popularity>      <ingredient id="1" units="2" />      <ingredient id="2" units="2" />      <ingredient id="7" units="2" />      <ingredient id="17" units="3" />    </pizza>    <pizza id="11">      <name>Banana</name>      <description></description>      <popularity>230</popularity>      <ingredient id="1" units="2" />      <ingredient id="2" units="2" />      <ingredient id="8" units="2" />      <ingredient id="17" units="2" />    </pizza>    <pizza id="12">      <name>Sultan</name>      <description></description>      <popularity></popularity>      <ingredient id="1" units="2" />      <ingredient id="2" units="2" />      <ingredient id="5" units="2" />      <ingredient id="14" units="3" />      <ingredient id="12" units="1" />    </pizza>    <pizza id="13">      <name>Calamata</name>      <description></description>      <popularity>212</popularity>      <ingredient id="1" units="2" />      <ingredient id="2" units="2" />      <ingredient id="4" units="2" />      <ingredient id="11" units="1" />    </pizza>    <pizza id="14">      <name>Natali</name>      <description></description>      <popularity>33</popularity>      <ingredient id="1" units="2" />      <ingredient id="2" units="2" />      <ingredient id="10" units="1" />      <ingredient id="3" units="1" />      <ingredient id="6" units="1" />    </pizza>    <pizza id="15">      <name>Orientale special</name>      <description></description>      <popularity>90</popularity>      <ingredient id="1" units="3" />      <ingredient id="2" units="2" />      <ingredient id="14" units="3" />      <ingredient id="18" units="1" />      <ingredient id="5" units="2" />    </pizza>    <pizza id="16">      <name>Hawaii</name>      <description></description>      <popularity>247</popularity>      <ingredient id="1" units="2" />      <ingredient id="2" units="2" />      <ingredient id="17" units="3" />      <ingredient id="8" units="1" />      <ingredient id="7" units="1" />      <ingredient id="9" units="1" />    </pizza>    <pizza id="17">      <name>Bussola</name>      <description></description>      <popularity>340</popularity>      <ingredient id="1" units="2" />      <ingredient id="2" units="2" />      <ingredient id="17" units="3" />      <ingredient id="11" units="2" />    </pizza>    <pizza id="18">      <name>Du chef</name>      <description></description>      <popularity>560</popularity>      <ingredient id="1" units="2" />      <ingredient id="2" units="2" />      <ingredient id="14" units="2" />      <ingredient id="3" units="2" />      <ingredient id="13" units="1" />      <ingredient id="5" units="2" />    </pizza>    <pizza id="20">      <name>Romana</name>      <description></description>      <popularity>74</popularity>      <ingredient id="1" units="2" />      <ingredient id="2" units="2" />      <ingredient id="11" units="3" />      <ingredient id="3" units="2" />    </pizza>    <pizza id="21">      <name>La Bella</name>      <description></description>      <popularity>344</popularity>      <ingredient id="1" units="2" />      <ingredient id="2" units="2" />      <ingredient id="10" units="3" />      <ingredient id="3" units="2" />    </pizza>    <pizza id="31">      <name>Chicken Pizza</name>      <description></description>      <popularity>184</popularity>      <ingredient id="1" units="2" />      <ingredient id="2" units="2" />      <ingredient id="19" units="2" />      <ingredient id="12" units="1" />      <ingredient id="9" units="2" />      <ingredient id="5" units="1" />      <ingredient id="15" units="1" />    </pizza>    <pizza id="47">      <name>Texas</name>      <description>American pan pizza</description>      <popularity>281</popularity>      <ingredient id="1" units="3" />      <ingredient id="2" units="4" />      <ingredient id="10" units="4" />      <ingredient id="16" units="3" />      <ingredient id="15" units="1" />    </pizza>    <pizza id="48">      <name>Boston</name>      <description>American pan pizza</description>      <popularity>281</popularity>      <ingredient id="1" units="3" />      <ingredient id="2" units="4" />      <ingredient id="4" units="3" />      <ingredient id="11" units="2" />      <ingredient id="16" units="1" />    </pizza>  </menu>  <storage>    <ingredient id="1" name="Tomato Sauce" in_storage="256" />    <ingredient id="2" name="Cheese" in_storage="25" />    <ingredient id="3" name="Mushroom" in_storage="3" />    <ingredient id="4" name="Tunafish" in_storage="6" />    <ingredient id="5" name="Onions" in_storage="29" />    <ingredient id="6" name="Olives" in_storage="29" />    <ingredient id="7" name="Pineapple" in_storage="178" />    <ingredient id="8" name="Banana" in_storage="121" />    <ingredient id="9" name="Curry" in_storage="670" />    <ingredient id="10" name="Salami" in_storage="34" />    <ingredient id="11" name="Shrimps" in_storage="93" />    <ingredient id="12" name="Fresh Tomatos" in_storage="23" />    <ingredient id="13" name="Tabasco" in_storage="17" />    <ingredient id="14" name="Minced Meat" in_storage="123" />    <ingredient id="15" name="Paprika" in_storage="17" />    <ingredient id="16" name="Gorgonzola" in_storage="17" />    <ingredient id="17" name="Ham" in_storage="54" />    <ingredient id="18" name="Eggs" in_storage="180" />    <ingredient id="19" name="Chicken" in_storage="121" />    <ingredient id="20" name="Kebab" in_storage="151" />  </storage></pizzeria>
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...