Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 336
  • Last Modified:

PHP bug in code - assistance needed.

Hi all,

I'm having some problem with some code.
This problem is that it's showing up on the page as text (displaying the php code as text) instead of listing the db data.

 Here is the code:

Thanks
<?php
    try
      {
       $connection = mysql_connect("localhost","username","password");
       mysql_select_db("database-name", $connection);
       $result = mysql_query("SELECT * FROM my-table");
 
      while($row = mysql_fetch_array($result))
        {
         echo "<li>";
	 echo "<h2>" . $row['date'] . "</h2>";
	 echo  . $row['textarea'] . "<p class='ui-li-aside'>" . $row['date'] . "<strong></p>";
        }
 
        mysql_close($connection);
           }
          catch(Exception $e)
             {
               echo $e->getMessage();
             }
   ?>

Open in new window

0
error77
Asked:
error77
  • 3
1 Solution
 
owner66Commented:
PHP is running correclty?
0
 
error77Author Commented:
Yes, I think it's a syntax error in the code but I haven't been about to spot it yet.
0
 
error77Author Commented:
Fixed it:

while($row = mysql_fetch_array($result))
       {
         echo $row['date'];
       echo $row['textarea'];
                                          
       }

That did it.
0
 
error77Author Commented:
I managed to sort me problem out. Solution added.
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now