Jump to content

unexpected $end


jnerotrix

Recommended Posts

I get this Error

Parse error: syntax error, unexpected $end in /www/110mb.com/c/u/s/t/o/m/-/a/custom-art/htdocs/youtube/other.php on line 89

 

In This Code:

 

<?php


$ip = $_SERVER['REMOTE_ADDR'];

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

if (file_exists($useripdata)) {

foreach (file($useripdata) 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'>";

} 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');
$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>';
}

$self = $_SERVER['PHP_SELF'];

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

}

?>

 

 

Link to comment
Share on other sites

try this, you didnt close your else statement.

 

<?php


$ip = $_SERVER['REMOTE_ADDR'];

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

if (file_exists($useripdata)) {

foreach (file($useripdata) 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'>";

} 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');
$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>';
}

$self = $_SERVER['PHP_SELF'];

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

}
}

?>

Link to comment
Share on other sites

Try this:

<?php


$ip = $_SERVER['REMOTE_ADDR'];

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

if (file_exists($useripdata)) {

foreach (file($useripdata) 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'>";

} 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');
	$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>';
	}
} else {
	$self = $_SERVER['PHP_SELF'];

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

}
}
?>

 

You had it check to see if $_POST['action'] is there, but not if it wasn't.

Link to comment
Share on other sites

ok for some reason my code isnt working its displaying the form no matter what weather the file exists or not the file does exist but i just get the else display

 

the text file contains variable strings

like this:

1 = 123

2 = 234

3 = 345

 

then when displayed it reads like this

$1 = 123

$2 = 234

$3 = 345

 

with this code

 

<?php


$ip = $_SERVER['REMOTE_ADDR'];

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

if (file_exists($useripdata)) {

   foreach (file($useripdata) as $line) {
     echo '$' . $line;

   }

 

is it possible to make variable strings out of a text file for the script to read

Link to comment
Share on other sites

is it possible to make a $variable from a text file

 

It depends on what you mean.

Setting the contents of the file to $variable - yes.

Creating a variable in the text file - no (unless you parsed the text file as php code.. which wouldn't be safe nor practical)

Link to comment
Share on other sites

is it possible to make a $variable from a text file

 

If you have a known file type where every other line is the name/definition you could do this:

 

<?php
$file = array(0 => "name = val1", 0 => "jackson2"); // file() functon will put file into an array
foreach ($file as $val) {
     $split = split(" = ", $val);
     $$split[0] = $split[1]; // assign $name = val1
}
?>

 

Not recommended as putting them into an array is alot safer, quicker and easier to access imo.

<?php
$file = array(0 => "name = val1", 0 => "jackson2"); // file() functon will put file into an array
foreach ($file as $val) {
     $split = split(" = ", $val);
     $values[$split[0]] = $split[1]; // assign $value['name'] = val1
}

print_r($values);
?>

 

Link to comment
Share on other sites

Not sure what you are getting at, technically you are not assing them to a variable you are just printing them out to make them appear like you are assigning them to variables.

 

I am also not sure if a variable can start with a number...(not 100% on this but pretty sure).

Link to comment
Share on other sites

thats not the actual saved data lol this is

numTimes = 10

shorturl = mznHorbWesw

autoplay = &autoplay=1

reloadtime = 5

setwidth = 425

setheight = 344

fullurl = http://www.youtube.com/watch?v=mznHorbWesw

 

Then When Displayed

 

its Displays as

 

$numTimes = 10

$shorturl = mznHorbWesw

$autoplay = &autoplay=1

$reloadtime = 5

$setwidth = 425

$setheight = 344

$fullurl = http://www.youtube.com/watch?v=mznHorbWesw

 

I want it to display as a variable

Link to comment
Share on other sites

is it possible to make a $variable from a text file

 

If you have a known file type where every other line is the name/definition you could do this:

 

<?php
$file = array(0 => "name = val1", 1 => "jack = jackson2"); // file() functon will put file into an array
foreach ($file as $val) {
     $split = split(" = ", $val);
     $$split[0] = $split[1]; // assign $name = val1
}
?>

 

Did that not give you your answer. If the variables are in a file, like you said the above would assign $name = "val1" ?

 

<?php
$file = array(0 => "name = val1", 1 => "jack = jackson2"); // file() functon will put file into an array
foreach ($file as $val) {
     $split = split(" = ", $val);
     $$split[0] = $split[1]; // assign $value['name'] = val1
}
echo $jack . "<Br />";
echo $name . "<Br />";

?>

 

Prints out

jackson2
val1

Link to comment
Share on other sites

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.