0

Here is my query in PDO:

$stmval = $pdo -> prepare("SELECT bio, first_name, last_name, options FROM wp_connections WHERE `email` LIKE '%".$_COOKIE["e"]."%' ORDER BY ID ASC LIMIT 1" );
$stmval -> execute();
$wp_connectionsdb = $stmval -> fetch();
$stmval -> closeCursor();
echo $wp_connectionsdb['options'];

Problem is options cell contains stuff like:

a:3:{s:5:"entry";a:1:{s:4:"type";s:10:"individual";}s:5:"group";a:1:{s:6:"family";a:0:{}}s:5:"image";a:4:{s:6:"linked";b:1;s:7:"display";b:1;s:4:"name";a:1:{s:8:"original";s:12:"fdv33.jpg";}s:4:"meta";a:1:{s:8:"original";a:8:{s:4:"name";s:12:"fdv33.jpg";s:4:"path";s:103:"/home/someurl/public_html/wp-content/uploads/connections-images/xxx/fdv33.jpg";s:3:"url";s:96:"http://someurl.com/wp-content/uploads/fdv33.jpg";s:5:"width";i:553;s:6:"height";i:552;s:4:"size";s:24:"width="553" height="552"";s:4:"mime";s:10:"image/jpeg";s:4:"type";i:2;}}}} 

How can I extract from above mess only URL property "http://someurl.com/wp-content/uploads/fdv33.jpg"

Anyone recognizes this data system?

Should I use mySQL or PHP to somehow extract what I need?

I'm sure this question will need to be moderated after answer is provided tho without actually knowing how to name it I'm simply unsure how to provide correct title for this question.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Greg Viv
  • 817
  • 1
  • 8
  • 22
  • 2
    Using $_COOKIE in an SQL expression is a wide open door to [SQL injection](https://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php?rq=1). – syck Nov 08 '16 at 14:20
  • 1
    It's not quite JSON, You're looking for PHP's `unserialize` method, which will give you an array to play with http://php.net/manual/en/function.unserialize.php – JKirchartz Nov 08 '16 at 14:20
  • Although this question is marked as duplicate its not a duplicate of the linked question in my opinion and should probably be moved to http://wordpress.stackexchange.com/. – jnhghy - Alexandru Jantea Nov 08 '16 at 14:34
  • I've tried with json decode but in the end unserialize was the keyword I needed. Also good hint on cookie method. – Greg Viv Nov 08 '16 at 14:52

0 Answers0