Drezard Posted October 19, 2006 Share Posted October 19, 2006 Hello, I have connected to the database and everthing like that its just i get this error:[QUOTE]Error in query: SELECT FROM . 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' at line 1[/QUOTE]Hes the code, I have 2 files ones called classes.php and the other is index.php. Now classes.php contains the necessary functions to connect to the mysql, it connects but it just gives me that error. I want index.php to display the info in the database under the table index and field index through the homemade function in classes.php called Heres the two bits ull need to helpindex.php:[CODE]include('classes.php'); // classes.php contains all the classes $myclass = new web; $upload_class->page = "index"; $upload_class->table = "index"; $myclass->connect(); $myclass->display_information();[/CODE]Heres the classes.php:(ive lefted out the class web bit and the connect() function)[CODE]function display_information() { $page = trim($this -> page);$table = trim($this -> table); $query = "SELECT $page FROM $table"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); if (mysql_num_rows($result) > 0) { echo "<table cellpadding=10 border=1>"; while($row = mysql_fetch_row($result)) { echo "<tr>"; echo "<td>".$row[0]."</td>"; echo "</tr>"; } echo "</table>"; } else { echo "No rows found!"; } mysql_free_result($result); mysql_close($connection); }[/CODE]- Cheers, DanielN e solutions please tell me cause i have no clue Quote Link to comment Share on other sites More sharing options...
Drezard Posted October 19, 2006 Author Share Posted October 19, 2006 help me please. Quote Link to comment Share on other sites More sharing options...
pnj Posted October 19, 2006 Share Posted October 19, 2006 [code] $myclass = new web; $upload_class->page = "index"; $upload_class->table = "index"; $myclass->display_information();[/code]The error suggests $this->page and $this->table are not set in the class function.In your code, you have initialized the fields page and table in the $upload_class variable, but then called display_information() with the $myclass variable, so page and table are empty.Cheers,pnj Quote Link to comment 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.