Page 1 of 1

All i want to do is put a variable into a MYSQL DB field...

Posted: Sun Aug 01, 2004 4:12 am
by supaseeds
I've got a table called email with two fields, emailname and useremail with one record inserted where emailname=1 and useremail = na@na.com

My current code, most of which probably isn't necessary:

Code: Select all

$r=mysql_query("SELECT useremail FROM email WHERE emailname=1") or die (mysql_error());
  $f=mysql_fetch_array($r);

   mysql_query("UPDATE email SET useremail=$fїmail]") or die (mysql_error());
produces the following error:
You have an error in your SQL syntax near '' at line 1

All I want to do is put the variable $f[mail] into the database field on the only record - how do i do this!? Many thanks in advance...

Posted: Sun Aug 01, 2004 6:13 am
by MarK (CZ)
I think that quoting of the variable could help.

Code: Select all

("UPDATE email SET useremail = '$f[mail]'")