Help me - error message

Dr. GBooky is here to help you with your guestbook problems ...
Post Reply
onepiece92
Posts: 2
Joined: Sat Jan 07, 2006 2:01 pm

Help me - error message

Post by onepiece92 »

I downloaded gbook and translatet some text in the gbook.php file into norwegian. Then i added some new sileys. Then i uploaded the images in binary mode, and the text files i ASCII mode.
I get the following error when i try to acess my guestbook: "Parse error: parse error, unexpected T_STRING in /home/vhosts/tim.555mb.com/gjestebok/gbook.php on line 391"

see it for yourself: http://tim.555mb.com/gjestebok/gbook.php
Henrie
Posts: 1095
Joined: Sun Aug 14, 2005 8:57 pm

Post by Henrie »

You have clearly made an error in the code syntax.
Open the gbook.php file in an editor and browse to line 391 (the one that gives the error).
Post this line in this forum (and some lines before and after that line, but clearly mark line 391).

Greetings,
Henrie
onepiece92
Posts: 2
Joined: Sat Jan 07, 2006 2:01 pm

Post by onepiece92 »

389: $v['url']=htmlspecialchars("$_REQUEST[url]");

390: if ($v['url'] == "http://" || $v['url'] == "https://") {$v['url'] = "";}

391: elseif (strlen($v['url']) > 0 && !(preg_match("/(http(s)?:\/\/+[\w\-]+\.[\w\-]+)/i",$v['url']))) {problem("This adress is invalid. Please check that your adress starts with "http://"!","1");}

392:

393: return $v;
Henrie
Posts: 1095
Joined: Sun Aug 14, 2005 8:57 pm

Post by Henrie »

Hello onepiece92,

Your code"for line 391 is:

Code: Select all

elseif (strlen($v['url']) > 0 && !(preg_match("/(http(s)?:\/\/+[\w\-]+\.[\w\-]+)/i",$v['url']))) {problem("This adress is invalid. Please check that your adress starts with "http://"!","1");}
The original code is:

Code: Select all

elseif (strlen($v['url']) > 0 && !(preg_match("/(http(s)?:\/\/+[\w\-]+\.[\w\-]+)/i",$v['url']))) 
{problem("The site URL is not valid, make sure you start it with http:// or https://!","1");}
The problem is that you have added quotes around the http:// text. In php code a quote " is used for defining the start and end of a string. To use quotes inside a string you have to use different code.

Method 1: escape it with a backslash (\)
This way the " is shown literal by php and not as part of the php code

Code: Select all

elseif (strlen($v['url']) > 0 && !(preg_match("/(http(s)?:\/\/+[\w\-]+\.[\w\-]+)/i",$v['url']))) {problem("This adress is invalid. Please check that your adress starts with \"http://\"!","1");}
Methode 2: use named characters
Use " instead of ". The users browser will show a named character as the single character instead of the inserted name.

Code: Select all

elseif (strlen($v['url']) > 0 && !(preg_match("/(http(s)?:\/\/+[\w\-]+\.[\w\-]+)/i",$v['url']))) {problem("This adress is invalid. Please check that your adress starts with "http://"!","1");}
Greetings,
Henrie
Post Reply