Search the Community
Showing results for tags 'encoding'.
-
Good evening everyone. I am writing some custom code over a WP site and I noticed that a value I need to grab is encoded into a string from a mysql table such as this: a:3:{s:13:"checkout_type";s:14:"create-listing";s:4:"plan";i:41;s:6:"addons";a:0:{}} (The value i need to grab is the 41 in i:41) I'm just wondering if this is a 'type' of encoding and that a singular built in php function can do. If not, then I can do it on my own, just don't want to waste time exploding and str_replacing till I get it if it actually is a standard for metadata. Thank you kind gentlemen and lady developers -Steve
-
I'm using PHP to grab some JSON from this URL - goo.gl/xdIqEy I've tried using cURL and file_get_contents(), but the 'LastName' element always comes back looking like ─Éur─æi─ç If I view that URL in Chrome, it looks like ÄurÄ‘ić It should look like Đurđić It's obviously some kind of encoding issue, but how do I handle this? The HTTP response headers don't give any clues to the encoding type. I've tried a lot of different iconv combinations when I've got the string back in PHP - but no luck. If I go to that URL in IE, it let's me download the .json file to disk. When I open that in Sublime Text, it looks correct. Any advice?
-
Hi People I'm not too familiar with PHP. What are these characters? They were originally meant to be £ signs but are now �. I googled and changed the encoding from charset=iso-8859-1 to UTF-8, but then I get the � character or the square character Thanks Craig
-
- php
- characters
-
(and 1 more)
Tagged with:
-
I'm finishing up my first few php programs. They are getting input from a user via an HTML form, validating that data at both the client and server sides, and then inserting the data from the form into a MySQL table. It's actually working pretty well in most respects but I'm having a bit of a problem with apostrophes, otherwise known as single quotes. The forms can ask for a title of a book or film and when those titles contain apostrophes, such as Ender's Game or Logan's Run, the insert statement to the database breaks. I believe the apostrophe gets misinterpreted in the Insert statement as closing the apostrophe that preceeds the variable name. Therefore, if the title is Ender's Game, the '$title' gets messed up by having a single quote in the middle of the title. This is the actual insert statement from my code: $insert = "INSERT INTO TopicProposals_Themes (Date_Proposed, Proposer, Title, Discuss, Prepare, Comments) VALUES ('$date_proposed', '$proposer', '$title', '$discuss', '$prepare', '$comments')"; $result = mysql_query($insert, $con); if (!$result) { throw new Exception('Insert of Topic Proposal (Theme) into table failed. Please contact the webmaster. Error number: ' . mysql_errno($con) . '. Error message: ' . mysql_error($con)); } So, what is the correct remedy for this situation? Should I simply change the apostrophes in the insert statement to be quotes ("") instead of (')? Or am I right in suspecting that I need to encode the values when I read them from the form, converting the apostrophes to &apost; and then write the encoded version to the database? I've never had much to do with encoding and decoding and I'm still not clear on the difference between apostrophes and quotes in php so forgive my ignorance in knowing what the right solution is.