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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
supaseeds
Forum Newbie
Posts: 13
Joined: Tue Jul 13, 2004 8:09 am

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

Post 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...
User avatar
MarK (CZ)
Forum Contributor
Posts: 239
Joined: Tue Apr 13, 2004 12:51 am
Location: Prague (CZ) / Vienna (A)
Contact:

Post by MarK (CZ) »

I think that quoting of the variable could help.

Code: Select all

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