Jump to content

Archived

This topic is now archived and is closed to further replies.

Adamb10

Unexpected T_Character parse error on line 67

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]

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
Yeah, I get confused with the variable stuff and quotes.

Share this post


Link to post
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]

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
I did do that Caesar(just not in this file), but in this file nothing works.

Share this post


Link to post
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!

Share this post


Link to post
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?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
Ah... just now noticed. This...
[code]
?action=comments?cmd=edit&id=15
[/code]
Should be...
[code]
?action=comments&cmd=edit&id=15
[/code]
You have two ? in your query string.

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites
: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.

Share this post


Link to post
Share on other sites
[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.

Share this post


Link to post
Share on other sites
Well... to be of any further help were going to need to see some code.

Share this post


Link to post
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]

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
hmmm... I see. I should probobly close that if statement earlier then?

Share this post


Link to post
Share on other sites
See me edited post above.

As I said.... In one big file, I really cant see your logic.

Share this post


Link to post
Share on other sites
Yep that was it, I moved the textboxes to a new file and now it works.

Thanks!!

Share this post


Link to post
Share on other sites
Now, I cant get the code that actually edit's the DB to work. Ah well, Im sure I can tackle it on my own. :)

Share this post


Link to post
Share on other sites

×

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.