#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    11
    Rep Power
    0
    define("TABLENAME","soreal");

    $db=mysql_connect(localhost,root,password);
    mysql_select_db("mydb",$db);

    if (!$result=mysql_query('UPDATE '.TABLENAME.' SET name = "'.$name.'" , area = "'.$area.'" , kind = "'.$kind.'" , money = "'.$money.'" , $file_description = "'.$file_description.'" WHERE ID = '.$id,$db)){
    echo "<p><h1>Error, I haven't change the fields</h1></p>";
    } else {
    echo "<p><h1>Fields changed</h1></p>";
    }
    mysql_free_result($result);

    Output will be <p><h1>Error, I haven't change the fields</h1></p> :

    WHY????? (if I do on a mysql client 'UPDATE '.TABLENAME.' SET name = "'.$name.'" , area = "'.$area.'" , kind = "'.$kind.'" , money = "'.$money.'" , $file_description = "'.$file_description.'" WHERE ID = '.$id (OF COURSE, I CHANGE THE VARIABLES BY THE VALUES) and works!!!! )

    PS: Sorry my bad english ;-)
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    109
    Rep Power
    15
    Try this statement:

    if (!$result=mysql_query("UPDATE $TABLENAME SET name='$name', area='$area', kind='$kind', money='$money', file_description='$file_description' WHERE id='$id'",$db)) {

    1. You had also an error in the part >>>$file_description=".'$file_description'.<<< take away the first "$" !!

    2. You have not closed the statement with "'" !!!+

    Hope it works
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    11
    Rep Power
    0
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by pwluky:
    Try this statement:

    if (!$result=mysql_query("UPDATE $TABLENAME SET name='$name', area='$area', kind='$kind', money='$money', file_description='$file_description' WHERE id='$id'",$db)) {

    1. You had also an error in the part >>>$file_description=".'$file_description'.<<< take away the first "$" !!

    2. You have not closed the statement with "'" !!!+

    Hope it works
    [/quote]

    Thanks ;-) I "think" the problem was the "$file_descrition" but I'm not sure...

    ------------------
    {C00L|Z3R0} on irc.ptnet.org

Similar Threads

  1. mysql sum fields
    By blues82 in forum MySQL Help
    Replies: 8
    Last Post: February 12th, 2004, 10:00 AM
  2. Problem to update record in mysql
    By vb_good in forum MySQL Help
    Replies: 3
    Last Post: January 24th, 2004, 02:44 PM
  3. Validate PHP form and update MySQL table
    By tlugosi in forum PHP Development
    Replies: 2
    Last Post: January 18th, 2004, 03:26 PM
  4. Replies: 1
    Last Post: January 16th, 2004, 08:39 PM
  5. detecting auto-increment fields with DBI (MySQL)
    By quelrat in forum Perl Programming
    Replies: 0
    Last Post: January 12th, 2004, 02:25 PM

IMN logo majestic logo threadwatch logo seochat tools logo