Jump to content

Undefined variable error message when running code


hance2105

Recommended Posts

hello guys,

 

when i run the code below, i get the following error message - Undefined variable: prod_id in C:\wamp\www\buysmart_site\my_list.php on line 50

 

<?php session_start(); include "db_connect.php"; $username = $_SESSION['username']; $sql=mysql_query("select user_id from tbllogin where username = '$username'"); $row=mysql_fetch_array($sql); $sql1 = mysql_query("select a.prod_name, a.prod_photo from tbl_product a, tblfavourites b where a.prod_id=b.prod_id AND b.user_id='$row[user_id]'"); $row1=mysql_fetch_array($sql1); if($row1){            echo "<table border='0'>";//start table                            // our table heading                echo "<tr>";                    echo "<th class='textAlignLeft'>Name</th>";                    echo "<th>Product</th>";                    echo "<th>Action</th>";                echo "</tr>";                                //also compute for total price                $totalPrice = 0;                                while ($row1 = mysql_fetch_assoc($sql1)){                    extract($row1);                                        //$totalPrice += $prod_price;                                        //creating new table row per record                    echo "<tr>";                        echo "<td>{$prod_name}</td>";                        echo '<td><img height="100" width="100" src="Images/Products/'.$row1['prod_photo'].'"/></td>';                        echo "<td class='textAlignCenter'>";                        echo "<a href='removefav.php?prod_id={$prod_id}&prod_name={$prod_name}' class='customButton'>";                        echo "<img src='' title='Remove from favourite' />";                        echo "</a>";                        echo "</td>";                    echo "</tr>";                }                             /*  echo "<tr>";                    echo "<th class='textAlignCenter'>Total Price</th>";                    echo "<th class='textAlignRight'>{$totalPrice}</th>";                    echo "<th></th>";                echo "</tr>";                            echo "</table>";            echo "<br /><div><a href='#' class='customButton'>Home</a></div>";        }else{            echo "<div>No products found in your favourites. </div>";        }     //else{        echo "<div>No products in favourites yet.</div>";//} */} ?> 

 

the prod_id is the product id that is stored in 2 tables - tbl_product and tblfavourites

 

how can i sort this issue out?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.