Forum Moderators: coopster

Message Too Old, No Replies

Insert row into SQL database

i can't figure out the syntax - EASY

         

WhosAWhata

2:58 am on Oct 27, 2005 (gmt 0)

10+ Year Member



this is my first attempt at inserting a row into the database and I am trying the following query.

$q = "INSERT INTO donovan (ymd,title,article) VALUES ($ymd,$title,$article)";

all i want to do is make a row that puts $ymd $title and $article into their respective columns, but my code doesn't seem to do anything

dkin

3:31 am on Oct 27, 2005 (gmt 0)

10+ Year Member



$q = "INSERT INTO donovan ( ymd, title, article) VALUES ('$ymd','$title', '$article')";
mysql_query = "$q";

not sure if that is in your code, but try it.

WhosAWhata

3:36 am on Oct 27, 2005 (gmt 0)

10+ Year Member



thanks, works great
but i had to change
mysql_query ="$q";
to
mysql_query($q);

i already did have that in the document, i guess the spaces in the columns made all the difference

coopster

3:16 pm on Oct 27, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



It is the quotation marks around string variables. Whenever you are entering data into your database table you need to enclose string data in quotation marks.