ERROR: Could not be able to execute INSERT INTO taarifa (TAREHE,) VALUES. ('miiss'. You have an error in your SQL syntax; check | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

ERROR: Could not be able to execute INSERT INTO taarifa (TAREHE,) VALUES. ('miiss'. You have an error in your SQL syntax; check

am trying to connect my html form tp my database but i got this error and here are the code <?php /* Attempt MySQL server connection. Assuming you are running MySQL server with default setting (user 'root' with no password) */ $mysqli = new mysqli("localhost", "root", "", "test"); // Check connection if($mysqli === false){ die("ERROR: Could not connect. " . $mysqli->connect_error); } // Escape user inputs for security $TAREHE = $mysqli->real_escape_string($_REQUEST['TAREHE']); // Attempt insert query execution $sql = ("INSERT INTO taarifa (TAREHE,) VALUES. ('$TAREHE'"); if($mysqli->query($sql) === true){ echo "Records inserted successfully."; } else{ echo "ERROR: Could not be able to execute $sql. " . $mysqli->error; } // Close connection $mysqli->close(); ?>

13th Sep 2018, 3:25 PM
cmm hacker
cmm hacker - avatar
3 ответов
+ 1
@ipang thanks so much, it worked
13th Sep 2018, 4:33 PM
cmm hacker
cmm hacker - avatar
0
You have invalid query string there, I guess this is probably what you meant: sql = "INSERT INTO taarifa (TAREHE) VALUES ('$TAREHE')"; And the TAREHE field should be a varchar variant for that query to work, as the value passed in was wrapped with single quotes => '$TAREHE' meaning it is assumed as string rather than number. Hth, cmiiw
13th Sep 2018, 4:13 PM
Ipang
0
You're welcome cmm hacker, hey I like that cute Koala, nice : )
13th Sep 2018, 4:36 PM
Ipang