Forum Moderators: coopster
<input type="text" name="firstname">
next page looks like this
<?php
//connect to MySQL
$connect = mysql_connect("hosting.com", "username", "password")
or die ("error.");
//make sure we're using the right database
mysql_select_db("no2");
//insert data into "details" table
$insert = "INSERT INTO details (firstname) " .
"VALUES ('".$_POST['firstname']."')";
$results = mysql_query($insert)
or die(mysql_error());
?>
there is no error shown and when i view the databse a record has been added but no data inside!
Any ideas on this please?
either
$insert = "INSERT INTO details (firstname) VALUES ('{$_POST[firstname]}')";
$results = mysql_query($insert) or die(mysql_error());
or
$insert = "INSERT INTO details (firstname) VALUES ('".$_POST[firstname]."')";
$results = mysql_query($insert) or die(mysql_error());
and yes do
echo "insert: $insert";
that could explain, why you are having problems.
Echo and print_r are the most popular debugging tools I use ;)
Michal