jd2007 Posted August 21, 2007 Share Posted August 21, 2007 select $this->id, $this->title, $this->thumbnail from $this->table order by 'select $this->past from $this->table2' the above is my query....what's wrong ? this is the 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 'from flash order by 'select past from awards'' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/65961-my-query-is-resulting-in-errorwhy/ Share on other sites More sharing options...
AndyB Posted August 21, 2007 Share Posted August 21, 2007 ... and this gives what error? Quote Link to comment https://forums.phpfreaks.com/topic/65961-my-query-is-resulting-in-errorwhy/#findComment-329789 Share on other sites More sharing options...
jd2007 Posted August 21, 2007 Author Share Posted August 21, 2007 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 'from flash order by 'select past from awards'' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/65961-my-query-is-resulting-in-errorwhy/#findComment-329790 Share on other sites More sharing options...
pranav_kavi Posted August 21, 2007 Share Posted August 21, 2007 echo the query so to check if it s valid. Quote Link to comment https://forums.phpfreaks.com/topic/65961-my-query-is-resulting-in-errorwhy/#findComment-329793 Share on other sites More sharing options...
jd2007 Posted August 21, 2007 Author Share Posted August 21, 2007 i want to take three columns from a table, one of the column is related to another table. column title, id, thumb is in table 1, column id, past, title is in table 2, i want title, id, thumb from table 1 ordered by past in table 2. Quote Link to comment https://forums.phpfreaks.com/topic/65961-my-query-is-resulting-in-errorwhy/#findComment-329796 Share on other sites More sharing options...
pranav_kavi Posted August 21, 2007 Share Posted August 21, 2007 can u post the the section of ur db code? Quote Link to comment https://forums.phpfreaks.com/topic/65961-my-query-is-resulting-in-errorwhy/#findComment-329801 Share on other sites More sharing options...
jd2007 Posted August 21, 2007 Author Share Posted August 21, 2007 its valid function latestSubmissionAwards($ext="") { if ($ext=="") { $this->que="select $this->id, $this->title, $this->thumb from $this->table order by $this->past desc limit 5"; $this->res=mysql_query($this->que); $this->showSubm(); } else { $this->table2=$ext; $this->que="select $this->id, $this->title, $this->thumbnail from $this->table order by 'select $this->past from $this->table2"; $this->res=mysql_query($this->que); $this->showSubm(); } } Quote Link to comment https://forums.phpfreaks.com/topic/65961-my-query-is-resulting-in-errorwhy/#findComment-329807 Share on other sites More sharing options...
pranav_kavi Posted August 21, 2007 Share Posted August 21, 2007 try adding a single quote at the end of the query bfore u close the double quotes. $this->que="select $this->id, $this->title, $this->thumbnail from $this->table order by 'select $this->past from $this->table2'"; Quote Link to comment https://forums.phpfreaks.com/topic/65961-my-query-is-resulting-in-errorwhy/#findComment-329810 Share on other sites More sharing options...
zgkhoo Posted August 21, 2007 Share Posted August 21, 2007 wat is this "->" symbol for? Quote Link to comment https://forums.phpfreaks.com/topic/65961-my-query-is-resulting-in-errorwhy/#findComment-329813 Share on other sites More sharing options...
jd2007 Posted August 21, 2007 Author Share Posted August 21, 2007 it still doesn't work. wat is this "->" symbol for? it used for reference in oop. Quote Link to comment https://forums.phpfreaks.com/topic/65961-my-query-is-resulting-in-errorwhy/#findComment-329822 Share on other sites More sharing options...
pranav_kavi Posted August 21, 2007 Share Posted August 21, 2007 in which part of the code r u printing out the table values? Quote Link to comment https://forums.phpfreaks.com/topic/65961-my-query-is-resulting-in-errorwhy/#findComment-329827 Share on other sites More sharing options...
Illusion Posted August 21, 2007 Share Posted August 21, 2007 ORDER BY clause expect a column name next to that not the values. ..............order by $this->table2.$this->past ; Quote Link to comment https://forums.phpfreaks.com/topic/65961-my-query-is-resulting-in-errorwhy/#findComment-329833 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.