Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

php error

Options
  • 16-08-2002 6:45pm
    #1
    Registered Users Posts: 1,747 ✭✭✭


    This is my very fist attempt at php and mysql (first attempt at programing at all if you discount html and actionscript) so sorry for what is bound to be a simplistic mistake.

    Im getting a parse error in this line:

    "<table width="300" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td class="date">"
    echo "Entry Date : ".htmlspecialchars($date).;
    "</td>
    </tr>
    </table>

    <table width="300" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td class="text">"
    echo "Comments:<br> ".htmlspecialchars($comments).;
    "</td>
    </tr>
    </table>

    <table width="300" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="50%" class="name">"
    echo "Name : <a href=mailto:$email>".htmlspecialchars($name)."</a>";"
    </td>
    <td width="50%" class="site">"
    echo "Sitename : <a href=$siteurl>".htmlspecialchars($sitename)."</a>";
    "</td>
    </tr>
    </table><br><br><br>"


    I had it working in its basic form but when i started adding html around it to format it it all started going wrong :)
    Any suggestions ?


Comments

  • Registered Users Posts: 14,148 ✭✭✭✭Lemming


    Get rid of the . at the end of the first php block.

    so it reads something like:

    <? echo "Entry Date".htmlspecialchars($date) ; ?>

    (assuming I've read your question right and that' the line causing the problem?

    The same is true of the next php block too ("Comments")


  • Registered Users Posts: 1,747 ✭✭✭Figment


    nope. didnt work.
    Here is the full code(without the server details:)

    <?php

    // SQL database Variables

    $hostname="localhost";
    $user="";
    $pass="";
    $dbase="";
    $connection = mysql_connect("$hostname" , "$user" , "$pass");
    $db = mysql_select_db($dbase , $connection);

    // View Guestbook

    $q="SELECT * from guestbook order by date desc";

    $result= mysql_db_query($dbase, $q, $connection) or die
    ("Could not execute query : $q." . mysql_error());

    while ($row=mysql_fetch_array($result))
    {
    $id=$row["id"];
    $name=$row["name"];
    $email=$row["email"];
    $sitename=$row["sitename"];
    $siteurl=$row["siteurl"];
    $date=$row["date"];
    $comments=$row["comments"];




    "<table width="300" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td class="date">"
    echo "Entry Date : ".htmlspecialchars($date);
    "</td>
    </tr>
    </table>

    <table width="300" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td class="text">"
    echo "Comments:<br> ".htmlspecialchars($comments).;
    "</td>
    </tr>
    </table>

    <table width="300" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="50%" class="name">"
    echo "Name : <a href=mailto:$email>".htmlspecialchars($name)."</a>";"
    </td>
    <td width="50%" class="site">"
    echo "Sitename : <a href=$siteurl>".htmlspecialchars($sitename)."</a>";
    "</td>
    </tr>
    </table><br /><br /><br />"
    }

    ?>


  • Closed Accounts Posts: 25 CarrigHOST


    Try this

    <?php

    // SQL database Variables

    $hostname="localhost";
    $user="";
    $pass="";
    $dbase="";
    $connection = mysql_connect("$hostname" , "$user" , "$pass");
    $db = mysql_select_db($dbase , $connection);

    // View Guestbook

    $q="SELECT * from guestbook order by date desc";

    $result= mysql_db_query($dbase, $q, $connection) or die
    ("Could not execute query : $q." . mysql_error());

    while ($row=mysql_fetch_array($result))
    {
    $id=$row["id"];
    $name=$row["name"];
    $email=$row["email"];
    $sitename=$row["sitename"];
    $siteurl=$row["siteurl"];
    $date=$row["date"];
    $comments=$row["comments"];



    ?>
    <table width="300" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td class="date"><?php
    echo "Entry Date : ".htmlspecialchars($date); ?>
    </td>
    </tr>
    </table>

    <table width="300" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td class="text"> <?php
    echo "Comments:<br> ".htmlspecialchars($comments);
    ?> </td>
    </tr>
    </table>

    <table width="300" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="50%" class="name"><?php
    echo "Name : <a href=mailto:".$email.">".htmlspecialchars($name)."</a>"; ?>
    </td>
    <td width="50%" class="site"> <?php
    echo "Sitename : <a href=".$siteurl.">".htmlspecialchars($sitename)."</a>";
    ?></td>
    </tr>
    </table><br /><br /><br />
    <?php
    }

    ?>


  • Registered Users Posts: 1,747 ✭✭✭Figment


    Ah ok, i see how that works. Thanks a lot guys :)


  • Closed Accounts Posts: 25 CarrigHOST


    So it worked. Glad to be of help.

    Sean


  • Advertisement
Advertisement