Probelm with php
#1

I have a problem. I successfuly connect to FTP, but why it reads file from web host not VPS (I connect to VPS FTP)

PHP код:
<?php
    $ip 
"ip"// your server's IP-address (not checked anywhere)
    
$host "host"// your server's FTP's host
    
$user "user"// your server's FTP's username
    
$pass "pass"// your server's FTP's user's password
    
$file "OnlinePlayers.txt"// modify only if your host's FTP doesn't go to the server's dir on connect
    
$lang "en"// choose your preferred language here; supported: en, hu, sr
    // DON'T CHANGE ANYTHING AFTER THIS LINE!!!
    
$conn ftp_connect($host);
    if (!
$conn)
    {
    echo 
"Error: Could not connect to ftp server<br>";
    exit;
    }
    
ftp_login($conn$user$pass);
    
$myFile "OnlinePlayers.txt";
    if(!
is_readable($myFile)) {
    echo 
"ERROR";
    exit;
    }
    
$fh fopen($myFile'r');
    
$theData fread($fhfilesize($myFile));
    
fclose($fh);
    
//echo $theData;
echo '<div align="center">
    <table border="0" width="84%" id="table1">
        <tr>
            <td width="250">
            <p align="center">Name</td>
            <td width="149">
            <p align="center">Score</td>
            <td>
            <p align="center">Kills</td>
            <td>
            <p align="center">Deaths</td>
            <td width="238">
            <p align="center">Level</td>
        </tr>'
;
    
$handle = @fopen("OnlinePlayers.txt""r");
    if (
$handle) {
    while (!
feof($handle)) {
        
$buffer fgets($handle);
        
$exploded_data explode("=",$buffer);
    echo 
"<tr>
            <td width='250'>
            <p align='center'><a href='http://sf-streets.com/sign.php?name=[_FFG_]BuLLeT'>
            <span style='text-decoration: none'><font color='#000000'>
$exploded_data[0]</font></span></a></td>
            <td width='149'>
            <p align='center'>
$exploded_data[1]</td>
            <td>
            <p align='center'>
$exploded_data[2]</td>
            <td>
            <p align='center'>
$exploded_data[3]</td>
            <td width='238'>
            <p align='center'>
$exploded_data[4]</td>
        </tr>"
;
    
//}
    
}
    
fclose($handle);
    echo 
'</table>
</div>'
;
    }
    
ftp_close($conn);
    exit ;
?>
Reply
#2

Maybe a stupid question, but, do you set these:
Код:
    $host = "host"; // your server's FTP's host
    $user = "user"; // your server's FTP's username
    $pass = "pass"; // your server's FTP's user's password
And I think those php functions are not for FTP, but local.

EDIT:
Код:
$handle = fopen("ftp://user:password@example.com/somefile.txt", "w");
http://php.net/manual/en/function.fopen.php
Reply
#3

Explain more. What you filled in at "host" etc?

// I see wups asked it already.
Reply
#4

Quote:
Originally Posted by wups
Посмотреть сообщение
Maybe a stupid question, but, do you set these:
Код:
    $host = "host"; // your server's FTP's host
    $user = "user"; // your server's FTP's username
    $pass = "pass"; // your server's FTP's user's password
And I think those php functions are not for FTP, but local.

EDIT:
Код:
$handle = fopen("ftp://user:password@example.com/somefile.txt", "w");
http://php.net/manual/en/function.fopen.php
Yes i set host, user and password correctly. It connects, but as you said, it's a local function, so i think that's why. So how to read from file in FTP ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)