Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-15-2012, 09:37 AM   PM User | #1
robbiez
New Coder

 
Join Date: Jul 2008
Posts: 70
Thanks: 8
Thanked 0 Times in 0 Posts
robbiez is an unknown quantity at this point
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
robbiez is offline   Reply With Quote
Old 10-15-2012, 01:18 PM   PM User | #2
guelphdad
Super Moderator


 
guelphdad's Avatar
 
Join Date: Mar 2006
Location: St. Catharines, Ontario Canada
Posts: 2,629
Thanks: 4
Thanked 147 Times in 138 Posts
guelphdad will become famous soon enoughguelphdad will become famous soon enough
IN more simple terms your query says:
Code:
DELETE FROM table WHERE 'apples'
Is it more obvious now what you have done incorrectly?
guelphdad is offline   Reply With Quote
Old 10-15-2012, 02:01 PM   PM User | #3
robbiez
New Coder

 
Join Date: Jul 2008
Posts: 70
Thanks: 8
Thanked 0 Times in 0 Posts
robbiez is an unknown quantity at this point
not really!
robbiez is offline   Reply With Quote
Old 10-15-2012, 02:26 PM   PM User | #4
guelphdad
Super Moderator


 
guelphdad's Avatar
 
Join Date: Mar 2006
Location: St. Catharines, Ontario Canada
Posts: 2,629
Thanks: 4
Thanked 147 Times in 138 Posts
guelphdad will become famous soon enoughguelphdad will become famous soon enough
Okay I'll give you a broader hint. Apples has to be equal to something like a column perhaps.
guelphdad is offline   Reply With Quote
Old 10-15-2012, 02:39 PM   PM User | #5
robbiez
New Coder

 
Join Date: Jul 2008
Posts: 70
Thanks: 8
Thanked 0 Times in 0 Posts
robbiez is an unknown quantity at this point
I realise that, but I can't work out the correct syntax which was the purpose of my post.

Thanks for your assistance
robbiez is offline   Reply With Quote
Old 10-15-2012, 06:48 PM   PM User | #6
guelphdad
Super Moderator


 
guelphdad's Avatar
 
Join Date: Mar 2006
Location: St. Catharines, Ontario Canada
Posts: 2,629
Thanks: 4
Thanked 147 Times in 138 Posts
guelphdad will become famous soon enoughguelphdad will become famous soon enough
So don't you think you need CARTDATA = yourstring perhaps? and without CARTDATA being there you are getting an error message?
guelphdad is offline   Reply With Quote
Old 10-15-2012, 07:06 PM   PM User | #7
robbiez
New Coder

 
Join Date: Jul 2008
Posts: 70
Thanks: 8
Thanked 0 Times in 0 Posts
robbiez is an unknown quantity at this point
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
robbiez is offline   Reply With Quote
Old 10-15-2012, 07:19 PM   PM User | #8
Inigoesdr
Super Moderator


 
Inigoesdr's Avatar
 
Join Date: Mar 2007
Location: Florida, USA
Posts: 3,601
Thanks: 2
Thanked 397 Times in 390 Posts
Inigoesdr is a jewel in the roughInigoesdr is a jewel in the roughInigoesdr is a jewel in the rough
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.
Inigoesdr is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:59 AM.


Advertisement
Log in to turn off these ads.