Parse error: syntax error, unexpected T_STRING – PHP

  php

Q(Question):

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

A(Answer):

is $bannerAd defined anywhere?

A(Answer):

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.

A(Answer):

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.

A(Answer):

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…

A(Answer):

well, I can’t see any syntax errors. then you can only comment out lines, maybe you find something this way.

A(Answer):

you mean put

//

before code lines and see what happens?

I will try that. Thanks for you time and help, its much appreciated!

A(Answer):

Post the revised code along with the full error string.

LEAVE A COMMENT