Jump to content

Undefined variable error message when running code


Go to solution Solved by Psycho,

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.