Cannot open COM port in PHP - php

I'm trying to open a COM port in PHP using the device's library file (file.dll) for the connection.
I get this error:
Fatal error: Uncaught exception 'com_exception' with message 'Source: file.DLL file.DLLDescription: com c:\users\user\folder\com.prg Error in line 9 OLE IDispatch exception code 0 from MSComm: The device is not open.. 1429' in C:\Users\user\folder\index.php:12 Stack trace: #0 C:\Users\user\folder\index.php(12): com->open(1, '115200,n,8,1') #1 {main} thrown in C:\Users\user\folder\index.php on line 12
The file 'com.prg' mentioned in the error does not exist in the folder (hidden files are visible).
I tried reinstalling MSComm, using another cable, using another port, reinstalling device drivers, updating PC drivers.
Here's the code:
<?php
$fp = new COM("file.dll");
echo "<br>". $fp->init();
echo "<br>". $fp->open(1, "115200,n,8,1");
echo "<br>". $fp->close();
?>
In open() command 1 - COM1 port, 115200 - bits per second, n - no parity, 8 - data bits, 1 - stop bits.
The connection works on another computer using the exact same configuration, so the problem here is not the code.
Any ideas?

Related

How i can connect MongoDB online cloud in PHP

i want online connection with MongoDB cloud in PHP
same source file working properly when i run on localhost in my laptop with empty $server string while i use mongoDb server cloud then i face an error
<?php
session_start();
// $server="";
$server='mongodb+srv://mongo_user_1:<password>#mongodb01-dolny.mongodb.net/test?retryWrites=true&w=majority';
$mongo = new MongoClient($server);
$db=$mongo->blogPosting;
$admin_cl=$db->admin;
$category_cl=$db->category;
$blog_cl=$db->blog;
$contact_cl=$db->contact;
$blog_comment_cl=$db->blog_comment;
?>
Fatal error: Uncaught exception 'MongoConnectionException' with
message '- Found unknown connection string option 'retryWrites' with
value 'true'' in G:\xampp\htdocs\mongo_blog\mongoDb.php:5 Stack trace:
0 G:\xampp\htdocs\mongo_blog\mongoDb.php(5): MongoClient->__construct('mongodb+srv://m...') #1
G:\xampp\htdocs\mongo_blog\blog\index.php(1):
include('G:\xampp\htdocs...') #2 {main} thrown in
G:\xampp\htdocs\mongo_blog\mongoDb.php on line 5

PHRETS Works Locally But Times Out On Web Server

I installed PHRETS with Composer and have been able to print information using CMD terminal and following the docs. I tried uploading all the files to my web server, but the page times out.
My error log shows the following:
PHP Fatal error: Uncaught exception 'GuzzleHttp\Ring\Exception\ConnectException' with message 'cURL error 7: Failed to connect to rets-rald.realtyserver.com port 6103: Connection timed out' in /public_html/phrets/vendor/guzzlehttp/ringphp/src/Client/CurlFactory.php:126
Stack trace:
#0 /public_html/phrets/vendor/guzzlehttp/ringphp/src/Client/CurlFactory.php(91): GuzzleHttp\Ring\Client\CurlFactory::createErrorResponse(Array, Array, Array)
#1 /public_html/phrets/vendor/guzzlehttp/ringphp/src/Client/CurlHandler.php(96): GuzzleHttp\Ring\Client\CurlFactory::createResponse(Array, Array, Array, Array, Resource id #69)
#2 /public_html/phrets/vendor/guzzlehttp/ringphp/src/Client/CurlHandler.php(68): GuzzleHttp\Ring\Client\CurlHandler->_invokeAsArray(Array)
#3 /public_html/phrets/vendor/guzzlehttp/ringphp/src/Client/Middleware.php(54): GuzzleHttp\Ring\Client\CurlHandler->__invoke(Array)
#4 /public_html/phrets/vendor/guzzlehttp/ringphp/src/Client/Middlewa in /public_html/phrets/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 49
How can I get it working on the web server? Below is my configuration.
$config = new \PHRETS\Configuration;
$config->setLoginUrl('http://rets-rald.realtyserver.com:6103/saskatchewan/rets/login');
$config->setUsername('username');
$config->setPassword('password');
$config->setRetsVersion('1.5');
$config->setUserAgent('PHRETS/2.0');
$config->setHttpAuthenticationMethod('digest');
$config->setOption('use_post_method', false);
$config->setOption('disable_follow_location', false);
Turns out, I just needed to enable port 6103 on the server.

Mantis SOAP-Error accessing mantisconnect.php (Eclipse Mylyn-Plugin)

I installed Mantis BT 1.2.19 on my server and it works well. To benefit from it in my Eclipse-IDE (Mars) I installed the Task-Repo Plugin for Mantis and tried to add the connection.
When I click on "Validate settings" in Eclipse I get the following error:
SOAP-ERROR: Parsing WSDL: Couldn't load from '/var/www/vhosts/{myhost}/httpdocs/mantis/api/soap/mantisconnect.wsdl' : failed to load external entity "/var/www/vhosts/{myhost}/httpdocs/mantis/api/soap/mantisconnect.wsdl"
In my error-log on the server are the following entries
[14-Oct-2015 11:25:05 Europe/Berlin] [mantisconnect.php] Error Type: SYSTEM WARNING,
Error Description: SoapServer::SoapServer(): I/O warning : failed to load external entity "/var/www/vhosts/{myhost}/httpdocs/mantis/api/soap/mantisconnect.wsdl"
Stack Trace:
mantisconnect.php L121 SoapServer(<string>'mantisconnect.wsdl', <Array> { ['features'] => 5 })
[14-Oct-2015 11:25:05 Europe/Berlin] PHP Warning: Uncaught SoapFault exception: [Server] Error Type: SYSTEM WARNING,
Error Description: SoapServer::SoapServer(): I/O warning : failed to load external entity "/var/www/vhosts/{myhost}/httpdocs/mantis/api/soap/mantisconnect.wsdl" in /var/www/vhosts/{myhost}/httpdocs/mantis/api/soap/mc_api.php:107
Stack trace:
#0 /var/www/vhosts/{myhost}/httpdocs/mantis/api/soap/mc_api.php(530): SoapActions::sendSoapFault('Server', 'Error Type: SYS...')
#1 [internal function]: mc_error_handler(2, 'SoapServer::Soa...', '/var/www/vhosts...', 121, Array)
#2 /var/www/vhosts/{myhost}/httpdocs/mantis/api/soap/mantisconnect.php(121): SoapServer->SoapServer('mantisconnect.w...', Array)
#3 {main}
thrown in /var/www/vhosts/{myhost}/httpdocs/mantis/api/soap/mc_api.php on line 107
[14-Oct-2015 11:25:05 Europe/Berlin] PHP Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from '/var/www/vhosts/{myhost}/httpdocs/mantis/api/soap/mantisconnect.wsdl' : failed to load external entity "/var/www/vhosts/{myhost}/httpdocs/mantis/api/soap/mantisconnect.wsdl"
in /var/www/vhosts/{myhost}/httpdocs/mantis/api/soap/mantisconnect.php on line 121
The errors above are produced by the Mantis plugin on accessing the URL
188.109.171.76 - - [14/Oct/2015:11:25:05 +0200] "POST /mantis/api/soap/mantisconnect.php HTTP/1.0" 500 1067 "-" "Mylyn/3.17.0 Mylyn-Mantis Connector/3.10.1 Apache Axis/1.4 Eclipse (org.eclipse.epp.package.jee.product) HttpClient/3.1 Java/1.8.0_60 (Oracle) Windows 7/6.1 (amd64; de_DE)"
But even a "normal" GET-access to the URL mentioned above produces the same error
https://{myhost}/mantis/api/soap/mantisconnect.php
No error is produced on accessing
https://{myhost}/mantis/api/soap/mantisconnect.php?wsdl
To solve the problem on my own I checked several ideas:
The file IS existant ... {myhost} is just a placeholder here obviously - placed by me
I switched to the context of the webserver www-data and tried accessing the file ... it IS accessible
So I´ve no idea...
PHP version is 5.5.9-1ubuntu4.13 on Ubuntu 14.04.3 LTS
€dit:
Tracked down the error to the following PHP-line in mantis/api/soap/mantisconnect.php
$server = new SoapServer("mantisconnect.wsdl",
array('features' => SOAP_USE_XSI_ARRAY_TYPE + SOAP_SINGLE_ELEMENT_ARRAYS)
);
I don´t understand why there an error is thrown - because as I said: it exists and is readable by the webserver...
€edit2:
I replaced the line
$server = new SoapServer("mantisconnect.wsdl",
with
$server = new SoapServer("http://{myhost}/mantis/api/soap/mantisconnect.wsdl",
THIS works... so I´ve a "solution" but I don´t know why the access via file does not work
I Think I found the answere on my own (my workaround failed some hours later - with same error again).
Seems to be a bug in PHP (on Ubuntu) as mentioned here
https://bugs.launchpad.net/ubuntu/+source/php5/+bug/1160336
Unresolved since 2013
:-(
My current workaround is disabling soap.wsdl_cache_enabled in php.ini which seems to help for the moment.

Failed to create COM object `WScript.shell': CoInitialize has not been called

At sometime today, this error occurred and the script hanged:
[21-Aug-2013 08:35:06] PHP Fatal error: Uncaught exception 'com_exception' with message 'Failed to create COM object `WScript.shell': CoInitialize has not been called.
' in C:\path\to\my\script.php:357
Stack trace:
#0 C:\path\to\my\script.php(357): com->com('WScript.shell')
#1 {main}
thrown in C:\path\to\my\script.php on line 357
This is the line (running in a loop) causing the error:
$com = new Com('WScript.shell');
This line usually runs fine so I'm not missing any libraries. Why could this happen ?
Go to php.ini and add this line. After that, restart php server. Good luck to you
extension=php_com_dotnet.dll
That is most likely due to desktop heap allocation error. One way to verify is to go to Windows Event Log (system category) and search for "desktop heap allocation failed" error or warning. As an workaround, you can consider using shell_exec.
For more details about desktop heap allocation error, see KB 184802
Effectively include the library "extension = php_com_dotnet.dll" in php.ini can serve in executing $ command = new Com ('WScript.Shell');
in my case it worked with Apache / 2.2.29 server (Win64) PHP / 3.5.29 mod_ssl / 2.2.29
thanks a lot.

Question about PHP PDO INFORMIX ERROR

I have installed PDO_INFORMIX and CSDK already on CentOS5.6 32bits
and index.php have
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
$db = new PDO("informix:host=172.30.179.81; service=5000;database=cms; EnableScrollableCursors=1", "myuser", "mypassword");
print("OK");
?>
but i still got this error
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE=HY000, SQLDriverConnect: -11060 [Informix][Informix ODBC Driver]General error.' in /usr/local/apache/htdocs/index3.php:5 Stack trace: #0 /usr/local/apache/htdocs/index3.php(5): PDO->__construct('informix:host=1...', 'myuser', 'mypassword') #1 {main} thrown in /usr/local/apache/htdocs/index3.php on line 5
Have anyone know what it is ?
Thanks
Ouch! The standard technique for finding out more about errors is:
$ finderr -11060
-11060 General error.
An error occurred that has no specific SQL_STATE. In this case,
additional text is provided that identifies the source of the problem.
This IBM Informix CLI error code is the same as SQLSTATE value S1000.
$
That is not very helpful - to be polite about it.
There are spaces in the connect string; does removing them help at all?
Can you telnet to the host 172.30.179.81?
Can you telnet to the port (service) 5000 on the host?
Can you connect from this machine using any other Informix tool?
Can you connect from other machines using the same connect string?
In case of desparation, can you track down whether all the shared libraries are loading correctly?

Categories