php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74762 ftp_connect makes php break with RID error
Submitted: 2017-06-15 03:03 UTC Modified: 2017-07-03 07:55 UTC
From: jmichae35 at gmail dot com Assigned:
Status: Not a bug Package: FTP related
PHP Version: 7.1.6 OS: windows 7 x64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
34 + 44 = ?
Subscribe to this entry?

 
 [2017-06-15 03:03 UTC] jmichae35 at gmail dot com
Description:
------------
PHP Parse error:  syntax error, unexpected 'RID' (T_STRING), expecting ',' or ';' in T:\w2\jtr\ftp7a.php on line 361

Test script:
---------------
$conn_id = ftp_connect($host,$port) or die("ERROR: ftp_connect() could not get FTP connection! \r\n");

Expected result:
----------------
a valid connection. I even tried lowercasing the domain (which should not be necessary). domains are to be case insensitive according to the RFC.

Actual result:
--------------
PHP Parse error:  syntax error, unexpected 'RID' (T_STRING), expecting ',' or ';' in T:\w2\jtr\ftp7a.php on line 361

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-06-15 05:45 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2017-06-15 05:45 UTC] requinix@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.

This does not sound like a PHP bug. Make sure your code is syntactically valid.
 [2017-06-15 18:48 UTC] kalle@php.net
-Status: Feedback +Status: Not a bug
 [2017-06-15 18:48 UTC] kalle@php.net
The code itself you posted is valid, so the syntax error must occur at a later point in your code and does not imply a bug in PHP itself
 [2017-06-18 02:37 UTC] jmichae35 at gmail dot com
<?php 
$server="somewhere.com";
$port=21;
$conn_id = ftp_connect($server,$port) or die("ERROR: ftp_connect() could not get FTP connection! \r\n");?>

I was surprised you took out the time to nail me for not including <?php tags ?> instead of trying the script. it's easy to use. try your own FTP server.
 

did you know the die statement is absolutely required now and I can't just compare $conn_id===false later for validity check?
 [2017-06-18 06:17 UTC] spam2 at rhsoft dot net
Damned your script has a syntax error somewhere around line 361 and nobody but you comes to the idea file a parse error as bug for whatever php function
 [2017-06-20 22:05 UTC] jmichae35 at gmail dot com
having fun blasting at this bug? use your head and enable and try an ftp_connect. see if it returns something that can be stored in a variable or whether it breaks all over.

I refuse your curses.
 [2017-06-20 22:38 UTC] jmichae35 at gmail dot com
this line of code came out of my large script. that's where the line number comes from. I cannot include the rest of my script because it is commercial code.
I tried the example from the documentation (the 1st sample) the documentation got updated since then. 

then I made it work like it's supposed to work today, with a newly required die statement.

why is die required and not optional?

if you take out the die statement, it throws a RID error statement in the same format as my 1st error I showed you.
"PHP Parse error:  syntax error, unexpected 'RID' (T_STRING), expecting ',' or ';' in ... on line ..."

my server doesn't take normal ftp either.


I am sorry for getting angry. I know that dealing with bugs all day long can really get to a guy, and you start to need a refreshing time.
 [2017-06-20 22:57 UTC] spam2 at rhsoft dot net
"PHP Parse error:  syntax error, unexpected 'RID' (T_STRING), expecting ',' or ';' in ... on line ..." is clearly a parse error

you 3 options:

* prove with "php -l /path/to/file.php" that it has no error
* publish your file
* leave the world in peace with things only you are able to see

"why is die required and not optional?" - no clue what you are talking about
 [2017-06-27 04:46 UTC] jmichae35 at gmail dot com
winkle burgers
 [2017-07-03 06:54 UTC] jmichae3 at yahoo dot com
try dropping the die statement and see if it still works.
<?php 
$server="somewhere.com";
$port=21;
$conn_id = ftp_connect($server,$port) /*or die("ERROR: ftp_connect() could not get FTP connection! \r\n")*/;?>

now you get the RID error.
 [2017-07-03 07:55 UTC] requinix@php.net
somewhere.com does not host a public FTP server so your repro code is invalid.
To be nice, I switched $server to the hostname of a public server I found via Google and... it works fine. No problems. No surprise.

Since you aren't able to give us a valid repro script, and since I'm rather looking forward to the conclusion of this, instead give us a link to where we can see the full version of your ftp7a.php. (Don't post it here.) Then we can look at it, tell you what the problem is with your code, and put this mess behind us.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue May 24 09:05:44 2022 UTC