please help me
it usually gives me error ( it says cant enter the values )

<?php
$host = "localhost";
$con = mysql_connect("localhost","awah","password") or die ("error to connect to the server");

// contact the table and enter the form
mysql_select_db("kigalifinders_clanteam_admin", $con);
$query = mysql_query("INSERT INTO contacts(from, subject, message) value('$_POST[email]','$_POST[subject]','$_POST[messgae]')");
if(!$query)
{
die ("cant enter the values");
}
mysql_close();
?>

It should be:

INSERT INTO table (columns) VALUES (values)

instead of VALUE.

Hi, dear

Check this out!

<?php
$con = mysql_connect("localhost","awah","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("my_db", $con);

$sql="INSERT INTO contacts (from, subject, message)
VALUES
('$_POST[email]','$_POST[subject]','$_POST[message]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";

mysql_close($con)
?>

okay , i will try it now
thanks

Never mind.

now try this code is it working for you or not..

i have got this error

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from, subject, message) VALUES ('awah.mohamad@yahoo.com','what is wrong in this ' at line 1

wait let me check this out!

Perhaps a single quote in the subject ?

Have u checked this script on any server... because same error. i think there is some bug in php version...

not exactly your values are coming correctly... still i m trying to resolve it..

Use word values insted of value in insert command

The problem is that "from" is a sql keyword. If you use a keyword as a column name, you need to encapsulate it. If you don't, sql will think you are asking for a query FROM a database.

Here is the correct syntax. INSERT INTO contacts (`from`, `subject`, `message`) VALUES ('{$_POST['email']}','{$_POST['subject']}','{$_POST['message']}')"; And it is good coding practice to encapsulate the other variables as well as I have show above.

All the best.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.