prosiłbym o przeanalizowanie kodu ,
na serwerze mam umieszczone poniższe pliki ale jest problem ze wstawianiem danych do tabeli, przy próbie wysłania danych przez pasek przeglądarki tabela nie zostaje zaktualizowana o nowy wpis
używam polecnia http://adres.strony/add.php?temp1=5&hum1=3
connect.php
Kod
<?php
function Connection()
{
$server="userdb1";
$user="1145068_KmM";
$pass="?

";
$db="?

?";
$connection = mysql_connect($server, $user, $pass);
if (!$connection) {
die('MySQL ERROR: ' . mysql_error());
}
mysql_select_db($db) or die( 'MySQL ERROR: '. mysql_error() );
return $connection;
}
?>
function Connection()
{
$server="userdb1";
$user="1145068_KmM";
$pass="?



$db="?



$connection = mysql_connect($server, $user, $pass);
if (!$connection) {
die('MySQL ERROR: ' . mysql_error());
}
mysql_select_db($db) or die( 'MySQL ERROR: '. mysql_error() );
return $connection;
}
?>
add.php
Kod
<?php
include("connect.php");
$link=Connection();
$temp1=$_POST["temp1"];
$hum1=$_POST["hum1"];
$query = "INSERT INTO `tempLog` (`temperature`, `humidity`)
VALUES ('".$temp1."','".$hum1."')";
mysql_query($query,$link);
mysql_close($link);
header("Location: index.php");
?>
include("connect.php");
$link=Connection();
$temp1=$_POST["temp1"];
$hum1=$_POST["hum1"];
$query = "INSERT INTO `tempLog` (`temperature`, `humidity`)
VALUES ('".$temp1."','".$hum1."')";
mysql_query($query,$link);
mysql_close($link);
header("Location: index.php");
?>
index.php
Kod
<?php
include("connect.php");
$link=Connection();
$result=mysql_query("SELECT * FROM `tempLog` ORDER BY `timeStamp` DESC",$link);
?>
<html>
<head>
<title>Sensor Data</title>
</head>
<body>
<h1>Temperature / moisture sensor readings</h1>
<table border="1" cellspacing="1" cellpadding="1">
<tr>
<td> Timestamp </td>
<td> Temperature 1 </td>
<td> Moisture 1 </td>
</tr>
<?php
if($result!==FALSE){
while($row = mysql_fetch_array($result))
{ printf("<tr><td> %s </td><td> %s </td><td> %s </td></tr>",
$row["timeStamp"], $row["temperature"], $row["humidity"]);
}
mysql_free_result($result);
mysql_close();
}
?>
</table>
</body>
</html>
include("connect.php");
$link=Connection();
$result=mysql_query("SELECT * FROM `tempLog` ORDER BY `timeStamp` DESC",$link);
?>
<html>
<head>
<title>Sensor Data</title>
</head>
<body>
<h1>Temperature / moisture sensor readings</h1>
<table border="1" cellspacing="1" cellpadding="1">
<tr>
<td> Timestamp </td>
<td> Temperature 1 </td>
<td> Moisture 1 </td>
</tr>
<?php
if($result!==FALSE){
while($row = mysql_fetch_array($result))
{ printf("<tr><td> %s </td><td> %s </td><td> %s </td></tr>",
$row["timeStamp"], $row["temperature"], $row["humidity"]);
}
mysql_free_result($result);
mysql_close();
}
?>
</table>
</body>
</html>