|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-12-31 11:30 UTC] flim at novadoc dot de
I wanted to connect to a ftp server, get some files and insert them into a database.
I started connecting to the ftp server, then logging in and that worked fine. Then I added a mysql_connect and now I get an error on ftp_login that says that it can not find ftpbuf.
(tried on two systems: Linux Redhat 6.2, Linux Redhat 7.2).
I'm not sure if this is a failure of ftp functions, mysql, a documentation problem or me being too stupid.
After dropping all unneccessary code, the file looks like that:
<?php
$hHandle=mysql_connect("localhost", "nobody", "")
or die ("no connection.\n");
mysql_close ($hHandle); #this can be dropped
$hFtp = ftp_connect ("localhost") #this works
|| die ("Could not connect.\n");
# next line results in an error:
$iLoginResult=ftp_login($hFtp, "nobody", "")
|| die ("Error: Unable to login\n");
?>
I got the following error message:
Warning: Unable to find ftpbuf 1 in "scipt" on line "XX",
(which is the ftp_login line (ftp_connect works!)).
If you drop mysql_connect, its working fine...
I'm using build in mysql support (for version 3.23.39), ftp is of course enabled too.
Hopefully this is a stupid question and there is an easy answer...
Thanks in advance and a happy new year,
flim
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 18:00:01 2025 UTC |
Your code doesn't watch out for operator precedence: $foo = function1() || die("i'm dead now"); will evalute to $foo = ( function1() || die("i'm dead now") ); which means $foo will be true (if function1 succeeded). For your code this means: $hFtp = ( ftp_connect ("localhost") || die ("Could not connect.\n") ). and therefore $hFtp will be boolean true and not your resource/connection id. Proper parenthesizing will solve this: ( $hFtp = ftp_connect ("localhost") ) || die ("Could not connect.\n");