Jump to content

unexpected '}', expecting ',' or ';'


Recommended Posts

I Get This Error

 

Parse error: syntax error, unexpected '}', expecting ',' or ';' in /www/rack111.com/m/y/t/mytestsite/htdocs/youtube/other.php on line 22

 

In This Code

 

 

<?php

error_reporting(0);

$ip = $_SERVER['REMOTE_ADDR'];

$useripdata = '/ip/' . $ip .'.txt';

if (file_exists($useripdata)) {

foreach (file('/ip/' . $ip . '.txt') as $line) {
  echo '$' . $line;

}

for ($i=0; $i < $numTimes; $i++) {
echo '<object width="$setwidth" height="$setheight""><param name="movie" value="http://www.youtube.com/v/' . $shorturl . '&hl=en&fs=1"></param><param name="allowFullScreen" value="false"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/' . $shorturl . '&hl=en&fs=1$autoplay" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="false" width="$setwidth" height="$setheight"></embed></object>';
}

echo "<meta http-equiv='refresh' content='$reloadtime' url='index.php'>;"

} else {
   
if (isset($_POST['action'])) {
   
$numTimes = (isset($_POST['times']) && is_numeric($_POST['times']))?$_POST['times']:10;
$shorturl = $_POST['url'];
$autoplay = "&autoplay=1";
$reloadtime = $_POST['reloadtime'];
$setwidth = $_POST['setwidth'];
$setheight = $_POST['setheight'];
$shorturl = $_POST['url'];
$fullurl = "http://www.youtube.com/watch?v=' . $shorturl . '";


$myFile = "/ip/' . $ip . '.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "numTimes = "10"\n";
fwrite($fh, $stringData);
$stringData = "shorturl = $shorturl \n";
fwrite($fh, $stringData);
$stringData = "autoplay = $autoplay \n";
fwrite($fh, $stringData);
$stringData = "reloadtime = $reloadtime \n";
fwrite($fh, $stringData);
$stringData = "setwidth = $setwidth \n";
fwrite($fh, $stringData);
$stringData = "setheight = $setheight \n";
fwrite($fh, $stringData);
$stringData = "fullurl = $fullurl \n";
fwrite($fh, $stringData);
fclose($fh);


function check_if_valid($fullurl) {
$res = (($check = @fopen($fullurl, ‘r’)) === false) ? false : @fclose($check);
return ($res == TRUE) ? VIDEO_IS_VALID:VIDEO_IS_INVALID ;
}

if ($HTTP_POST_VARS["submitted"] == "yes"){
echo "<meta http-equiv='refresh' content='$reloadtime'>";
}


for ($i=0; $i < $numTimes; $i++) {
echo '<object width="$setwidth" height="$setheight""><param name="movie" value="http://www.youtube.com/v/' . $shorturl . '&hl=en&fs=1"></param><param name="allowFullScreen" value="false"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/' . $shorturl . '&hl=en&fs=1$autoplay" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="false" width="$setwidth" height="$setheight"></embed></object>';
}

}

}

?>

<table border="1">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<tr>
<td>Video Url:<input type="text" readonly="1" value="http://www.youtube.com/watch?v=" size="30"><input type="Text" name="url"></td>
</tr>
<tr>
<td>(Number)<input type="text" name="times" value="10"> of Times to Display Video in <input type="text" name="reloadtime" value="5">(Seconds)</td>
</tr>
<tr>
<td>Set Width <input type="text" name="setwidth" value="425"> Set Height <input type="text" name="setheight" value="344">
</tr>
<tr>
<td align="center" valign="center"><input type="submit" name="action" value="Submit">
<input type="hidden" name="submitted" value="yes">
</td>
</tr>
</form
</table>

Link to comment
https://forums.phpfreaks.com/topic/135640-unexpected-expecting-or/
Share on other sites

I am unable to test the code, but i have taken it, indented, looked through it, and replaced quite a few small errors... and changed some stuff i wasn't sure about...

 

I see no reason why it shouldn't run... though if im wrong, please return the error :)

 

<?php

error_reporting(0);
$ip = $_SERVER['REMOTE_ADDR'];
$useripdata = '/ip/' . $ip .'.txt';

if (file_exists($useripdata)){
   foreach (file('/ip/' . $ip . '.txt') as $line){
      echo '$' . $line;
   }
   for ($i=0; $i < $numTimes; $i++) {
      echo "<object width='".$setwidth."' height='".$setheight."'>
            <param name='movie' value='http://www.youtube.com/v/".$shorturl."&hl=en&fs=1'></param>
            <param name='allowFullScreen' value='false'></param>
            <param name='allowscriptaccess' value='always'></param>
            <embed src='http://www.youtube.com/v/".$shorturl."&hl=en&fs=1".$autoplay."' 
            type='application/x-shockwave-flash' allowscriptaccess='always'    
            allowfullscreen='false' width='".$setwidth."' height='".$setheight."'>
            </embed></object>";
   }
   echo "<meta http-equiv='refresh' content='".$reloadtime."' url='index.php'>";
} 
else {   
   if (isset($_POST['action'])){   
      $numTimes = (isset($_POST['times']) && is_numeric($_POST['times']))?$_POST['times']:10;
      $shorturl = $_POST['url'];
      $autoplay = "&autoplay=1";
      $reloadtime = $_POST['reloadtime'];
      $setwidth = $_POST['setwidth'];
      $setheight = $_POST['setheight'];
      $shorturl = $_POST['url'];
      $fullurl = "http://www.youtube.com/watch?v=".$shorturl;

      $myFile = "/ip/".$ip.".txt";
      $fh = fopen($myFile, 'w') or die("can't open file");
      $stringData = "numTimes = "10"\n";           fwrite($fh, $stringData);
      $stringData = "shorturl = $shorturl \n";     fwrite($fh, $stringData);
      $stringData = "autoplay = $autoplay \n";     fwrite($fh, $stringData);
      $stringData = "reloadtime = $reloadtime \n"; fwrite($fh, $stringData);
      $stringData = "setwidth = $setwidth \n";     fwrite($fh, $stringData);
      $stringData = "setheight = $setheight \n";   fwrite($fh, $stringData);
      $stringData = "fullurl = $fullurl \n";       fwrite($fh, $stringData);
      fclose($fh);

      function check_if_valid($fullurl){
         $res = (($check = @fopen($fullurl, ‘r’)) === false) ? false : @fclose($check);
         return ($res == TRUE) ? VIDEO_IS_VALID:VIDEO_IS_INVALID ;
      }

      if ($HTTP_POST_VARS["submitted"] == "yes"){
         echo "<meta http-equiv='refresh' content='".$reloadtime."'>";
      }
      for ($i=0; $i < $numTimes; $i++) {
         echo "<object width='".$setwidth."' height='".$setheight."'>
              <param name='movie' value='http://www.youtube.com/v/".$shorturl."&hl=en&fs=1'>
              </param><param name='allowFullScreen' value='false'></param>
              <param name='allowscriptaccess' value='always'></param>
              <embed src='http://www.youtube.com/v/".$shorturl."&hl=en&fs=1$autoplay'  
              type='application/x-shockwave-flash' allowscriptaccess='always' 
              allowfullscreen='false' width='".$setwidth."' height='".$setheight."'><
              /embed></object>";
      }
   }
}
?>

<table border="1">
   <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
   <tr><td>
      Video Url:<input type="text" readonly="1" value="http://www.youtube.com/watch?v=" size="30">
      <input type="Text" name="url">
   </td></tr><tr><td>
      (Number)<input type="text" name="times" value="10"> of Times to Display Video in 
      <input type="text" name="reloadtime" value="5">(Seconds)
   </td></tr><tr><td>
      Set Width <input type="text" name="setwidth" value="425"> Set Height 
      <input type="text" name="setheight" value="344">
   </tr><tr><td align="center" valign="center">
      <input type="submit" name="action" value="Submit">
      <input type="hidden" name="submitted" value="yes">
   </td></tr>
   </form>
</table>

 

it reads easier indented :)

 

EDIT, gah, missed a " ^^

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.