Monday 15 March 2010

PHP loop error message -


I am new to php code posting along with php. So if any information is missing, please let me know I am trying to list a list of echo through a foreach loop. I am not sure whether the mistake is just syntax or something bigger than that or not. Here is the error message:

  Home Product List Code Name Version Release Date (!) Warning: foreach () / application / XAMPP / xamppfiles / htdocs / tech_support / product_manager / line 15 call stack # Time memory function location 1 0.0004 247496 {main} () ../index.phpedia 2 0.0024 273008 included ('/ application / xmpp / xamppfiles / htdocs / tech_support / product_manager / product_list. Php') ../index.php : 20  

Here is the product_list php.

  & lt ;? Php include '../view/header php'; ? & Gt; & Lt; H1 & gt; Product List & lt; / H1> & Lt ;! - Display a table of products - & gt; & Lt; H2 & gt; & Lt ;? Resonate php $ products; ? & Gt; & Lt; / H2 & gt; & Lt; TR & gt; & Lt; Th & gt; Code & lt; / Th & gt; & Lt; Th & gt; Name & lt; / Th & gt; & Lt; Th & gt; Version & lt; / Th & gt; & Lt; Th & gt; Release date & lt; / Th & gt; & Lt; Th & gt; & Nbsp; & Lt; / Th & gt; & Lt; / TR & gt; & Lt ;? Php foreach ($ product $ as product):? & Gt; // & lt; ----- Line 15 & lt; Tr & gt; & Lt; Td> & Lt ;? Php ek $ product ['product_id']; ? & Gt; & Lt; / TD & gt; & Lt; Td> & Lt ;? Php $ product ['name']; ? & Gt; & Lt; / TD & gt; & Lt; Td square = "true" & gt; & Lt ;? Php $ product ['version']; ? & Gt; & Lt; / TD & gt; & Lt; Td> & Lt; Form action = "." Method = "post" & gt; & Lt; Input type = "hidden" name = "product_id" value = "& lt ;? php resonance $ product ['release date'] ;? gt; gt;" Gt; & Lt; Input type = "submit" value = "delete" & gt; & Lt; / Form & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt ;? Php endforeach; ? & Gt; & Lt; P & gt; & Lt; A href = "? Action = show_ad_form" & gt; Add Products & lt; / A & gt; & Lt; / P & gt; & Lt ;? Php includes '../view/footer.php'; ? & Gt;  

I have the code in my index folder.

  & lt ;? Php is required ('../method/database.php'); Required ('../model/product_db.php'); $ Action = filter_input (INPUT_POST, 'verb'); If ($ action === null) {$ action = filter_input (INPUT_GET, 'action'); If ($ action === null) {$ action = 'list_products'; }} If ($ action == 'list_products') {$ product_id = filter_input (INPUT_GET, 'product_id', FILTER_VALIDATE_INT); If ($ product_id == faucet || $ product_id == incorrect) {$ product_id = 1; } $ Products = get_product ($ product_id); ('Product_list.php'); } And if ($ action == 'show_add_form') {$ product = get_product ($ product_id); ('Product_add.php'); .......  

Just here is my database function

  & lt; Php function get_product ($ product_id) {global $ db; $ Query = 'SELECT * products with WHERE productCode =: product_id'; $ Statement = $ db- & gt; Ready ($ query); $ Statement- & gt; Bind value (": product_id", $ product_id); $ Statement & gt; Executed (); $ Products = $ statement- & gt; Fetch (); $ Statement & gt; CloseCursor (); $ Return of products; }? & Gt;  

If $ products is an object that you try Type it before using it in the loop like this:

$ array = (array) $ yourObject;


No comments:

Post a Comment