Reputation: 1
Here is a little php program I did a few years ago (it worked then...) As I recently tried to incorporate it to my new "website", no data is inserted in my table...
(when I run it, I don't receive any error message)
If anyone could tell me what's wrong, I'd be very glad. THX!
// data,from a form on another page, that I want to insert in my db
$nom = $_POST['nom'];
$prenom = $_POST['prenom'];
$date = $_POST['date'];
$identifiant = $_POST['identifiant'];
$password = $_POST['password'];
// connexion to my database
$connexion = mysql_connect("mysql5.000webh.com","a888888_user","mypassword");
mysql_select_db("a888888_mydatabase",$connexion);
// creation and sending of SQL query
$requete = "insert into panel values
('','$nom','$prenom','$date','$identifiant','$password')";
mysql_query($requete);
echo "Vos donnees ont ete envoyees !";
include('page.html');
// closing Mysql connexion
mysql_close();
Upvotes: 0
Views: 1088
Reputation: 11
Instead of directly executing your query like,
mysql_query($requete);
Use a variable to fetch the result of the query using a variable like,
$result = mysql_query($requete);
Now use a simple check whether your query was executed or not by just using an if statement and then use the mysql_error()
function to see the error.
if ( !$result ) {
die( mysql_error() );
}
Upvotes: 1
Reputation: 23297
You didn't specify the fields in which to inser the values:
$requete = "insert into panel values
('','$nom','$prenom','$date','$identifiant','$password')"
Upvotes: 0