jnerotrix Posted December 6, 2008 Share Posted December 6, 2008 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>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/135754-unexpected-end/ Share on other sites More sharing options...
ballhogjoni Posted December 6, 2008 Share Posted December 6, 2008 ur missing a curly brace "}" some where in your code Quote Link to comment https://forums.phpfreaks.com/topic/135754-unexpected-end/#findComment-707320 Share on other sites More sharing options...
peranha Posted December 6, 2008 Share Posted December 6, 2008 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>"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/135754-unexpected-end/#findComment-707322 Share on other sites More sharing options...
balistic Posted December 6, 2008 Share Posted December 6, 2008 yeah just needs one added on the end. Quote Link to comment https://forums.phpfreaks.com/topic/135754-unexpected-end/#findComment-707324 Share on other sites More sharing options...
jnerotrix Posted December 6, 2008 Author Share Posted December 6, 2008 now the page display is nothing at all Quote Link to comment https://forums.phpfreaks.com/topic/135754-unexpected-end/#findComment-707326 Share on other sites More sharing options...
Philip Posted December 6, 2008 Share Posted December 6, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/135754-unexpected-end/#findComment-707328 Share on other sites More sharing options...
jnerotrix Posted December 6, 2008 Author Share Posted December 6, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/135754-unexpected-end/#findComment-707333 Share on other sites More sharing options...
jnerotrix Posted December 6, 2008 Author Share Posted December 6, 2008 is it possible to make a $variable from a text file Quote Link to comment https://forums.phpfreaks.com/topic/135754-unexpected-end/#findComment-707339 Share on other sites More sharing options...
Philip Posted December 6, 2008 Share Posted December 6, 2008 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) Quote Link to comment https://forums.phpfreaks.com/topic/135754-unexpected-end/#findComment-707340 Share on other sites More sharing options...
premiso Posted December 6, 2008 Share Posted December 6, 2008 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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/135754-unexpected-end/#findComment-707343 Share on other sites More sharing options...
jnerotrix Posted December 6, 2008 Author Share Posted December 6, 2008 Well it writes it into the text file as 123 = 123 234 = 234 345 = 345 Then using the foreach (file($useripdata) as $line) { echo '$' . $line; } Code it echo's it as $123 = 123 $234 = 234 $345 = 345 So would This Work Quote Link to comment https://forums.phpfreaks.com/topic/135754-unexpected-end/#findComment-707344 Share on other sites More sharing options...
premiso Posted December 6, 2008 Share Posted December 6, 2008 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). Quote Link to comment https://forums.phpfreaks.com/topic/135754-unexpected-end/#findComment-707347 Share on other sites More sharing options...
Philip Posted December 6, 2008 Share Posted December 6, 2008 Or just print it out in a format like "$123"? <?php $var = 'variableName'; $$var = 'test'; echo $var; //prints variableName echo $variableName; // prints test ?> Are you trying to do like variable variables? Quote Link to comment https://forums.phpfreaks.com/topic/135754-unexpected-end/#findComment-707350 Share on other sites More sharing options...
jnerotrix Posted December 6, 2008 Author Share Posted December 6, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/135754-unexpected-end/#findComment-707352 Share on other sites More sharing options...
Philip Posted December 6, 2008 Share Posted December 6, 2008 So you want to be able to call $numTimes later in your PHP script and it would display 10, is that correct? Quote Link to comment https://forums.phpfreaks.com/topic/135754-unexpected-end/#findComment-707353 Share on other sites More sharing options...
jnerotrix Posted December 6, 2008 Author Share Posted December 6, 2008 yes Quote Link to comment https://forums.phpfreaks.com/topic/135754-unexpected-end/#findComment-707356 Share on other sites More sharing options...
fanfavorite Posted December 6, 2008 Share Posted December 6, 2008 $var1 = "numTimes"; $var2 = "shorturl"; $var3 = "autoplay"; $var4 = "reloadtime"; ... $$var1 = 10; $$var2 = "mznHorbWesw"; $$var3 = "&autoplay=1"; $$var4 = 5; echo $numTimes."<br />"; echo $shorturl."<br />"; echo $autoplay."<br />"; echo $reloadtime; Quote Link to comment https://forums.phpfreaks.com/topic/135754-unexpected-end/#findComment-707443 Share on other sites More sharing options...
premiso Posted December 6, 2008 Share Posted December 6, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/135754-unexpected-end/#findComment-707705 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.