Matpatnik Posted January 21, 2007 Share Posted January 21, 2007 Hi guys,Is there a way to do something like this or maybe I did a mistake: if ($action == "edit") { $actionsql = "WHERE type_id=" . $_GET['id']; } else { $actionsql = "ORDER BY type_id"; } $sql = "SELECT type_id, type_name " . "FROM type '" . $actionsql . "'"; $result = mysql_query($sql) or die("<font color=\"#FF0000\">Query Error</font>" . mysql_error()); while ($row = mysql_fetch_array($result)) { $type_name = $row['type_name'];?> It was just a test and it failed it give me this error message Query Error 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 ''WHERE type_id=3'' at line 1Thank you for your help Link to comment Share on other sites More sharing options...
Escee Posted January 21, 2007 Share Posted January 21, 2007 You've got the WHERE or ORDER clause between quotes: '" . $actionsql . "' Will be: FROM type 'WHERE type_id=3' Must be: FROM type WHERE type_id=3 So remove the quotes ('). Link to comment Share on other sites More sharing options...
Matpatnik Posted January 23, 2007 Author Share Posted January 23, 2007 Oh I see,it work now thank you Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now