File: C:/xampp/htdocs/myapi/logSpotDb.php
<?php
// Assuming your PHP script interacts with a database or performs some other logic to generate data
// For this example, let's assume it generates a simple JSON response
// Sample data for demonstration purposes
error_reporting(0);
$getsn=$_GET['sn'];
$servername = "127.0.0.1";
$username = "root";
$password = "fredsql";
$DBNAME = "tvicheck-st";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
//echo "Connected successfully";
if( !mysqli_select_db($conn, $DBNAME)) {
die ("無法選擇資料庫");
}
mysqli_query( $conn, "SET NAMES 'utf8'");
$querys1 = "select spotDb from crbase where sn='$getsn' and activebit='1' ORDER BY id DESC LIMIT 1 ";
//echo $querys1;
$results1 = mysqli_query($conn, $querys1);
$num = mysqli_num_rows( $results1);
if ($num > 0)
{
$row = mysqli_fetch_object($results1);
$spotDb=$row->spotDb;
}
$spotDb=$spotDb+1;
$querys = "update crbase set spotDb='$spotDb' where sn='$getsn' ";
$results = mysqli_query($conn, $querys);
//echo $querys;
?>