Go Down

Topic: Asking for help to execute a PHP script (Read 3825 times) previous topic - next topic


Apr 28, 2013, 04:34 pm Last Edit: Apr 28, 2013, 04:55 pm by psnap Reason: 1
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.


There is an issue being worked where pdf files are not handled correctly as attachments. You'll need to supply the data in some other format.


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.



There is no errors at all. MySQL works and php script works. Arduino code give no errors. Please look at new txt file just uploaded.


Please find Apache ErrorLog, newly uploaded.
I'm not familar wíth Apache, but it seems to be a library problem?


How, exactly, do you execute the PHP script using a browser? I'm almost positive you are not typing just:

in the URL field. So, why is that all you are putting in the GET request?

The M in WAMP stands for MySQL. Is that what you are referring to as "I have a SQL Database/table"?

Why does the script say DB2? Which database software are you using?


Please find Apache ErrorLog, newly uploaded.
I'm not familar wíth Apache, but it seems to be a library problem?

Not at all. It says that the Arduino is requesting a page that does not exist. See my previous reply.


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 (http://localhost/updatedb2.php)


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?


My updateDB2.php are working when execute from my Browser (http://localhost/updatedb2.php)

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.


Among other things it seems you assign an IP address to the arduino, then make a DHCP request for an IP address.
Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0


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] 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?


I have two PC's running WAMP

From PC A, can you access the web server on PC B? It looks like your Apache setup is not allowing external clients to access updateDB2.php.


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.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131