Page 1 of 1

FTP connection problem

Posted: Sat Sep 16, 2006 1:46 pm
by Omsis
I'm sorry, if the questio alredy has been answered, but i cwas not able to find a sulution...

Code: Select all

$ftpcon = ftp_connect(FTP_SERV,FTP_PORT) or die ('ERROR nr1');
            $ftplogin = ftp_login($ftpcon,FTP_USR,FTP_PASS) or die ('ERROR nr1');
            if ($ftplogin)
            {
                ftp_put($ftpcon,$file_name,$file_link,FTP_BINARY) or die ('ERROR nr1');
            }
            ftp_close($ftpcon);

Code: Select all

Problem: Fatal error: Call to undefined function ftp_connect() in /usr/home/hood-ftp/spele/funct.php on line 177
i dot gt it.... at home this php code runs perfectly, when i upload it to the web server, it throws this error at me.... some help, please? :)

Posted: Sat Sep 16, 2006 1:50 pm
by feyd
Maybe the FTP functionality isn't loaded?
Run the following in a new file and tell us the results please.

Code: Select all

<?php

$neg = array('off', 0, false, '', null);
$flags = array(
	'Register Globals' => 'register_globals',
	'Short Tags' => 'short_open_tag',
	'Display Errors' => 'display_errors',
	'Magic Quotes GPC' => 'magic_quotes_gpc',
	'Magic Quotes Runtime' => 'magic_quotes_runtime',
	'Magic Quotes Sybase' => 'magic_quotes_sybase',
);
$ve = phpversion();
$os = PHP_OS;
$er = intval(error_reporting());
foreach ($flags as $n => $v)
{
	$flags[$n] = (in_array(strtolower(ini_get($v)), $neg) ? 'Off' : 'On');
}
$cli = (php_sapi_name() == 'cli');
$eol = "\n";

$gle = get_loaded_extensions();
$rows = array();
$le = '';
$wide = 4;
$j = count($gle);
$pad = $wide - $j % $wide;
$len = max(array_map('strlen', $gle));
$func = create_function('$a', 'return str_pad($a, ' . intval($len) . ');');
$gle = array_map($func, $gle);
for($i = 0; $i < $j; $i += $wide)
{
	$le .= '   ' . implode('   ', array_slice($gle, $i, $wide)) . $eol;
}

$ec = array(
	'E_STRICT' => 2048, 'E_ALL' => 2047, 'E_USER_NOTICE' => 1024,
	'E_USER_WARNING' => 512, 'E_USER_ERROR' => 256, 'E_COMPILE_WARNING' => 128,
	'E_COMPILE_ERROR' => 64, 'E_CORE_WARNING' => 32, 'E_CORE_ERROR' => 16,
	'E_NOTICE' => 8, 'E_PARSE' => 4, 'E_WARNING' => 2, 'E_ERROR' => 1,
);

$e = array();
$t = $er;
foreach ($ec as $n => $v)
{
	if (($t & $v) == $v)
	{
		$e[] = $n;
		$t ^= $v;
	}
}
if (ceil(count($ec) / 2) + 1 < count($e))
{
	$e2 = array();
	foreach ($ec as $n => $v)
	{
		if (!in_array($n, $e) and $n != 'E_ALL')
		{
			$e2[] = $n;
		}
	}
	$er = $er . ' ((E_ALL | E_STRICT) ^ ' . implode(' ^ ', $e2) . '))';
}
else
{
	$er = $er . ' (' . implode(' | ', $e) . ')';
}

if (!$cli)
{
	echo '<html><head><title>quick info</title></head><body><pre>', $eol;
}

echo 'PHP Version: ', $ve, $eol;
echo 'PHP OS: ', $os, $eol;
echo 'Error Reporting: ', $er, $eol;
foreach ($flags as $n => $v)
{
	echo $n, ': ', $v, $eol;
}
echo 'Loaded Extensions:', $eol, $le, $eol;

if (!$cli)
{
	echo '</pre></body></html>', $eol;
}

?>

Posted: Sat Sep 16, 2006 5:16 pm
by Omsis
the server admin told me, that it was loaded....

here is the result:

Code: Select all

PHP Version: 5.1.4
PHP OS: FreeBSD
Error Reporting: 2039 ((E_ALL | E_STRICT) ^ E_STRICT ^ E_NOTICE))
Register Globals: Off
Short Tags: On
Display Errors: On
Magic Quotes GPC: On
Magic Quotes Runtime: Off
Magic Quotes Sybase: Off
Loaded Extensions:
   xmlwriter    libxml       dom          xmlreader 
   xml          tokenizer    standard     SimpleXML 
   SPL          session      PDO          SQLite    
   Reflection   posix        mysql        mbstring  
   imap         iconv        hash         gettext   
   gd           date         ctype        zlib      
   pcre         openssl
if understand corectly,it is not loaded, right?

Posted: Sat Sep 16, 2006 5:26 pm
by feyd
It would appear not, if comparing to my results:

Code: Select all

[feyd@home]>"\User data\feyd\bin"\php5\php -r "var_export(get_loaded_extensions());"
array (
  0 => 'bcmath',
  1 => 'calendar',
  2 => 'com_dotnet',
  3 => 'ctype',
  4 => 'date',
  5 => 'ftp',
  6 => 'hash',
  7 => 'iconv',
  8 => 'odbc',
  9 => 'pcre',
  10 => 'Reflection',
  11 => 'session',
  12 => 'libxml',
  13 => 'standard',
  14 => 'tokenizer',
  15 => 'zlib',
  16 => 'SimpleXML',
  17 => 'dom',
  18 => 'SPL',
  19 => 'wddx',
  20 => 'xml',
  21 => 'xmlreader',
  22 => 'xmlwriter',
)
Granted, I'm running Windows on my local machine.

Posted: Sun Sep 17, 2006 6:03 am
by Omsis
so, it apears, i have 2 choises
1) try to avoid the FTP functions
2)try to get the server's admin to load the ftp extension

is there a third? :)

if i choose the first, which aternative would be the best? :)

my plan:

Code: Select all

The WEB server www.serv.com
My FTP server ftp://xxx.xxx.xxx.xxx
i need the files uploaded via my script on http://www.serv.com bet put on my ftp server. actually, it may not be a FTP server, as long as the files in the end are on my home server! any ideas? :)

thnx for help! ;)

Posted: Sun Sep 17, 2006 9:23 am
by feyd
There's always finding a pure PHP solution or building your own. fsockopen() will likely be used.