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?

Link to comment
Share on other sites

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']; ?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.