Help urgently needed - bogus (?) error message

This is a discussion on "Help urgently needed - bogus (?) error message" within the PHP Forum section. This forum, and the thread "Help urgently needed - bogus (?) error message are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old May 27th, 2007, 00:16
Reputable Member
Join Date: Mar 2005
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
Posts: 233
Thanks: 4
Thanked 0 Times in 0 Posts
Help urgently needed - bogus (?) error message



Please disregard this post. I found the problem.




This is a production page that I've somehow broken. (It was semi-working before, but cookies were not being set properly. The error message it's now throwing is "Parse error: syntax error, unexpected ',' in X:\Documents\webdev\localhost\dhs57\postcomment.ph p on line 209"

Line 209 in the code below is the first "setcookie" line.
If I comment out line 209, the error changes to read 210. If I comment out 209 and 210, the error still says 210. I don't see anything wrong with 209, 210 or anything before or after but I must be missing something. Hopefully someone here will see it.

PHP: Select all

$query "INSERT INTO `comments` ( `ID` , `eventID` , `name` , `comment` ) ".
     
"VALUES (NULL , '".$eventid."', '".$postname."', '".$postmsg."')";
    
#echo $bdo."PC236<br>query=$query".$edo;
    #echo $bdo."PC237 - This is where we run the insert query".$edo;
    
$result mysql_query($query,$dblink) or die(mysql_error());
    if (
$result) {
        
#echo $bdo."PC238 - comments posted successfully".$edo;
        
unset($_SESSION['eventid']);
        unset(
$_SESSION['postmsg']);
        if (
$eventid 20000) {
            
$cmid $eventid 10000;
            
$query "SELECT Email FROM alumni WHERE ID = '".$cmid."'";
            
$result mysql_query($query,$dblink) or die(mysql_error());
            
$rec mysql_fetch_array($result);
            
$sendto $rec['Email'];
            if (
strpos($sendto,"@") > 0) {
                
$headers "From: webmaster@dhs57.com";
                
$subject $postname.' has "signed your yearbook"!';
                
$msgtext $postname.' has "signed your yearbook" on DHS57.com. Check it out at http://www.dhs57.com - click on Classmates, then click on your name to see what your classmate had to say!';
                
$sent mail($sendto$subject$msgtext$headers);
            } 
        } 
        
setcookie("UserID"$_SESSION['userid'], time()+86400*180), "/""dhs57.stickpuppy.com");  /* expire in 180 days */
        
setcookie("postname"$_SESSION['postname'], time()+86400*180), "/""dhs57.stickpuppy.com");  /* expire in 180 days */
        
echo "<p>Your comment has been posted. Please <a href='".$return2."'>click here</a> or use your browser's 'Back' button to return to where you were.</p>";
    } else {
        
#echo $bdo."PC239 - comment could not be posted".$edo;
        
echo "An unknown error has occurred. Your comment could not be posted. Please ".
             
"<a href='contact.php?msgid=57121'>notify the webmaster</a>.";
    }
}
?> 

Last edited by Donny Bahama; May 28th, 2007 at 15:57.
Reply With Quote

  #2 (permalink)  
Old May 27th, 2007, 00:26
Reputable Member
Join Date: Mar 2005
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
Posts: 233
Thanks: 4
Thanked 0 Times in 0 Posts
Re: Help urgently needed - bogus (?) error message

OK - a bit of the info above is incorrect...

I went back to the page with the form and started over (as opposed to using F5 or Ctrl+F5 to test changes) and reposted the form and it stops giving the error if I comment out both setcookie lines.

So what the heck is wrong with my setcookie lines?

Last edited by Donny Bahama; May 27th, 2007 at 00:34.
Reply With Quote
  #3 (permalink)  
Old May 27th, 2007, 01:51
Reputable Member
Join Date: Mar 2005
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
Posts: 233
Thanks: 4
Thanked 0 Times in 0 Posts
Re: Help urgently needed - bogus (?) error message

I found the problem. I'm missing an open parenthesis right after "time()+"

PHP: Select all

setcookie("UserID"$_SESSION['userid'], time()+86400*180), "/""dhs57.stickpuppy.com");  /* expire in 180 days */
        
setcookie("postname"$_SESSION['postname'], time()+86400*180), "/""dhs57.stickpuppy.com");  /* expire in 180 days */
        
echo "<p>Your comment has been posted. Please <a href='".$return2."'>click here</a> or use your browser's 'Back' button to return to where you were.</p>";
    } else {
        
#echo $bdo."PC239 - comment could not be posted".$edo;
        
echo "An unknown error has occurred. Your comment could not be posted. Please ".
             
"<a href='contact.php?msgid=57121'>notify the webmaster</a>.";
    }
}
?> 
[/quote]
Reply With Quote
  #4 (permalink)  
Old May 28th, 2007, 15:44
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Help urgently needed - bogus (?) error message

Bah, should have read to the bottom before I looked for the problem. Glad you found it.

You know, you don't need to concat and backtick PHP queries (at least in PHP 5 and later mysql 4, you might have to test it on your config):

PHP: Select all

$query "INSERT INTO `comments` ( `ID` , `eventID` , `name` , `comment` ) " "VALUES (NULL , '".$eventid."', '".$postname."', '".$postmsg."')"
SQL will read the variable values even if they are in single quotes
PHP: Select all

$query "INSERT INTO comments ( ID,eventID,name,
comment) VALUES (NULL,'$eventid','$postname','$postmsg')"

Also, when you're posting code on the forum, it's a gazillion times easier to read if you use the Enter key to break up long lines and eliminate that horizontal scrollbar.
Reply With Quote
  #5 (permalink)  
Old May 28th, 2007, 16:01
Reputable Member
Join Date: Mar 2005
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
Posts: 233
Thanks: 4
Thanked 0 Times in 0 Posts
Re: Help urgently needed - bogus (?) error message

Quote:
Originally Posted by masonbarge View Post
Bah, should have read to the bottom before I looked for the problem. Glad you found it.
Really sorry to have wasted your time, Mason. I've updated the first post so this won't happen again.
Quote:
You know, you don't need to concat and backtick PHP queries
I do know. The concatenation is a preference and the backticks are there from when I craft a query in phpMyAdmin then copy and paste.
Quote:
Also, when you're posting code on the forum, it's a gazillion times easier to read if you use the Enter key to break up long lines and eliminate that horizontal scrollbar.
Thanks. I'll be sure to do that in the future.
Reply With Quote
Reply

Tags
error message

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Web Design Tutor needed urgently! RollingSound Job Opportunities 1 Apr 16th, 2008 17:27
shopping cart advice needed urgently! butterflyness Starting Out 3 Dec 12th, 2007 11:20
Web develpors needed, Urgently! TargeTemplate Job Opportunities 2 Sep 17th, 2007 14:12
Keep getting error message Microsoft VBScript runtime error '800a01a8' cpando1974 Classic ASP 2 Aug 7th, 2007 12:00
Web designer urgently needed IRE Job Opportunities 2 Jul 26th, 2007 10:02


All times are GMT. The time now is 11:39.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43