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
Help me - error message
-
- Posts: 2
- Joined: Sat Jan 07, 2006 2:01 pm
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;
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;
Hello onepiece92,
Your code"for line 391 is:
The original code is:
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
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.
Greetings,
Henrie
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");}
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");}
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");}
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");}
Henrie