Hi there, im fairly new to computer programing so excuse my question if its obvious but im trying to get the arduino to connect to a mysql datebase, this is to store the pin output of the arduino for a homeautomation project. I have set up a working PHP please see below and this connects from an HTML page using forms. How can i adapt this to work with the arduino sending the pin output.
I have spent weeks trying to work this out and many hours googling to just find myself getting more and more lost. any help will be much appreciated.
have obviously taken my webserver name, password and username out.
-------my PHP file on my webserver---------------------------------------------
<?php $con = mysql_connect("my_webhost","username","password"); if (!$con) { die('could not connect: ' .mysql_error()); } mysql_select_db("my_database", $con); $sql="INSERT INTO Automation (arduino,pin2,pin3,pin4,pin5,pin6) VALUES ('$_POST[arduino]','$_POST[pin2]','$_POST[pin3]','$_POST[pin4]','$_POST[pin5]','$_POST[pin6]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con); ?>--------my current working html page-------------------------------------------
arduino:pin2:
pin3:
pin4:
pin5:
pin6: