I'll post here for the sake of thread's completeness😃
First about what etoast is using in his code
$query ="INSERT INTO cottagemap (plot, agency, houseID, named, described, sleeps, linkz)";
$query.=" VALUES ('$plot','$agency','$houseID','$named','$described','$sleeps','$linkz')";
This $query. (with a dot) is a way of concatenation? So he is like continuing the query although he could do it in one line? Or is there any reason to this?
My galling problem with (simple:rolleyes: ) insert statement: It is a simple mysql insert but nothing is going into the db. (like etoast said).
<html>
<head>
<title>feedback</title>
</head>
<body>
<?php
if (!$_POST['user'] || !$_POST['email'] || !$_POST['comments']) {
?>
<h2>Fill in</h2>
<br />
Please fill in all field.
<br />
<a href="feedback.html">Go back</a>
<?php
exit;
}
$user = addslashes($_POST['user']);
$email = addslashes($_POST['email']);
$comments = addslashes($_POST['comments']);
$db = mysql_connect("localhost", "root");
mysql_select_db("sample", $db);
$addfeedback = "INSERT INTO feedback (user, email, spam, comments)
VALUES ('.$user.', '.$email.', '.$spam.', '.$comments.')";
$result = mysql_query($feedback);
?>
<h2>Thank you</h2>
<br />
We have added your comment to our database.
</body>
</html>
I get the Thank you We have added your comment to our database. but that has to do something with that this is just a plain HTML always output no matter what PHP does (or doesn't)?
I'm suspecting the exit; statement (although it is put into the if clause).
The tutorial says to put another double quotes into query like this:
$addfeedback = "INSERT INTO feedback (user, email, spam, comments)
VALUES ('".$user."', '".$email."', '".$spam."', '".$comments."')";
saying that some problems could arrise regarding the different PHP configurations.
Is this still a thing (the tutorial is outdated you see) with "new" (PHP5?) PHP? Won't work with just ' or with ' and " together.