php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14781 ftp_login failure after mysql_connect
Submitted: 2001-12-31 11:30 UTC Modified: 2002-01-02 05:30 UTC
From: flim at novadoc dot de Assigned:
Status: Not a bug Package: FTP related
PHP Version: 4.1.1 OS: Linux Redhat 6.2/7.2
Private report: No CVE-ID: None
 [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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-01 07:56 UTC] mfischer@php.net
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");
 [2002-01-02 05:30 UTC] flim at novadoc dot de
Well...ahm. Should have thought of that myself I guess...thanks a lot. And sorry to bother you with things I should solve on my own :-)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 14:01:28 2024 UTC