2

I am using shared hosting and first time trying to read data from Firebird file. I have an interface that allow user to select their .fdb file via below:

HTML

<label class="title">Import by FBD File</label>
<input type="file" class="input-file input-importFDB" name="filefdb" id="filefdb" >
<input class='btn btn-primary' type='submit' id='btnImportFDB' name='btnImportFDB' value='Import'>

PHP file

if (isset($_POST['btnImportFDB'])){
    $host = $_FILES["filefdb"]["tmp_name"];
    $username = 'SYSDBA';
    $password = 'masterkey';

    $dbh = ibase_connect($host, $username, $password);
    $stmt = 'SELECT * FROM customer;';
    $sth = ibase_query($dbh, $stmt);
    while ($row = ibase_fetch_object($sth)) {
        echo $row->CUST_NO.'<br/>';
    }
    ibase_free_result($sth);
    ibase_close($dbh);
}

The error I am getting is:

[21-Sep-2017 19:36:06 Asia/Singapore] PHP Warning:  ibase_connect(): Unable to complete network request to host &quot;localhost&quot;. Failed to establish a connection.  in /home/mywebproject/demo.mywebsite.com.my/validate/myfile.php on line 56
[21-Sep-2017 19:36:06 Asia/Singapore] PHP Warning:  ibase_query(): invalid database handle (no active connection)  in /home/mywebproject/demo.mywebsite.com.my/validate/myfile.php on line 58
[21-Sep-2017 19:36:06 Asia/Singapore] PHP Warning:  ibase_fetch_object() expects parameter 1 to be resource, boolean given in /home/mywebproject/demo.mywebsite.com.my/validate/myfile.php on line 59
[21-Sep-2017 19:36:06 Asia/Singapore] PHP Warning:  ibase_free_result() expects parameter 1 to be resource, boolean given in /home/mywebproject/demo.mywebsite.com.my/validate/myfile.php on line 62
[21-Sep-2017 19:36:06 Asia/Singapore] PHP Warning:  ibase_close() expects parameter 1 to be resource, boolean given in /home/mywebproject/demo.mywebsite.com.my/validate/myfile.php on line 63

Update on what I want to achieve:

  1. I want to allow my user to specify the .fdb path located in their local machine, the path will be capture in my website.
  2. The user will just click on a button to 'transfer' (upload) the data from the .fdb file to my website.
  3. So here I am getting the errors as shown above. Mind if I ask what are the other methods to achieve the same objective as mine? Should I just request my users to perform so called data dump/data import/data upload in text/XML/excel(csv) format?
0

2 Answers 2

2

You are uploading a database file from a client to the server to connect to it? That is an odd thing to do to say the least. Normally you would host the database on the server, and connect to it (maybe after allowing the client to specify which database to use).

In this case, it looks like you get this error because there is no Firebird server installed on your host, or because it runs on a different port than the default port 3050 (as indicated by Unable to complete network request to host 'localhost' in the error). In my experience shared hosting with Firebird is rare, so you might want to check with your hosting company if they actually offer Firebird, and if so what port to use.

This will (might) also not work properly for the following reasons:

  • When the client is using Windows and the server is using Linux, Firebird server will not be able to open the database,
  • The Firebird server process on a correctly configured server should not be able to access files from the webserver process
Sign up to request clarification or add additional context in comments.

4 Comments

Hi Mark, thanks for your valuable time and feedback. I've updated my question, please don't mind to advise me again.
@4LeaveCover My answer remains the same: you don't seem to have a Firebird server running (or on a different port), and even if you solve that you are probably going to run into different problems. The only real way is to backup a database and restore it on the server, or indeed use excelsheets, csv, etc to upload data.
What I want is the data from the user, but the user may be using MySQL, MSSQL, Firebird, MS Access etc. So instead of asking them to upload the DB file, I should convince them to perform data extraction on their end and upload/dump into my system?
@4LeaveCover Given that you'd have an even harder time correctly uploading an SQL Server or MySQL database, I think that would be better, yes.
0
Error:    Unable to complete network request to host &quot;localhost&quot;

Pay attention on the quotes in the name of host

1 Comment

I think that is just PHP that is escaping the error message for you, because given how the $host variable is populated, it will only contain the path to the file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.