English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

$username="pn_457871";
$password="********";
$database="pn_457871_database";
$host="sql1.phpnet.us";

$first=$_POST['first'];
$last=$_POST['last'];

mysql_connect($host,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query=INSERT INTO table VALUES ("$first","$last");
mysql_query($query);

mysql_close();
?>

It's connecting to the database, but not saving any results. The form (http://natedaweb.phpnet.us/radiopanel.html) has the right names for the text boxes (I think)

What's wrong?!?

2007-03-18 13:00:47 · 5 answers · asked by Christian_Dude 2 in Computers & Internet Programming & Design

5 answers

Its in the query.
$query=INSERT INTO table VALUES ("$first","$last");
mysql_query($query);

Should be:
$query = "INSERT INTO table (columnname1,columnname2) VALUES ('$first','$last')";

The punctuation was wrong but the biggest problem was you weren't specifying the columns to add the values to.

Also, if you're pulling the information from a form, you may need to use $_POST['first'] and $_POST['last']

2007-03-19 05:26:44 · answer #1 · answered by rob 3 · 0 0

Make sure you are using POST method in the form. If you have missed adding method attribute to form's tag, the form is by default submitted with GET method.

2007-03-20 02:10:52 · answer #2 · answered by Atif Majid 3 · 0 0

is $first empty ? check the database server log
to find out why insert is failing

2007-03-19 07:45:39 · answer #3 · answered by Anonymous · 0 0

THIS LINE:
$query=INSERT INTO table VALUES ("$first","$last");

You should be assigning the query string to the variable....but you need to do it like this.

$query="INSERT INTO table VALUES ($first,$last)";

2007-03-18 22:45:55 · answer #4 · answered by Jeffrey F 6 · 1 0

huh?


what exactly is this code supposed to be FOR...???

2007-03-18 20:21:03 · answer #5 · answered by soccergrl4103 3 · 0 0

fedest.com, questions and answers