Jump to content


Photo

Unexpected T_Character parse error on line 67


  • Please log in to reply
23 replies to this topic

#1 Adamb10

Adamb10
  • Members
  • PipPip
  • Member
  • 19 posts
  • LocationMilwaukee, Wisconsin

Posted 21 June 2006 - 11:39 PM

Scroll down to post #11 plz.

#2 Caesar

Caesar
  • Members
  • PipPipPip
  • Advanced Member
  • 1,025 posts

Posted 21 June 2006 - 11:49 PM

Try this:
<?
//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>');
}
?>

PHP Ninja

#3 mainewoods

mainewoods
  • Members
  • PipPipPip
  • Advanced Member
  • 685 posts
  • LocationMaine

Posted 21 June 2006 - 11:51 PM

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.

#4 Adamb10

Adamb10
  • Members
  • PipPip
  • Member
  • 19 posts
  • LocationMilwaukee, Wisconsin

Posted 21 June 2006 - 11:52 PM

[!--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.

#5 mainewoods

mainewoods
  • Members
  • PipPipPip
  • Advanced Member
  • 685 posts
  • LocationMaine

Posted 21 June 2006 - 11:58 PM

What code is on line 74?

#6 Caesar

Caesar
  • Members
  • PipPipPip
  • Advanced Member
  • 1,025 posts

Posted 22 June 2006 - 12:00 AM

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) View Post[/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:

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

But there are gonna be errors down the line in others areas where single quotes are used around variables.
PHP Ninja

#7 Adamb10

Adamb10
  • Members
  • PipPip
  • Member
  • 19 posts
  • LocationMilwaukee, Wisconsin

Posted 22 June 2006 - 12:00 AM

Yeah, I get confused with the variable stuff and quotes.

#8 mainewoods

mainewoods
  • Members
  • PipPipPip
  • Advanced Member
  • 685 posts
  • LocationMaine

Posted 22 June 2006 - 12:05 AM

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
<?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
?>


#9 Caesar

Caesar
  • Members
  • PipPipPip
  • Advanced Member
  • 1,025 posts

Posted 22 June 2006 - 12:06 AM

[!--quoteo(post=386654:date=Jun 21 2006, 07:00 PM:name=Adamb10)--][div class=\'quotetop\']QUOTE(Adamb10 @ Jun 21 2006, 07:00 PM) View Post[/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...


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>";

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) View Post[/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.

PHP Ninja

#10 Adamb10

Adamb10
  • Members
  • PipPip
  • Member
  • 19 posts
  • LocationMilwaukee, Wisconsin

Posted 22 June 2006 - 12:07 AM

I did do that Caesar(just not in this file), but in this file nothing works.

#11 Adamb10

Adamb10
  • Members
  • PipPip
  • Member
  • 19 posts
  • LocationMilwaukee, Wisconsin

Posted 22 June 2006 - 12:24 AM

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...

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

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

$action = $_GET['action'];

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

Thanks!

#12 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 22 June 2006 - 12:27 AM

[!--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?

#13 Adamb10

Adamb10
  • Members
  • PipPip
  • Member
  • 19 posts
  • LocationMilwaukee, Wisconsin

Posted 22 June 2006 - 12:37 AM

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


#14 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 22 June 2006 - 12:45 AM

Ah... just now noticed. This...
?action=comments?cmd=edit&id=15
Should be...
?action=comments&cmd=edit&id=15
You have two ? in your query string.

#15 mainewoods

mainewoods
  • Members
  • PipPipPip
  • Advanced Member
  • 685 posts
  • LocationMaine

Posted 22 June 2006 - 12:47 AM

I would code it like this:
    //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>
--get to lose all those escaped quotes!

#16 Adamb10

Adamb10
  • Members
  • PipPip
  • Member
  • 19 posts
  • LocationMilwaukee, Wisconsin

Posted 22 June 2006 - 12:48 AM

:P Right now I just wanna get a working script and then optimize/clean it up.

P.S. Adding a & and removing the ? kinda works. I get the same page only without the posts.

#17 Adamb10

Adamb10
  • Members
  • PipPip
  • Member
  • 19 posts
  • LocationMilwaukee, Wisconsin

Posted 22 June 2006 - 01:04 AM

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

Theres the new screenshot, what it looks like after you hit edit.


#18 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 22 June 2006 - 01:05 AM

Well... to be of any further help were going to need to see some code.

#19 Adamb10

Adamb10
  • Members
  • PipPip
  • Member
  • 19 posts
  • LocationMilwaukee, Wisconsin

Posted 22 June 2006 - 01:08 AM

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

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>
            <?
            
        }
        
            }
            
        }
    
            }
        



#20 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 22 June 2006 - 01:28 AM

None of that code is relevent considering the first line says...
if(!isset($cmd))
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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users