www.webdeveloper.com
Results 1 to 5 of 5

Thread: Update where: LOSING MY MIND!

  1. #1
    Join Date
    Oct 2008
    Posts
    8

    Angry Update where: LOSING MY MIND!

    Ok I keep getting an error for this that says my syntax is wrong near "order=7". If I change it to any other column than "order", it works perfectly fine. What could possibly make that happen? This is driving me insane! Heres the code:

    PHP Code:
    <?
    session_start
    ();
    $uid $_SESSION['id'];
    include(
    "dbcon.php");

    $title $_POST['title'];
    $noteid $_POST['tnum'];



    $request "UPDATE notes SET title='$title' WHERE (user=$uid AND order=$noteid)";

    $query mysql_query($request) or die(mysql_error());

    if(
    $query){
        echo 
    "Success";
    }else{
        echo 
    "FFAILURE!!! - ".$request;
    }

    ?>
    I cant figure this out...

  2. #2
    Join Date
    Sep 2008
    Posts
    408
    What does your table look like? In particular what type of field is order?

    also, try throwing some single quotes and backticks up. sometimes theres weird glitches:

    PHP Code:
    $request "UPDATE `notes` SET `title`='$title' WHERE `user`=$uid AND `order`='$noteid'"

  3. #3
    Join Date
    Oct 2008
    Posts
    8
    Wow... thanks. I don't know what the problem was, but I guess the backticks did it. Speaking of which what do they do? I'd never heard of using them. I actually had to look at my keyboard to find the key for them. haha

  4. #4
    Join Date
    Jul 2008
    Location
    Athens, Greece
    Posts
    74
    well it is not weird glitches...

    it is just that the work order is a reserved keyword in sql language ( reserved for ordering results ) ..

    i am not sure about mysql (i suppose that is what you use), but in mssql you can always use field names with []
    so and order = $noteid should be and [order] = $noteid

    regards

  5. #5
    Join Date
    Sep 2008
    Posts
    408
    good call gabriele. and yeah, for mysql thats the use of the back tick `

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles