SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2009
    Posts
    142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cant get sql update to work SOLVED

    I keep getting this error :

    Code:
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'a test post - edited, category = Frames, canada = Canada, price = 200, currency ' at line 3 [1064]
    
    SQL
    
    UPDATE phpbb_buysell SET username = ian, date = 2009 , part_name = This is a test post - edited, category = Frames, canada = Canada, price = 200, currency = CDN, status = OBO, description = This is a test post to see how images work or do they?, email = iantaylor603@gmail.com, image_a = http://p1.pinkbike.com/photo/2935/pbpic2935426.jpg, image_b = , image_c = WHERE id="$edit_id"
    With this code

    Code PHP:
    $edit_id = request_var('edit', 0);
     
    $sql = 'UPDATE phpbb_buysell SET username = '.$db->sql_escape(request_var('username','')).',
    date = '.$db->sql_escape(request_var('date',0)).' ,
    part_name = '.$db->sql_escape(request_var('part_name','')).',
    category = '.$db->sql_escape(request_var('category','')).',
    canada = '.$db->sql_escape(request_var('canada','')).',
    price = '.$db->sql_escape(request_var('price','')).',
    currency = '.$db->sql_escape(request_var('currency','')).',
    status = '.$db->sql_escape(request_var('status','')).',
    description = '.$db->sql_escape(request_var('description','')).',
    email = '.$db->sql_escape(request_var('email','')).',
    image_a = '.$db->sql_escape(request_var('image_a','')).',
    image_b = '.$db->sql_escape(request_var('image_b','')).',
    image_c = '.$db->sql_escape(request_var('imageca','')).'
     
    WHERE id="$edit_id"';
    Last edited by longneck; Feb 11, 2009 at 08:09.

  2. #2
    SitePoint Zealot
    Join Date
    Jan 2009
    Posts
    142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I changed it to this and the $edit_id works now but still the same error


    Code PHP:
    $edit_id = request_var('edit', 0);
     
    $sql = "UPDATE phpbb_buysell SET
    username = ".$db->sql_escape(request_var('username','')).",
    date = ".$db->sql_escape(request_var('date',''))." ,
    part_name = ".$db->sql_escape(request_var('part_name','')).",
    category = ".$db->sql_escape(request_var('category','')).",
    canada = ".$db->sql_escape(request_var('canada','')).",
    price = ".$db->sql_escape(request_var('price',0)).",
    currency = ".$db->sql_escape(request_var('currency','')).",
    status = ".$db->sql_escape(request_var('status','')).",
    description = ".$db->sql_escape(request_var('description','')).",
    email = ".$db->sql_escape(request_var('email','')).",
    image_a = ".$db->sql_escape(request_var('image_a','')).",
    image_b = ".$db->sql_escape(request_var('image_b','')).",
    image_c = ".$db->sql_escape(request_var('imageca',''))." 
    WHERE id='$edit_id'";

  3. #3
    SitePoint Zealot
    Join Date
    Jan 2009
    Posts
    142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Problem is solved

  4. #4
    SitePoint Evangelist ferrari_chris's Avatar
    Join Date
    Mar 2008
    Location
    NP, New Zealand
    Posts
    576
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What was the problem? I'm curious.

  5. #5
    SitePoint Zealot
    Join Date
    Jan 2009
    Posts
    142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ferrari_chris View Post
    What was the problem? I'm curious.
    forgot the ticks

    here is the working code

    Code PHP:
    $edit_id = request_var('edit', 0);
     
    $sql = "UPDATE phpbb_buysell SET
    username = ' ".$db->sql_escape(request_var('username',''))." ',
    date = ' ".$db->sql_escape(request_var('date',''))." ' ,
    part_name = ' ".$db->sql_escape(request_var('part_name',''))." ',
    category = ' ".$db->sql_escape(request_var('category',''))." ',
    canada = ' ".$db->sql_escape(request_var('canada',''))." ',
    price = ' ".$db->sql_escape(request_var('price',0))." ',
    currency = ' ".$db->sql_escape(request_var('currency',''))." ',
    status = ' ".$db->sql_escape(request_var('status',''))." ',
    description = ' ".$db->sql_escape(request_var('description',''))." ',
    email = ' ".$db->sql_escape(request_var('email',''))." ',
    image_a = ' ".$db->sql_escape(request_var('image_a',''))." ',
    image_b = ' ".$db->sql_escape(request_var('image_b',''))." ',
    image_c = ' ".$db->sql_escape(request_var('image_c','')). " ' 
    WHERE id='$edit_id'";

    with out them it was trying to do username= ian where i want it to do username ='ian'

  6. #6
    SitePoint Evangelist ferrari_chris's Avatar
    Join Date
    Mar 2008
    Location
    NP, New Zealand
    Posts
    576
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's what I thought it might have been.

    Thanks.

  7. #7
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    i've un-done your original post edit. please do not destroy your posts just because your problem has been solved. when you do that, you also destroy any opportunity for others to learn from your question.
    Check out our new Industry News forum!
    Keep up-to-date with the latest SP news in the Community Crier

    I edit the SitePoint Podcast


Bookmarks

Posting Permissions

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