Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Jul 2008
    Posts
    74
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Help with Mysql Syntax to delete row from database.

    HI
    I need a script to delete a row from a database. I am not sure of the syntax of the statement due to the format of the database.

    This is an example row of the table that has four columns:

    ID Column:
    03h0l182i54d74w7x112x1c7887006kv-1458gjyg5olfslv77bb750khi4vi61gw
    CartID
    gmt5636boc429180q8h4zv59b1vb28po
    Cartdata
    a:30:{s:6:"randid";s:12:"29c090334ltk";}
    Time
    1350205041


    I know the value of s:12 in variable $randid.

    what I have been trying is variations of this
    Code:
    mysql_query("DELETE FROM ecom_cart WHERE '%s:6:\'randid\'`,\'s:12:\'".$randid."\'%'
    ")
    but just get errors.

    Any help would be appreciated.

    Thanks
    Rob

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,631
    Thanks
    4
    Thanked 147 Times in 138 Posts
    IN more simple terms your query says:
    Code:
    DELETE FROM table WHERE 'apples'
    Is it more obvious now what you have done incorrectly?

  • #3
    New Coder
    Join Date
    Jul 2008
    Posts
    74
    Thanks
    8
    Thanked 0 Times in 0 Posts
    not really!

  • #4
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,631
    Thanks
    4
    Thanked 147 Times in 138 Posts
    Okay I'll give you a broader hint. Apples has to be equal to something like a column perhaps.

  • #5
    New Coder
    Join Date
    Jul 2008
    Posts
    74
    Thanks
    8
    Thanked 0 Times in 0 Posts
    I realise that, but I can't work out the correct syntax which was the purpose of my post.

    Thanks for your assistance

  • #6
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,631
    Thanks
    4
    Thanked 147 Times in 138 Posts
    So don't you think you need CARTDATA = yourstring perhaps? and without CARTDATA being there you are getting an error message?

  • #7
    New Coder
    Join Date
    Jul 2008
    Posts
    74
    Thanks
    8
    Thanked 0 Times in 0 Posts
    I have never worked with a database in this format:

    a:30:{s:6:"randid";s:12:"29c090334ltk";}

    but yes I realise I need cartdata= but I have no idea of the syntax required to extract the value of s:12.

    I am sure I will resolve my problem using the Mysql litreature.

    Thanks

  • #8
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    Quote Originally Posted by robbiez View Post
    I have never worked with a database in this format:

    a:30:{s:6:"randid";s:12:"29c090334ltk";}
    That is a serialized array. Use unserialize() in PHP to get to the array and consequently, it's value.


  •  

    Posting Permissions

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