I kindly asking for help to execute a PHP script from Arduino sketch.
I need help to understand how it works. Over the past week I have tried to understand the routing from Arduino code to a PHP script which update a MySQL database. I'm pretty close, i think, but need the final push.
The project:
I have a SQL Database/table with 5 fields: id-temp-humi-dewp-date.
I have done a PHP script which update the SQL table called sensor1. It works if I insert fixed numbers and run the PHP from Browser.
Then I have Arduino code and hardware (Ethernet Shield) connected to my LAN. The MySQL (WAMP) is installed locally.
The arduino code have no errors and seems to connect to the server correctly. My problem is the PHP script is not been executed from Arduino.
I use the GET command to execute PHP file. The PHP file is placed in WAMP /www directory (localhost/phpscript.php)
I have attached a file for better understand.
Hope anyone can help me. I have no ideas left to solve my problem.
My goal is to update MySQL with the variables [temp - humi - dewp] from Arduino into mySQL database.
PS! To avoid any mistake in hardware, I try update to cosm, it works.
Sorry, I don't open PDF files from strangers. Please post .txt, .ino, or another non-virus-bearing format.
You say you have it working from the browser, but it fails when you attempt to make it work from the arduino. What do the apache error and access logs say on the LAMP system? You might get a clue as to what is what is wrong there.
It's MySQL not DB2 (IBM). The PHP filename is updateDB2.php (attached) The file is placed in my /www/ library on my wamp server. (same machine running Arduino.
I just want to know if the Arduino code is OK. It seems not according to Apache Errorlog (file attached).
My updateDB2.php are working when execute from my Browser
So, the browser strips the http: part off. That defines the protocol to use. The Arduino uses the http protocol by default.
The browser then strips the //localhost part. That defines the server, which the Arduino defines in the server[] array, passed to the client.connect method.
What does that leave? /updateDB2.php. That is not the same as updateDB2.php. Try properly specifying the location of the script (the leading slash IS necessary).
A script that writes hardcoded data into the database seems useless. Why doesn't the script take arguments?
That is a browser on the server. That is not a good test. Try that from another computer on the localnet.
I was involved in another thread like this, but I can't find it right now. There was a setting in the php extensions that allowed only localhost access only. If I find it, I'll post again.
Thanks, After change the Arduino code line:
client.println("GET /updateDB2.php") I add the / before the file name.
I got a new error from Apache Errorlog.
[Sun Apr 28 17:47:48 2013] [error] [client 192.168.1.75] client denied by server configuration: G:/WAMP/www/updateDB2.php
The error occurs both on my local machine and remote server (I have two PC's running WAMP).
In the php script I did not add any rights at the Databae and table. root without password to make it easy. Any idea?
Any idea how I add/change access. I have a user added to database with username & password.
And changed in the php file too. But same problem. I guess it may be in some .ini file. But where?
Generally, the idea is that you answer the questions we ask before asking new ones. The answers to the questions we ask provide context for the new ones you ask.
Problem solved!
My problem was a matter of rights on WAMP server.
For others who has same problem, you have to look in the Apache log file.
I change the Apache ini file "httpd.conf". Look for:
Options FollowSymLinks
AllowOverride None
Order deny,allow deny from all <<<-- Change from deny to Allow
Also check your Firewall allow post 3306 (default).