deansaddigh Posted November 19, 2009 Share Posted November 19, 2009 im getting an error and i think its my where clause basically i want to perform an sql query based on my where clause which is the product id passed from the previous page. any help would be wicked. //get the product id $_GET['productid']; //************************************************************************** //sql statement to join tables to get products $query = "select product.ProductID, product.ProductName, product.ProductCategory, product.ProductPrice, product.ProductQuantity, product.ProductDescription, image.ImageID, image.ImagePath, image.ImageName, product_image.ImageID, product_image.ProductID FROM product WHERE ProductID='productid'); JOIN product_image ON product.ProductID = product_image.ProductID JOIN image ON image.ImageID = product_image.ImageID"; //execute query or die $result = mysql_query($query, $conn) or die ("Unable join tables"); Quote Link to comment https://forums.phpfreaks.com/topic/182144-solved-i-think-my-where-clause-is-wrong/ Share on other sites More sharing options...
rajivgonsalves Posted November 19, 2009 Share Posted November 19, 2009 this //sql statement to join tables to get products $query = "select product.ProductID, product.ProductName, product.ProductCategory, product.ProductPrice, product.ProductQuantity, product.ProductDescription, image.ImageID, image.ImagePath, image.ImageName, product_image.ImageID, product_image.ProductID FROM product WHERE ProductID='productid'); should be //sql statement to join tables to get products $query = "select product.ProductID, product.ProductName, product.ProductCategory, product.ProductPrice, product.ProductQuantity, product.ProductDescription, image.ImageID, image.ImagePath, image.ImageName, product_image.ImageID, product_image.ProductID FROM product WHERE ProductID='".mysql_real_escape_string($_GET['productid'])."'"); Quote Link to comment https://forums.phpfreaks.com/topic/182144-solved-i-think-my-where-clause-is-wrong/#findComment-960963 Share on other sites More sharing options...
deansaddigh Posted November 19, 2009 Author Share Posted November 19, 2009 God you help everyone, thanks again man Quote Link to comment https://forums.phpfreaks.com/topic/182144-solved-i-think-my-where-clause-is-wrong/#findComment-960968 Share on other sites More sharing options...
deansaddigh Posted November 19, 2009 Author Share Posted November 19, 2009 does this look correct cause its chaning everything under the line you wrote to different colours //sql statement to join tables to get products $query = "select product.ProductID, product.ProductName, product.ProductCategory, product.ProductPrice, product.ProductQuantity, product.ProductDescription, image.ImageID, image.ImagePath, image.ImageName, product_image.ImageID, product_image.ProductID FROM product WHERE ProductID='".mysql_real_escape_string($_GET['productid'])."'") JOIN product_image ON product.ProductID = product_image.ProductID JOIN image ON image.ImageID = product_image.ImageID"; Quote Link to comment https://forums.phpfreaks.com/topic/182144-solved-i-think-my-where-clause-is-wrong/#findComment-960981 Share on other sites More sharing options...
rajivgonsalves Posted November 19, 2009 Share Posted November 19, 2009 It should have been this however I don't know the syntax not to good at joins //sql statement to join tables to get products $query = "select product.ProductID, product.ProductName, product.ProductCategory, product.ProductPrice, product.ProductQuantity, product.ProductDescription, image.ImageID, image.ImagePath, image.ImageName, product_image.ImageID, product_image.ProductID FROM product WHERE ProductID='".mysql_real_escape_string($_GET['productid'])."'" JOIN product_image ON product.ProductID = product_image.ProductID JOIN image ON image.ImageID = product_image.ImageID"; Quote Link to comment https://forums.phpfreaks.com/topic/182144-solved-i-think-my-where-clause-is-wrong/#findComment-960983 Share on other sites More sharing options...
deansaddigh Posted November 19, 2009 Author Share Posted November 19, 2009 Thanks man Quote Link to comment https://forums.phpfreaks.com/topic/182144-solved-i-think-my-where-clause-is-wrong/#findComment-960999 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.