-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathinsert_mysql.php
More file actions
29 lines (24 loc) · 774 Bytes
/
insert_mysql.php
File metadata and controls
29 lines (24 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
foreach ($_REQUEST as $key => $value)
{
if ($key == "yourdata") {
$yourdata = $value;
}
}
// EDIT: Your mysql database account information
$username = "test_user";
$password = "test_password";
$database = "test_db_name_here";
$tablename = "test_table_name_here";
$localhost = "localhost";
// Check Connection to Database
if (mysql_connect($localhost, $username, $password))
{
@mysql_select_db($database) or die ("Unable to select database");
// Next two lines will write into your table 'test_table_name_here' with 'yourdata' value from the arduino and will timestamp that data using 'now()'
$query = "INSERT INTO $tablename VALUES ($yourdata,now())";
$result = mysql_query($query);
} else {
echo('Unable to connect to database.');
}
?>