Pages: [1] 2   Go Down
Author Topic: Asking for help to execute a PHP script  (Read 1966 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

* Arduino code.txt (1.43 KB - downloaded 37 times.)
* Arduino-PHP-MySQL.pdf (121.43 KB - downloaded 32 times.)
* ApacheLogError.txt (0.3 KB - downloaded 18 times.)
« Last Edit: April 28, 2013, 09:55:50 am by psnap » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
God Member
*****
Karma: 39
Posts: 988
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

-br
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How, exactly, do you execute the PHP script using a browser? I'm almost positive you are not typing just:
Quote
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?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)

* updateDB2.txt (0.44 KB - downloaded 23 times.)
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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?
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 138
Posts: 5835
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9470
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Among other things it seems you assign an IP address to the arduino, then make a DHCP request for an IP address.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1] 2   Go Up
Jump to: