Jump to content

Fatal error: Function name must be a string in W:\www\blog\index.php on line 14


soc86

Recommended Posts

I am having more trouble with my code, please see the error below when loading my browser:

 

Here is my blog

Fatal error: Function name must be a string in W:\www\blog\index.php on line 14

 

My code is:

 

<?php
mysql_connect ("localhost", "root", "gwalia");
mysql_select_db("blog");
?>
<html>
<head>
<title>Show My Blog</title>
</head>
<body>
Here is my blog<hr/>
<?php
$sql = mysql_query("SELECT * FROM blogdata ORDER BY id DESC");
While($row = mysql_fetch_array($sql)){
$title = $row('title');
$content = $row('content');
$category = $row('category');
?>


<table border='1'>
<tr><td><?php echo $title; ?></td><td><?php echo $category; ?></td></tr>
<tr><td colspan='2'><?php echo $content; ?></td><td></tr>
</table>
<?php
}


?>

</body>
</html>

 

Line 14 is '$title = $row('title');'.  But i do not know what is wrong with my code, help please?

AyKay is correct.

 

I also see an issue where you are setting a variable....

$title = $row['title'];

 

And then just echoing it later.

<?php echo $title; ?>

 

Unless you are modifying the variable for some reason you are just bring up memory.  To be more efficient just REMOVE this line..

$title = $row['title'];

 

And in your echo statement just do this..

<?php echo $row['title']; ?>

Unless you are modifying the variable for some reason you are just bring up memory.

For a string value it's a negligible amount. If the coder has an easier time dealing with a second variable (which any decent IDE's intellisense would discover) then it's definitely in his/her favor to use it.

Archived

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

×
×
  • Create New...

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.