thomashw Posted January 8, 2008 Share Posted January 8, 2008 Can someone tell me what's wrong with this? I am getting an error saying there is something wrong with the SQL syntax. $result = mysql_query("SELECT * FROM product, product_attributes, product_options WHERE product.product_id={$id} AND product_attributes.options_id=product_options.product_options_id, product_options.product_options_id=product_options_values_to_product_options.product_options_id, product_options_values_to_product_options.product_options_values_id=product_options_values.product_options_values_name") or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/85084-solved-select-statement/ Share on other sites More sharing options...
revraz Posted January 8, 2008 Share Posted January 8, 2008 Post that error Quote Link to comment https://forums.phpfreaks.com/topic/85084-solved-select-statement/#findComment-433937 Share on other sites More sharing options...
Ken2k7 Posted January 8, 2008 Share Posted January 8, 2008 What are you trying to do? Quote Link to comment https://forums.phpfreaks.com/topic/85084-solved-select-statement/#findComment-433938 Share on other sites More sharing options...
thomashw Posted January 8, 2008 Author Share Posted January 8, 2008 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' product_options.product_options_id=product_options_values_to_product_options.' at line 4 Quote Link to comment https://forums.phpfreaks.com/topic/85084-solved-select-statement/#findComment-433939 Share on other sites More sharing options...
GingerRobot Posted January 8, 2008 Share Posted January 8, 2008 You should be using AND, not a comma to separate the different conditions of the WHERE clause: <?php $result = mysql_query("SELECT * FROM product, product_attributes, product_options WHERE product.product_id={$id} AND product_attributes.options_id=product_options.product_options_id AND product_options.product_options_id=product_options_values_to_product_options.product_options_id AND product_options_values_to_product_options.product_options_values_id=product_options_values.product_options_values_name") or die(mysql_error()); ?> Quote Link to comment https://forums.phpfreaks.com/topic/85084-solved-select-statement/#findComment-433940 Share on other sites More sharing options...
thomashw Posted January 8, 2008 Author Share Posted January 8, 2008 I might as well post the whole code. If you see any problems with it please let me know! <? $result = mysql_query("SELECT * FROM product, product_attributes, product_options WHERE product.product_id={$id} AND product_attributes.options_id=product_options.product_options_id, product_options.product_options_id=product_options_values_to_product_options.product_options_id, product_options_values_to_product_options.product_options_values_id=product_options_values.product_options_values_name") or die(mysql_error()); $count = 0; while($name = mysql_fetch_assoc($result)) { if(mysql_num_rows($name) > 0) { if($count==0) { echo "<tr>\n<td>\n<label>\n<span>"; echo $name["product_options_name"]; echo "</label></span></td>"; ++$count; }}} echo "<tr>\n<td>"; echo "<td align=\"left\" class=\"productdrop\">"; echo "<select name=\"cat1\">"; $count = 0; while($form = mysql_fetch_assoc($result)) { if(mysql_num_rows($result) > 0) { if($count==0) { echo "<option value=\"Quantity: 16\">$form[product_options_values_name]</option>"; }}} ?> Quote Link to comment https://forums.phpfreaks.com/topic/85084-solved-select-statement/#findComment-433941 Share on other sites More sharing options...
Ken2k7 Posted January 8, 2008 Share Posted January 8, 2008 Did you read GingerRobot's post? Quote Link to comment https://forums.phpfreaks.com/topic/85084-solved-select-statement/#findComment-433943 Share on other sites More sharing options...
thomashw Posted January 8, 2008 Author Share Posted January 8, 2008 Yep, I was posting at the same time as him. I feel like an idiot now. Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/85084-solved-select-statement/#findComment-433945 Share on other sites More sharing options...
GingerRobot Posted January 8, 2008 Share Posted January 8, 2008 No problem. Can you mark this as solved if you're all done? Quote Link to comment https://forums.phpfreaks.com/topic/85084-solved-select-statement/#findComment-433950 Share on other sites More sharing options...
thomashw Posted January 8, 2008 Author Share Posted January 8, 2008 Okay. Done. Quote Link to comment https://forums.phpfreaks.com/topic/85084-solved-select-statement/#findComment-433956 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.