Connecting Arduino with phpMyadmin


I working on a project to build a weather station with an Arduino that measures temperature, pressure values etc. These values will then be stored in a MySQL database which I’ll use to plot a live data on a web server. I’m using Apache web server with phpMyadmin installed. My problem is I don’t know how to write a PHP code to send data from my Arduino to the database. I’ll appreciate it if you can help me.

Before others post here - this has been done numerous times; why are you unable to find these resources (to everyone else, if you post a link to such a resource, you are doing the OP a disservice - how is s/he supposed to ever learn how to do research themselves)?


I found this code which I placed in the htdocs folder of apache but my database is still not showing the arduino value. How can I run this code please as I’m new to web servers?

test server page <? $temp1 = $HTTP_GET_VARS['temp1']; if(strlen($temp1) < 1) $temp1 = "0"; $dbcnx = mysql_connect("localhost","user", "password"); if(!$dbcnx) { echo( "

Unable to connect to the database server at this time.

" ); exit(); } if(!mysql_select_db("test") ) { echo( "

Unable to locate the test database at this time.

" ); exit(); } $result = mysql_query("INSERT INTO temperatures (temp1) VALUES ($temp1)"); if(!$result) echo("

Insert failed

"); else echo("

Insert ok

"); mysql_close($dbcnx); echo('temp1 = ' . $temp1 . ' '); ?>

Did you create the "temperatures" table in the database?

CREATE TABLE `temperatures` (
  `event_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `temp1` int(10) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`event_id`)


I created the database but it's called 'temperatures' while the table is called 'temp'. Since I already have Apache do I still need Ethernet shield before I can upload my data to the web server?