Page 1 of 1

Page will not display

Posted: Mon Mar 21, 2011 2:55 pm
by ericjb9
I am building a website for a candle company. I have a products page with a number of links to specific product pages. For example, the Banana Nut Bread link goes to the Banana Nut Bread page with an image, pricing, and description. I am doing this using ?detail_id=$id, so I have one page for every product in my database based on the id. I have links on the page to display images of different sizes. I am pulling the images from a mysql database. Everything works fine when I set an id my query to pull the images, but when I want to to pull the image based on the detail_id, the page is blank saying dead query. Please someone give me an awnser.

Code: Select all

<?php
include("products/func_lib.php");
$chosen_id=$_GET['detail_id'];
$selectall=querydb("select * from product_table where $id=$chosen_id");
$title=querydb("select name from product_table where $id=$chosen_id");
$selectNavSoy=querydb("select $id,name from product_table where $id in (28,29,30,31) order by $id");
$selectNavParaffin=querydb("select $id,name from product_table where $id<28 order by $id");

$row=mysql_fetch_array($title);
$name=$row['name'];
?>

	<?php
    $row=mysql_fetch_array($selectall);
	$name=$row['name'];
    $meltimg=$row['meltimg'];
    $image=$row['image'];
	$desc=$row['description'];
	
	echo "<div id='productname'><h2>$name</h2></div><br /><br /><br /><br />";
	
    switch($_GET['i']){
        case m:
            echo "<img src='images/$meltimg' id='productimage' />";
        break;
        
        case tf:
            echo "<img src='images/$image' id='productimage' />";
        break;
		
		default:
		echo "<img src='images/$image' id='productimage' />";
    }
 
    echo "<div id='productprice'><strong>Price:</strong><br />
    <a href='?i=tf'>24 oz</a><br />
    <a href='?i=m'>Melts</a>
    </div>";
    
    echo "<div id='productdesc'><strong>Description:</strong><br />
	$desc<br /><br />
    </div>";
    ?>

Re: Page will not display

Posted: Mon Mar 21, 2011 2:59 pm
by danwguy
Are you sure you want to be using "WHERE $id=$chosen_id" and not "WHERE id=$chosen_id"? I'm assuming you have a table in your database named id and that's what you are trying to select from but saying "WHERE $id=$chosen_id" is saying WHERE (variable)id=(variable)chosen_id.