Jump to content

Unexpected T_Character parse error on line 67


Adamb10

Recommended Posts

Try this:
[code]<?
//commentmanagement.php

//essential functions to life
db_connect();

//User logged in?
if(session_is_registered('ub2')){
      
    echo '<br><br><center>
    <table width="60%" cellspacing="1" cellpadding="4" border="0" class="border">
            <tr>
                <td class="titlebg" colspan="2">

                <b>Admin Center - Comment Management</b>
                </td>
            </tr><tr>
                <td class="windowbg" colspan="2">
                <table width="100%" cellspacing="0" cellpadding="0" border="0">
                    <tr>
                        <td class="windowbg" width="20%">Hey Adam!</td>

                        <td class="windowbg" width="70%" align="right"><a href="?action=admin">Admin Center</a> | <b>Comments</b> | <a href="index.php?action=settings">Settings</a> | <a href="?action=customize">Customize</a></td>
                    </tr>
                </table>
                </td>
            </tr>
                <td class="windowbg2"> Listed below are all the comments on this guestbook.  Comments are listed by id and the persons name who posted it.<br><br>';
                echo '
                <table width="80%" cellspacing="1" cellpadding="4" border="0" class="border" align="Center">

    <tr>
        <td class="titlebg"><b>ID</b></td>
        <td class="titlebg"><b>Name</b></td>
        <td class="titlebg"><b>Edit</b></td>
        <td class="titlebg" width="30%"><b>Delete</b></td>
    </tr>';

            if(!isset($cmd))
{
$result = mysql_query("select * from comments order by id");
while($r=mysql_fetch_array($result))
   {
   $name=$r["name"]; //take out the title
      $id=$r["id"]; //Take out the id
   $date=$r["date"]; // Take out the Date
   echo "
       <tr>
        <td class='windowbg2'>$id</td>
        <td class='windowbg2'>$name</td>
        <td class='windowbg'><a href='?action=commentmanagement?cmd=edit&id=$id'>Edit</a></td>
        <td class='windowbg'><a href='?action=commentmanagement?cmd=delete&id=$id'>Delete</a></td>
    </tr>
    

    </center>";
    if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit")
{
   if (!isset($_POST["submit"]))
   {
      $id = $_GET["id"];
      $sql = "SELECT * FROM comments WHERE id=$id";
      $result = mysql_query($sql);        
      $myrow = mysql_fetch_array($result);
      echo "
      <form action='?action=editing' method='post'>
      <input type='hidden' name='id' value='.$myrow[id].'>
      <table width='100%' cellspacing='0' cellpadding='0' border='0'>
                <td class='titlebg' colspan='2'><b>Edit Comment</b></td>
        </tr><tr>
                    <td class='windowbg2' width='30%'><b>Name:</b><br>
            <font class='subtext'>The name the person used to tell who they are.</font></td>

            <td class='windowbg'><input type='text' name='title' size='40' value='.$myrow['name'].'></td>
        </tr><tr>
            <td class='windowbg2' width='30%'><b>Email:</b><br>

            <font class='subtext'>The email the person used to be contacted.</font></td>
            <td class='windowbg'><input type='text' name='name' size='40' value=''.$myrow["email"].''></td>
        </tr><tr>
        <td class='windowbg2' width='30%'><b>Website:</b><br>

            The website the person entered in.  This field is optional
            <td class='windowbg'><input type='text' name='name' size='40' value=''.$myrow['website'].''></td>
        </tr><tr>
        <td class='windowbg2' width='30%'><b>Comment:</b><br>

            <font class='subtext'>The comment the user entered in.</font></td>
            <td class='windowbg'><textarea name='comment' cols='38' rows='5'>'.$myrow['comment'].'</textarea></td>
             <input type='hidden' name='cmd' value='edit'>
             </tr>
        <tr>
            <td class='titlebg' colspan='2' align='right'><input type='submit' value='Edit Comment'> <input type='reset' value='Reset'></td></tr>
            </form>";
            
}


        
    }
}

echo '</table>';
} else {
    error('You do not have permission to view this page because:<br>
    <b>You are not logged in</b>');
}
?>[/code]
Link to comment
Share on other sites

Go to line 67 in your source code and look at that line and the line before it. One or the other line will have a simple syntax error in it involving: failure to terminate single or double quotes, failure to terminate parentheses or currly braces, too many parentheses or curly braces, other simple syntax errors etc.
Link to comment
Share on other sites

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/adamb10/public_html/ub2/sources/admin/commentmanagement.php on line 74
[/quote]

I looked over the code twice, the only thing that catches my eye is the value= part and I tried changing that but I still got the error.
Link to comment
Share on other sites

Ah...didn't notice...but you have a ton of errors surrounding the use of single quotes around your variables. Check those.

[!--quoteo(post=386647:date=Jun 21 2006, 06:52 PM:name=Adamb10)--][div class=\'quotetop\']QUOTE(Adamb10 @ Jun 21 2006, 06:52 PM) [snapback]386647[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I looked over the code twice, the only thing that catches my eye is the value= part and I tried changing that but I still got the error.
[/quote]

Line 74 should be:

[code]<td class='windowbg'><input type='text' name='title' size='40' value=''.$myrow['name'].''></td>[/code]

But there are gonna be errors down the line in others areas where single quotes are used around variables.
Link to comment
Share on other sites

You should pop in and out of php mode instead of outputting large amounts of html between single quotes and double quotes. Makes it way less confusing
[code]<?php
    //do php stuff
?>
<a href="somelink">don't need to worry about single quotes ' or double quotes " either</a>
more html
<?php
    //back to php
?>[/code]
Link to comment
Share on other sites

[!--quoteo(post=386654:date=Jun 21 2006, 07:00 PM:name=Adamb10)--][div class=\'quotetop\']QUOTE(Adamb10 @ Jun 21 2006, 07:00 PM) [snapback]386654[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Yeah, I get confused with the variable stuff and quotes.
[/quote]

Welll...if it confuses you, you can do the following when using variables in your html...


[code]echo"

<table align=\"center\">

<tr>
<td>Name: </td><td align=\"center\">$name</td></tr>

<tr>
<td>Name: </td><td align=\"center\">$name</td></tr>

</table>";[/code]

Basically, use double quotes if you're going to have PHP variables there...it should make it easier for you.




[!--quoteo(post=386656:date=Jun 21 2006, 07:05 PM:name=mainewoods)--][div class=\'quotetop\']QUOTE(mainewoods @ Jun 21 2006, 07:05 PM) [snapback]386656[/snapback][/div][div class=\'quotemain\'][!--quotec--]
You should pop in and out of php mode instead of outputting large amounts of html between single quotes and double quotes.
[/quote]

Also an option ;-) Whatever is easiest for you.
Link to comment
Share on other sites

Instead of creating a new topic...

I got the code to run thanks to starting and stopping PHP like previously mentioned. Now I got another problem(not a parse error :)).

The whole purpose of this file is to let the admin edit/delete comments. When the admin clicks edit to edit a topic, the url goes to ?action=comments?cmd=edit&id=15. Unfortuantely, when I do click edit, it goes to a blank page instead of a few text boxes. The code for this is right here...

[code]
if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit")
{
   if (!isset($_POST["submit"]))
   {
[/code]

I use the action urls system where every action(like ?action=logout) is stored in actions.php. Heres a sampling from that file...

[code]
$action = $_GET['action'];

if($action == "login"){
    require('login.php');
}
if($action =="admin"){
    require('admin/admin.php');
}
[/code]
Any reason this wont work?

Thanks!
Link to comment
Share on other sites

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Any reason this wont work?[/quote]
Nope.
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Unfortuantely, when I do click edit, it goes to a blank page instead of a few text boxes[/quote]
Can we see the form in which you click this second edit?
Link to comment
Share on other sites

Second edit? Theres only 1 edit you click to get to the form.

[img src=\"http://adamb10.com/edit.jpg\" border=\"0\" alt=\"IPB Image\" /]

OR...

[a href=\"http://adamb10.com/ub2/?action=login\" target=\"_blank\"]http://adamb10.com/ub2/?action=login[/a]
adam/hakkar are the login details
Click comments
Click Edit for any of the comments
Link to comment
Share on other sites

I would code it like this:
[code]
    //end php
?>
<table align="center">
<tr>
<td>Name: </td><td align="center"><?php echo $name; ?></td></tr>
<tr>
<td>Name: </td><td align="center"><?php echo $name; ?></td></tr>
</table>[/code]
--get to lose all those escaped quotes!
Link to comment
Share on other sites

ummm..I posted the code on the last page, but heres more of it.

[code]
if(!isset($cmd))
{
$result = mysql_query("select * from comments order by id");
while($r=mysql_fetch_array($result))
   {
   $name=$r["name"]; //take out the title
      $id=$r["id"]; //Take out the id
   $date=$r["date"]; // Take out the Date
   echo "
       <tr>
        <td class='windowbg2'>$id</td>
        <td class='windowbg2'>$name</td>
        <td class='windowbg'><a href='?action=comments&cmd=edit&id=$id'>Edit</a></td>
        <td class='windowbg'><a href='?action=comments&cmd=delete&id=$id'>Delete</a></td>
    </tr>
    

    </center>";
    if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit")
{
   if (!isset($_POST["submit"]))
   {
      $id = $_GET["id"];
      $sql = "SELECT * FROM comments WHERE id=$id";
      $result = mysql_query($sql);        
      $myrow = mysql_fetch_array($result);
//PHP, we need you to cool down so get a drink and relax.
  ?>
      <form action='?action=editing' method='post'>
      <input type=hidden name='id' value="<? echo $myrow["id"] ?>">
      <table width='100%' cellspacing='0' cellpadding='0' border='0'>
                <td class='titlebg' colspan='2'><b>Edit Comment</b></td>
        </tr><tr>
                    <td class='windowbg2' width='30%'><b>Name:</b><br>
            <font class='subtext'>The name the person used to tell who they are.</font></td>

            <td class='windowbg'><input type='text' name='title' size='40' value="<? echo $myrow["name"] ?>"></td>
        </tr><tr>
            <td class='windowbg2' width='30%'><b>Email:</b><br>

            <font class='subtext'>The email the person used to be contacted.</font></td>
            <td class='windowbg'><input type='text' name='name' size='40' value="<? echo $myrow["email"] ?>"></td>
        </tr><tr>
        <td class='windowbg2' width='30%'><b>Website:</b><br>

            <font class='subtext'>The website the person entered in.  This field is optional</font></td>
            <td class='windowbg'><input type='text' name='name' size='40' value="<? echo $myrow["website"] ?>"></td>
        </tr><tr>
        <td class='windowbg2' width='30%'><b>Comment:</b><br>

            <font class='subtext'>The comment the user entered in.</font></td>
            <td class='windowbg'><textarea name='comment' cols='38' rows='5'><? echo $myrow["comment"] ?></textarea></td>
             <input type='hidden' name='cmd' value='edit'>
             </tr>
        <tr>
            <td class='titlebg' colspan='2' align='right'><input type='submit' value='Edit Comment'> <input type='reset' value='Reset'></td></tr>
            </form>
            <?
            
        }
        
            }
            
        }
    
            }
        
[/code]
Link to comment
Share on other sites

None of that code is relevent considering the first line says...
[code]
if(!isset($cmd))
[/code]
Assuming, that is, that $cmd = $_GET['cmd']

Really... the problem with writting all your code in one big file like so is the logic becomes pretty un-userfriendly pretty quickl;y. The logic is quite difficult to follow when you cant see the whole picture.
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.