PHP bug in code - assistance needed.

Posted on 2011-04-20
Last Modified: 2012-05-11
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:

       $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>";
          catch(Exception $e)
               echo $e->getMessage();

Open in new window

Question by:error77
    LVL 4

    Expert Comment

    PHP is running correclty?

    Author Comment

    Yes, I think it's a syntax error in the code but I haven't been about to spot it yet.

    Accepted Solution

    Fixed it:

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

    That did it.

    Author Closing Comment

    I managed to sort me problem out. Solution added.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now