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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
phphunger
Forum Commoner
Posts: 45
Joined: Tue Aug 11, 2009 11:56 pm

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

Post 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>
 
User avatar
mrvijayakumar
Forum Commoner
Posts: 58
Joined: Tue Aug 18, 2009 12:39 am
Location: Chennai city, India
Contact:

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

Post 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>";
phphunger
Forum Commoner
Posts: 45
Joined: Tue Aug 11, 2009 11:56 pm

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

Post by phphunger »

Thank you mrvijayakumar..Thanks for your immediate response..
Post Reply