PHP Script SQL Error #1064

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
_phillip
 
Posts: 313
Joined: Fri Apr 09, 2021 3:28 pm

PHP Script SQL Error #1064

Post by _phillip »

I have been trying to resolve this SQL error for longer than I care to admit. Here is the PHP script:

Code: Select all

<?php
$temperature = $_POST['temperature'];	// nwas $_GET[]
$humidity 	 = $_POST['humidity']; 		// nwas $_GET[]

$dbname = 'pabriles_example';
$dbuser = 'pabriles_admin';  
$dbpass = '.########>>>'; 
$dbhost = 'www.redristracards.com'; 

$connect = @mysqli_connect($dbhost,$dbuser,$dbpass,$dbname);

if ($connect->connect_error){

	die("Connection failed: $sql");	// my code ...
} else {
	echo "YES!!  We connnected!<br><br>";

}

$sql = "INSERT INTO iot_project(temperature, humidity) VALUES ('$temperature', '$humidity')";

if ($connect->query($sql) === TRUE) {
	echo "ADDED: ".$temperature.", ".$humidity;
	} else {
		echo "ERROR!!!: ".$sql."<br>".$conn->error;
	}

$connect->close(); 
?>
Serial monitor results are as follows:
serial-monitor-results.png
serial-monitor-results.png (43.98 KiB) Viewed 51 times
And here is the SQL error message I get from the server:
sql-#1064-erro.png
sql-#1064-erro.png (73.23 KiB) Viewed 51 times
I have tried using various SQL syntax checkers and each regurgitate the same exact message which is no help. I have tweaked the 'INSERT INTO ...' sql code line several ways and nothing helps. This leads me to believe that the real error has nothing to do with this line. I am going to delete the db table and re-install it and see if that helps. I have no idea what else to try.

ANY HELP will be greatly appreciated.

Thank you!

User avatar
_phillip
 
Posts: 313
Joined: Fri Apr 09, 2021 3:28 pm

Re: PHP Script SQL Error #1064

Post by _phillip »

I just realized that I made a mistake. The following:
webpage-output.png
webpage-output.png (43.98 KiB) Viewed 45 times
was from a web page, not my serial monitor. Here is the serial monitor output:
Attachments
serial-monitor-output.png
serial-monitor-output.png (140.77 KiB) Viewed 45 times

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”