gpt4 book ai didi

php - Raspberry 4 (Buster) 上的 mysql/mariaDB 连接/权限出现问题; phpMyadmin 出错; MySQL Workbench 没有连接

转载 作者:行者123 更新时间:2023-11-29 15:26:11 25 4
gpt4 key购买 nike

我的项目是,一个带有 7 个传感器的气象站(Arduino MEGA)通过 php 脚本将数据发送到服务器“RASPI02”

在访问协议(protocol)中,我可以看到正确的消息...在此处输入图像描述 enter image description here “http/1.1”200 2075 响应,这一面应该没问题

但是这个草图中的某些内容一定是错误的,因为数据不会添加到数据库中数据库已准备就绪,并且通过 mariaDB-monitor 直接插入数据(屏幕截图1)

<?php
$con = mysqli_connect("localhost","user","password","WEATHER");
mysqli_set_charset($con,"utf8");

if (mysqli_connect_errno())
{
echo "Error connecting to MySQL db: " . mysqli_connect_error();
}

$tempin = $_GET["tempin"];
$temp = $_GET["temp"];
$dew = $_GET["dew"];
$heat = $_GET["heat"];
$speed = $_GET["wspd"];
$gust = $_GET["gust"];
$speedavg = $_GET["wspdavg"];
$wdir = $_GET["wdir"];
$wdiravg = $_GET["wdiravg"];
$h = $_GET["hum"];
$p = $_GET["pressure"];
$rain = $_GET["rain"];
$rainrate = $_GET["rainrate"];
$rad = $_GET["rad"];
$uvi = $_GET["uvi"];



if($tempin== "" || $temp=="" || $p=="" || $h=="" || $tempin== 0 || $temp==0 || $p==0 || $h==0 || $tempin< -40 || $temp< -40 || $tempin>60 || $temp>60 || $p>1050 || $p<950 || $h==0.01 || $h==0.02 || $h==0.03 || $h>99)
{
echo 'We cannot save bad values to DB!';
}
else
{
$ins = mysqli_query($con,"INSERT INTO `TEMP_db` (`tempin`) (`temp`) (`dew`) (`heat`) (`hum`) VALUES ('".$tempin."')('".$temp."')(\'b4".$dew."`)(\'b4".$heat."`)('".$h."')") or die (mysqli_error($con));
$ins1 = mysqli_query($con,"INSERT INTO ``WIND_db`(`wspd`)(`gust`)(`wspdavg`)(`wdir`)(`wdiravg`) VALUES (\'b4".$speed."`)(\'b4".$gust."`)(\'b4".$speedavg."`)(\'b4".$wdir."`)(\'b4".$wdiavg."`)") or die (mysqli_error($con));
$ins2 = mysqli_query($con,"INSERT INTO `Pressure_db` (`pressure`) VALUES ('".$p."')") or die (mysqli_error($con));
$ins3 = mysqli_query($con,"INSERT INTO `RAIN_db` (`rain`) (`rainrate`) VALUES ('".$rain."')('".$rainrate."')") or die (mysqli_error($con));
$ins4 = mysqli_query($con,"INSERT INTO `Solar_db` (`uvi`)(`rad`) VALUES ('".$uvi."')('".$rad."')") or die (mysqli_error($con));
echo 'Datas saved succesfully!';
}

?>

当我启动 MySQL Workbench 时,收到错误消息,无法连接到服务器?

在 phpMyAdmin 中,我可以定义用户,可以看到包含数据的表格,但是当我打开它时,会给出错误消息,但条目可用(2 截图 phpMA1 和 phpMA2)

有3个问题

1-草图“data-get.php”$ins,$ins1 - 4 ...插入...2- MySQL Workbench,连接问题3- phpMA错误消息

我期待通过这种方式获得更多信息,因为我已经研究过了,所以可能没有找到解决方案

提前非常感谢

马克斯·穆勒

抱歉,我无法添加更多屏幕截图!?

enter image description here

最佳答案

在第 10 行到第 24 行中,它将给出一个 php 通知:“未定义索引:”正如第 28 行(回显)“我们不能...”

当我查看 Apache2 access.log 时,所有数据都是正确的

我无法理解“未定义索引”这个问题!

关于php - Raspberry 4 (Buster) 上的 mysql/mariaDB 连接/权限出现问题; phpMyadmin 出错; MySQL Workbench 没有连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59074809/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com