Search
Left Quote    Black holes are where God divided by zero.
- Steven Wright    
Right Quote
 
[login] | [Register]
Forum Index » PHP and mySQL » Viewing Topic and Replies
Post Reply


        Viewing Topic: Parse error: parse error, unexpected T_VARIABLE
  This user is online  Guest
  Subject: "Parse error: parse error, unexpecte..." Posted: @ 3:56 am on Jul 29 2006   
Unregistered

Code:
Parse error: parse error, unexpected T_VARIABLE in /home/content/c /o/l/collegemov ie/html/source/ scripts/comment s/comments.php on line 7



This is line 7:


Code:
$inf = "SELECT * FROM `comments` WHERE page = '".stripsl ashes($_SERVER[ 'REQUEST_URI']) ."' ORDER BY time ASC";[


I have no idea why this is showing up! I think I've set everything up correctly, though.

    Viewed: 19,609 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Parse error: parse error, unexp..." Posted: @ 5:54 am on Jul 29 2006    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

you have: $inf = "SELECT * FROM `comments` WHERE page = '".strip slashes($_SERVE R['REQUEST_URI '])."' ORDER BY time ASC";[

try:

$inf = "SELECT * FROM `comments` WHERE `page` = '".STRIP SLASHES($_SERVE R['REQUEST_URI '])."' ORDER BY `time` ASC";

What was the [ for you had in there? part of the code or a mis-print?




-bs0d | AllSyntax.com

    Viewed: 19,601 Times | Reply to This | To top
  This user is online  Guest
  Subject: "re: Parse error: parse error, unexp..." Posted: @ 3:39 pm on Jul 29 2006    
Unregistered

That was definitely a mistake. Happened when I was putting the [Code] in.



    Viewed: 19,596 Times | Reply to This | To top
  This user is online  Guest
  Subject: "re: Parse error: parse error, unexp..." Posted: @ 3:40 pm on Jul 29 2006    
Unregistered

Realized what the problem is. When you just typed that replacement line, you put apostrophies around the word page. On the tutorial, they are not there:

$inf = "SELECT * FROM `comments` WHERE page = '".strip slashes($_SERVE R['REQUEST_URI '])."' ORDER BY time ASC";

So, now I have a new error message.

Warning: mysql_connect() : Can't connect to local MySQL server through socket '/tmp/mysql.so ck' (2) in /home/content/c /o/l/collegemov ie/html/source/ scripts/comment s/config.php on line 9

So, I assume that's a problem with my connect.php file. However, I'm not sure what the problem is. Here it is:



Code:

<?php

$database[dbser ver]="mys ql149.secureser ver.net";
$database[dbuse r]="test ";
$database[dbnam e]="test ";
$database[dbpas s]="test ";
$table ="comment s";

$connect = mysql_connect($ database['dbse rver'], $database['dbu ser'], $database['dbp ass']);

$select= mysql_select_db ($database['db name']);
?>



I replaced the word test with the actual database name, user name, and password. But they're all in there. Is that all I need to change in that file? What else could be wrong?



    Viewed: 19,594 Times | Reply to This | To top
  This user is online  Guest
  Subject: "re: Parse error: parse error, unexp..." Posted: @ 3:57 pm on Jul 29 2006    
Unregistered

Update time! Okay, so it was simply an error in the database variables that I typed in.

New error:

Warning: Cannot modify header information - headers already sent by (output started at /home/content/c /o/l/collegemov ie/html/source/ tests/comments. php:2) in /home/content/c /o/l/collegemov ie/html/source/ scripts/comment s/comments.php on line 58



    Viewed: 19,592 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Parse error: parse error, unexp..." Posted: @ 4:09 pm on Jul 29 2006    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

ahh, that one is easy. use ob_start(); as the very first line of the comments script right after <?




-bs0d | AllSyntax.com

    Viewed: 19,588 Times | Reply to This | To top
  This user is online  Guest
  Subject: "re: Parse error: parse error, unexp..." Posted: @ 4:30 pm on Jul 29 2006    
Unregistered

Okay, it might not be as easy as we would like it to be. Maybe I'm just lagging.

I tried putting that as the first line of the script. It didn't work. Then I looked around the forums and found that if you're including the file then you have to put that line as the very first line of the...well, something. I think that's where I get lost.

One of my pages looks like this:


Code:


<?php include ('../includes/ head.php');?&g t;

<?php include ('../includes/ head_writings.p hp');?>

<div class="wr iting"> ;

<hr />

<?php include(" ../scripts/comm ents/comments.p hp"; ?>

<hr />

</div>

<?php include ('../includes/ foot_writings.p hp');?>

<?php include ('../includes/ foot.php');?&g t;



Where should that ob_start(); be put? I tried it at the top of the comments.php, then I tried it at the top of the head.php like this:


Code:

<?

ob_start();

?>

<!DOCTYPE html PUBLIC "-//W3C// DTD XHTML 1.0 Transitional//E N" "http://w ww.w3.org/TR/xh tml1/DTD/xhtml1 -transitional.d td"> <html xmlns="ht tp://www.w3.org /1999/xhtml&qu ot;>
<head>
<etc, etc, etc.>



It still does it. Suggestions? And thanks for replying to quickly and being so helpful.



    Viewed: 19,585 Times | Reply to This | To top
  This user is online  Guest
  Subject: "re: Parse error: parse error, unexp..." Posted: @ 4:35 pm on Jul 29 2006    
Unregistered

Minus the smilie face. Not sure why I had " instead of '. I changed it just now.



    Viewed: 19,583 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Parse error: parse error, unexp..." Posted: @ 6:14 pm on Jul 29 2006    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

yea, im still developing the forums so I've gotta add a "disable smilies" option so smilies wont appear in code.

ANYWAYS... In your 1st code sample, I would use ob_start like this:


Code:


<? ob_start();
include ('../includes/ head.php');
include ('../includes/ head_writings.p hp');
?>
<div class="wr iting"> ;
<hr />
<? include(" ../scripts/comm ents/comments.p hp"; ?>
<hr />
</div>




-bs0d | AllSyntax.com

    Viewed: 19,578 Times | Reply to This | To top
  This user is online  Guest
  Subject: "re: Parse error: parse error, unexp..." Posted: @ 3:29 pm on Jul 31 2006    
Unregistered

Yay! Works fine.

Now I have a new problem. Whenever I post a comment within five minutes of each other it tells me to wait. That's fine. But it puts that comment on the page and then it doesn't finish loading any of the page below that comment. Why?



    Viewed: 19,564 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Parse error: parse error, unexp..." Posted: @ 5:33 pm on Jul 31 2006    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

That would be the flood control as described in the middle of the 3rd page of the tutorial: Building a Comments Script: Page 3




-bs0d | AllSyntax.com

    Viewed: 19,558 Times | Reply to This | To top
  This user is online  Guest
  Subject: "re: Parse error: parse error, unexp..." Posted: @ 12:56 am on Aug 03 2006    
Unregistered

Oh, I totally understand that. I think the part that I was confused about was: "it doesn't finish loading any of the page below that comment. Why?" The tutorial doesn't explain that.

I'm sure it has to do with the fact that I <? include the footer. Or maybe it doesn't. Do you know?



    Viewed: 19,549 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Parse error: parse error, unexp..." Posted: @ 2:11 am on Aug 03 2006    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

Yea, its because of the die(); function. It stops everything if an error is encountered. So the script encountered die(); at the flood control part of the script which is before the footer, so anything after that is not going to be executed.

Thats why. I haven't looked into any alternatives, feel free if its a bother. If you find a better solution you could add that to this thread and others may be able to find it useful as well?




-bs0d | AllSyntax.com

    Viewed: 19,545 Times | Reply to This | To top
  This user is online  Guest
  Subject: "re: Parse error: parse error, unexp..." Posted: @ 10:51 pm on Aug 08 2006    
Unregistered

Gotcha.

So, why when I put line breaks in a comment it puts <br /> <br /> instead of the break?



    Viewed: 19,515 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Parse error: parse error, unexp..." Posted: @ 3:23 am on Aug 09 2006    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

use nl2br();




-bs0d | AllSyntax.com

    Viewed: 19,510 Times | Reply to This | To top
  This user is online  Guest
  Subject: "re: Parse error: parse error, unexp..." Posted: @ 1:55 pm on Aug 09 2006    
Unregistered

Where do I put that?



    Viewed: 19,503 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Parse error: parse error, unexp..." Posted: @ 5:22 pm on Aug 09 2006    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

addslashes(html specialchars(nl 2br($_POST['co mment']))) when a comment is inserted into the database, then

stripslashes($c omment) when you show it. try that-




-bs0d | AllSyntax.com

    Viewed: 19,498 Times | Reply to This | To top
  This user is online  Guest
  Subject: "re: Parse error: parse error, unexp..." Posted: @ 3:45 pm on Aug 11 2006    
Unregistered

Okay, so I added this:


Code:

$q ="INSERT INTO `comments` (article_id, page, date, time, username, ip, contact, subject, comment) VALUES ('".$_GE T['id'].&quo t;', '".$_POS T['page'].&q uot;', '".$_POS T['date'].&q uot;', '".$_POS T['time'].&q uot;', '".addsl ashes(htmlspeci alchars($_POST[ 'username'])) ."', '".$_SER VER['REMOTE_AD DR']."' , '".addsl ashes(htmlspeci alchars($_POST[ 'contact'])). "', '".addsl ashes(htmlspeci alchars($_POST[ 'subject'])). "', '".addsl ashes(htmlspeci alchars(nl2br($ _POST['comment '])))." ', '".addsl ashes(htmlspeci alchars(nl2br($ _POST['comment '])))." ')";



I'm not sure where to add stripslashes($c omment) exactly. I'd love it if you could explain a little more.



    Viewed: 19,489 Times | Reply to This | To top
Viewing Page: 1 of 1


1 |

You must be logged in to post on the forums. Login or Register








"AllSyntax.com" Copyright © 2002-2018; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank