Page 1 of 1

Fatal error: Function name must be a string in C:\.....

Posted: Wed Aug 19, 2009 1:07 am
by phphunger
Hi,

As i am practicing the php with mysql database in that i am getting a fatal error as follows
Connection Success!!!
Fatal error: Function name must be a string in C:\xampp\htdocs\WishList\test.php on line 28

I have created a table 'cars' in the 'test' database. I want to fetch the results from the database. But i am not getting.
Can anyone tell me why i am getting this error.

Code:

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
 
        <?php
 
            //connection parameters
            $username = "root";
            $password = "";
            $dbhost = "localhost";
 
            //connection to database
            $dbconnection = mysql_connect($dbhost, $username, $password) or die("Could not connect to MySQL Database");
            echo "Connection Success!!!";
 
            //working with particular database
            $dbhandle = mysql_select_db("test", $dbconnection) or die("Could not select the test database");
 
            //execute query and return results
            $resultsett = mysql_query("SELECT id, name, year FROM cars");
 
            //fetch the data from the database test
            while($row = mysql_fetch_array($resultsett)){
                echo "ID:" .$row('id')." Name:".$row('name'). " Year:".$row('year')."<br>";
            }
 
       ?>
        
    </body>
</html>
 

Re: Fatal error: Function name must be a string in C:\.....

Posted: Wed Aug 19, 2009 1:24 am
by mrvijayakumar
Hi phphunger,

Problem in this line, replace line 28 with following code,

Code: Select all

echo "ID:" .$row['id']." Name:".$row['name']. " Year:".$row['year']."<br>";

Re: Fatal error: Function name must be a string in C:\.....

Posted: Wed Aug 19, 2009 3:51 am
by phphunger
Thank you mrvijayakumar..Thanks for your immediate response..