Forum Moderators: coopster

Message Too Old, No Replies

Having trouble inserting records to a table.

         

contraband

11:00 pm on Jan 18, 2006 (gmt 0)

10+ Year Member



currently i am using the code:

$query ="INSERT INTO table_name (Field_name) VALUES ($name)";
$result = mysql_query($query);

and it doesnt seem to be inserting.

am i doing it wrong?

thanks in advance,

andy

coopster

1:07 am on Jan 19, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, contraband.

String values should be quoted.

$query ="INSERT INTO table_name (Field_name) VALUES ('$name')";

Note the single quotation marks around the $name variable.

dreamcatcher

9:29 am on Jan 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Also use mysql_error to show errors:

$result = mysql_query($query) or die(mysql_error());

dc