| | | Join Date: Feb 2010
Posts: 4
| |
Hi,
Just found this forum and it looks like a wealth of info!
I'm not a coder and have a problem with the following brief bit of code (reportedly on line 22): - <?php
-
$d = $_GET["d"];
-
$m = $_GET["m"];
-
$y = $_GET["y"];
-
-
$d = (int) $d;
-
$m = (int) $m;
-
$y = (int) $y;
-
-
$curr = time();
-
-
$olddt = mktime(0,0,0,$m,$d,$y);
-
-
$ddiff = $curr - $olddt;
-
$fulldays = floor($ddiff/(60*60*24));
-
-
if ($fulldays < 2) { // Change 3 to however many days you want the link to last
-
$bannerAd[1] = 'http://www.mysite.com’;
-
-
$adCount = count($bannerAd);
-
$randomAdNumber = mt_rand(1, $adCount);
-
header('Location: ' . $bannerAd[$randomAdNumber]);
-
}
-
else {
-
header('Location:http://www.mysite2.com/');
-
}
-
?>
I cannot find the problem. If anyone can help it would be super appreciated.
Thanks
Ruchka
|  | | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 5,372
| | | re: Parse error: syntax error, unexpected T_STRING
is $bannerAd defined anywhere?
| | | | Join Date: Feb 2010
Posts: 4
| | | re: Parse error: syntax error, unexpected T_STRING
Thanks for responding Dormilich.
The entire code is pasted above. I have no other codes or definitions anywhere else.
As far as I know it could be defined in line 18:
$bannerAd[1] = 'http://www.mysite.com’;
But that is just a guess.
|  | | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 5,372
| | | re: Parse error: syntax error, unexpected T_STRING
line #18, the string is not closed (a right single quotation mark is different from an apostrophe). therefore the first ' on line 22 is closing the string and PHP expects a . or ; after that.
| | | | Join Date: Feb 2010
Posts: 4
| | | re: Parse error: syntax error, unexpected T_STRING
Wow OK I see that and I made the change to line #18:
now it is $bannerAd[1] = 'http://www.mysite.com';
but I am still getting the same error. Weird...
|  | | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 5,372
| | | re: Parse error: syntax error, unexpected T_STRING
well, I can’t see any syntax errors. then you can only comment out lines, maybe you find something this way.
| | | | Join Date: Feb 2010
Posts: 4
| | | re: Parse error: syntax error, unexpected T_STRING
you mean put
//
before code lines and see what happens?
I will try that. Thanks for you time and help, its much appreciated!
|  | | | Join Date: Jun 2007 Location: York, England, with wolves.
Posts: 5,533
| | | re: Parse error: syntax error, unexpected T_STRING
Post the revised code along with the full error string.
|  | Similar topics - help finding "Parse error: syntax error, unexpected T_STRING" ( PHP answers )
- I got this Parse error: syntax error, unexpected T_STRING, expecting '(' in ( PHP answers )
- output buffering, parse error unexpected t_string ( PHP answers )
- Re: output buffering, parse error unexpected t_string ( PHP answers )
- Parse Error : syntax error, unexpected T_STRING, expecting ',' or ';' ( PHP answers )
- parse error or infinite loop? a blank screen, yet the php error logis empty ( PHP answers )
- Parse error: syntax error, unexpected T_STRING, expecting ':' or ';' ( PHP answers )
- Parse error: syntax error, unexpected T_ENCAPSED_AND WHITESPACE, expecting T_STRING ( PHP answers )
- PHP Parse Error: syntax error, unexpected T_STRING, expecting ',' or ';' ( PHP answers )
- Parse error: parse error, unexpected T_STRING ( PHP answers )
| | |