Page 1 of 1

Error

Posted: Sun Jan 18, 2009 3:05 pm
by andrewj
hi im tryin to do this code and gettign the error as "
Current Category:Fatal error: Call to undefined function getcategoryname() in /home/webwiz77/public_html/sad/admin/manageproducts.php on line 21"


here is my code[/u]

Code: Select all

 
<?php   include('includes/header.php');
 
        if(!isset($_GET['cat'])) {
            $cat = 0;
        } else {
            $cat = $_GET['cat'];
        }
        
        if($_GET['delete']) {
            $sql = "DELETE FROM ddcart_products WHERE id = '".$_GET['delete']."'";
            $result = mysql_query($sql);
            $deleted = 1;
        }
 
?>
    
        <h2>Manage Products</h2>
        
        <?php if($deleted == 1) echo '<div class="success">Product deleted.</div>'; ?>
        
        <div><strong>Current Category:</strong> <?php echo getCategoryName($cat); ?> (<a href="manageproducts.php?cat=<?php echo getCatParentId($cat); ?>">Go to Parent Category</a>)</div>
        
        <div><strong>Sub-categories:</strong> <?php echo displaySubcats($cat); ?></div>
    
        <h3 style="width: 50%; float: left;">Products In This Category</h3>
        <div style="width: 40%; float: right; text-align: right; margin-top: 10px;"><input type="button" value="Add Product" onclick="window.location='addproduct.php?cat=<?php echo $cat; ?>'" /></div>
        
        <div class="clear"></div>
    
        <table class="producttable" cellpadding="3" cellspacing="0">
            <tr class="products_toprow">
                <td>Product Name</td>
                <td>Price</td>
                <td>Status</td>
                <td>Stock</td>
                <td>Options</td>
            </tr>
            
            <?php
                
                $productsql = "SELECT * FROM ddcart_products WHERE cat = '".$cat."'";
                $productresult = mysql_query($productsql);
                $i = 1;
                while($product = mysql_fetch_assoc($productresult)) {
                ?>
                <tr class="products_regrow1">
                    <td><?php echo $product['name']; ?></td>
                    <td><?php echo priceDisplay($product['price']); ?></td>
                    <td><?php echo parseStatus($product['active']); ?></td>
                    <td><?php echo parseStock($product['stock']); ?></td>
                    <td><a href="addproduct.php?edit=<?php echo $product['id']; ?>"><img src="assets/images/pencil.gif" border="0" alt="Edit Product" /></a><a href="manageproducts.php?cat=<?php echo $cat; ?>&delete=<?php echo $product['id']; ?>" onclick="return confirm('Are you sure you want to delete this product?');"><img src="assets/images/cross.gif" border="0" alt="Edit Product" /></a></td>
                </tr>
                <?php   
                }
            
            ?>
           
            
        </table>
           
        
        
<?php include('includes/footer.php'); ?>
 

Re: Error

Posted: Sun Jan 18, 2009 3:13 pm
by Burrito
moved to PHP code and added php tags for you. Please post in the correct forums and use PHP tags when posting code in the future.

Re: Error

Posted: Sun Jan 18, 2009 3:40 pm
by andrewj
ok thanks:)

Re: Error

Posted: Sun Jan 18, 2009 4:40 pm
by Mark Baker
So where is the function getcategoryname() defined?