-9

I have used tad php from github(https://github.com/cobisja/tad-php)now I am getting an error displayed below.

Fatal error: Uncaught exception 'TADPHP\Exceptions\ConnectionError' with message 'Imposible iniciar conexión con dispositivo 192.168.0.126' in C:\xampp\htdocs\tad\lib\TAD.php:409 Stack trace: #0 C:\xampp\htdocs\tad\lib\TAD.php(271): TADPHP\TAD->check_for_connection() #1 C:\xampp\htdocs\tad\index.php(44): TADPHP\TAD->__call('get_date', Array) #2 C:\xampp\htdocs\tad\index.php(44): TADPHP\TAD->get_date() #3 {main} thrown in C:\xampp\htdocs\tad\lib\TAD.php on line 409

I am using zk iface 302 device and I want to access data from DB of device through php

<?php
require 'lib/TADFactory.php';
require 'lib/TAD.php';
require 'lib/TADResponse.php';
require 'lib/Providers/TADSoap.php';
require 'lib/Providers/TADZKLib.php';
require 'lib/Exceptions/ConnectionError.php';
require 'lib/Exceptions/FilterArgumentError.php';
require 'lib/Exceptions/UnrecognizedArgument.php';
require 'lib/Exceptions/UnrecognizedCommand.php';


 $tad_factory = new TADPHP\TADFactory();

 use TADPHP\TADFactory;
 use TADPHP\TAD;



 $comands = TAD::commands_available();

 $b1 = (new TADFactory(['ip'=>'192.168.0.126']))->get_instance();

 $dt = $b1->get_date(); // method executed via TAD class.
echo $dt;

?>
Nima
  • 3,309
  • 6
  • 27
  • 44
Aihtsham Ali
  • 104
  • 2
  • 13

2 Answers2

9

You can't just copy and paste code from the Git example page when it is to do with connection configuration.

IPs are not the same.

Since you are using XAMPP you will need the code to be:

$b1 = (new TADFactory(['ip'=>'127.0.0.1']))->get_instance();

127.0.0.1 is an alias for localhost which is what you will be connecting to on your local machine. Naturally, this will change if you put this code into production as the IP will no longer be local.

I have never used the TAD library, however, based on the error message you supplied, the following should fix your problem. For now...

Please don't copy and paste, it's best to learn what the code does rather than take it and use it and move on.

JustCarty
  • 3,839
  • 5
  • 31
  • 51
0

Open the software to see the available READER IP address

From the Interface

$options =array(
'ip' => '192.168.1.252',   //Any of the above IP addresses from image above
'internal_id' => 100,    // 1 by default.
'com_key' => 123,        // 0 by default.
'description' => 'TAD1', // 'N/A' by default.
'soap_port' => 80,     // 80 by default,
'udp_port' => 4370,      // 4370 by default.
'encoding' => 'utf-8'    // iso8859-1 by default.
);
$tad_factory = new TADFactory($options);
$b1 =$tad_factory->get_instance();//The you can access your date
$dt = $b1->get_date();
joash
  • 2,205
  • 2
  • 26
  • 31