Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

php error

  • 16-08-2002 06:45PM
    #1
    Registered Users, Registered Users 2 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, Registered Users 2, Paid Member Posts: 14,174 ✭✭✭✭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, Registered Users 2 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, Registered Users 2 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