PDA

View Full Version : [PHP] Help with problem



iUnknown
04-07-2008, 10:36 PM
Hello,

This is part of my PHP code:


<?php
if($port != !$port)
{
$port = $_POST['port'];
$handle = fopen('/home/XXXXXXXXXXX/public_html/players/'. $port .'.asx', "x+");
$line1 = '<ASX version="3.0">'
$line2 = '<title>Radio</title>'
$line3 = '<entry>'
$line4 = ' <title>Radio</title>'
$line5 = ' <author>Tech-Hosts.co.uk</author>'
$line6 = ' <ref href="http://shoutcasts.tech-hosts.com:'. $port .'/"/>'
$line7 = '</entry>'
$line8 = '</ASX>'

fwrite($handle, $line1."\n")
fwrite($handle, $line2."\n")
fwrite($handle, $line3."\n")
fwrite($handle, $line4."\n")
fwrite($handle, $line5."\n")
fwrite($handle, $line6."\n")
fwrite($handle, $line7."\n")
fwrite($handle, $line8."\n")
fclose($handle);

I get this error when simply opening the document ($port is nothing/not defined).


Parse error: syntax error, unexpected T_VARIABLE in /home/XXXXXXXX/public_html/playercode.php on line 45

Line 45 is:


$line2 = '<title>Radio</title>'

I'm not very good at PHP, I just pick things up as I go along and I've never spent time learning it. I'm trying to code a simple PHP script so I knew I'd need some real help along the way.

+rep to the first person to give a correct solution.

Thanks.

craigg.
04-07-2008, 10:38 PM
<?php
if($port != !$port)
{
$port = $_POST['port'];
$handle = fopen('/home/XXXXXXXXXXX/public_html/players/'. $port .'.asx', "x+");
$line1 = '<ASX version="3.0">';
$line2 = '<title>Radio</title>';
$line3 = '<entry>';
$line4 = ' <title>Radio</title>';
$line5 = ' <author>Tech-Hosts.co.uk</author>';
$line6 = ' <ref href="http://shoutcasts.tech-hosts.com:'. $port .'/"/>';
$line7 = '</entry>';
$line8 = '</ASX>';

fwrite($handle, $line1."\n");
fwrite($handle, $line2."\n");
fwrite($handle, $line3."\n");
fwrite($handle, $line4."\n");
fwrite($handle, $line5."\n");
fwrite($handle, $line6."\n");
fwrite($handle, $line7."\n");
fwrite($handle, $line8."\n");
fclose($handle);

iUnknown
04-07-2008, 10:40 PM
Haha thanks, +rep. One last thing, my bit at the top isn't working properly:


if($port != !$port)
{

It's doing that code even if $port isn't defined. Is there any other way to do this? I want it so when they post a form on that page it does the code below that, but if they haven't then I just want it to ignore that section (don't want to use else, just one if will do).

+rep to the person who can give me a correct solution fastest for that. Thanks.

iUnknown
04-07-2008, 10:59 PM
Sorry, can't edit, managed to work it out myself. Thanks. Thread closed.

Want to hide these adverts? Register an account for free!