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

    Join Date
    Aug 2000
    Location
    Eindhoven, NL
    Posts
    22
    Rep Power
    0
    if ($Submit) {

    if ($id) { mysql_query("UPDATE clients SET name='$name', email='$email', credits='$credits', upload='$upload',
    stats='$stats', max='$max', purchase='$purchase' WHERE (id='$id')") or die ("can't get query update!");}
    else { mysql_query("INSERT INTO clients (name, email, credits, upload, stats, max, purchase) VALUES ('$name', '$email', '$credits', '$upload', '$stats', '$max', '$purchase')") or die ("can't get query new !"); }
    }

    Why the f*ck does this fail?

    an angry user
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    I'm not sure, but then again your code is dang near impossible to read ;-)

    Try it this way (you can read more about REPLACE in the mysql manual):

    if ($submit)
    {
    if (!$id) $id='null';
    $query="replace into clients (id,name,email,credits,upload,stats,max,purchase) values ($id,'$name','$email','$credits','$upload','$stats','$max','$purchase')";
    mysql_query($query) or die ...;
    }

    Are all those values strings? You shouldn't use quotes around numeric values you are inserting... i.e. if $max is numeric it should be written ,$max, not ,'$max',

    if you see what I'm saying. Important, don't put quotes around $id as it will either be numeric or 'null' so that it will create a new record and 'null' can't have quotes around it or mysql will interpret it to mean the string 'null' not the special value null.

Similar Threads

  1. php script won't work inside "cgi-local" directory
    By Volitics in forum PHP Development
    Replies: 5
    Last Post: April 26th, 2004, 11:50 PM
  2. Can Named Anchors be invoked inside Movie Clips?
    By binkey in forum Flash Help
    Replies: 0
    Last Post: July 25th, 2003, 01:43 AM
  3. Including JS files inside another JS file
    By Mirolist in forum HTML Programming
    Replies: 6
    Last Post: July 22nd, 2003, 06:32 PM
  4. a loop inside IF inside a loop
    By wannabe in forum PHP Development
    Replies: 4
    Last Post: March 15th, 2003, 04:27 PM
  5. scope of variable inside js function
    By jahu in forum HTML Programming
    Replies: 4
    Last Post: February 20th, 2003, 01:47 AM

IMN logo majestic logo threadwatch logo seochat tools logo