Jump to content


This topic is now archived and is closed to further replies.


SQL error

Recommended Posts

Hello, I have connected to the database and everthing like that its just i get this error:


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


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 help

// classes.php contains all the classes
$myclass = new web;
$upload_class->page = "index";
$upload_class->table = "index";



Heres the classes.php:
(ive lefted out the class web bit and the connect() function)
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!";




- Cheers, Daniel

N e solutions please tell me cause i have no clue

Share this post

Link to post
Share on other sites
[code] $myclass = new web;
$upload_class->page = "index";
$upload_class->table = "index";


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.


Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.