Foreign Characters create symbols in PHP and MySQL
- Category: Personal Home Page
- Hits: 21681
- PHP 5.4
- MySQL 5.1.4
- Databases initially setup with collation 'latin1_swedish_ci'
What
Another article trying to help people display foreign characters on their website without the funny question marks in diamond symbols and how I solved it in my case.
htaccess Rewrites SEF URL and submits to PHP
- Category: Personal Home Page
- Hits: 19074
A quick note on a htaccess rewrite rule I'm liking.
What does it do?
What I type:
http://www.mywebsite.com/blog/videos.htmlSends this to server:
http://www.mywebsite.com/index.php?myFolder=blog&myFiles=videosHow?
Convert XML UTF-16 to JSON UTF-8 with PHP cURL
- Category: Personal Home Page
- Hits: 40535
Fix PHP cURL: parser error: Document labelled UTF-16 but has UTF-8 content
What?
This is an article with notes for me on how to convert some received XML encoded in UTF-16 to some JSON in UTF-8. If it were entirely in UTF-8, I would simply load the received XML with SimpleXML and use the built-in PHP JSON_encode function. I ran into the following errors:
Warning: SimpleXMLElement::__construct() [<a href='simplexmlelement.--construct'>simplexmlelement.--construct</a>]: Entity: line 1: parser error : Document labelled UTF-16 but has UTF-8 content in /public_html/.../.../my_script.php on line ###
Warning: simplexml_load_string() [<a href='function.simplexml-load-string'>function.simplexml-load-string</a>]: Entity: line 1: parser error : Document labelled UTF-16 but has UTF-8 content in /public_html/.../.../my_script.php on line ###Why?
So I've googled, binged and yahoo'd for this and although there are some solutions that deal with loading UTF16 content into SimpleXMLElement or simplexml_load_string, it doesn't solve my problem. I'm receiving XML data within a cURL result but I get the above error with using either "SimpleXMLElement" or "simplexml_load_string". Returning the XML with cURL isn't a problem, but I want to convert it to JSON and I usually use a PHP function to load the data into an XML array and use the built-in PHP function: "json_encode".
How?
PHP: First name and Initial of Surname
- Category: Personal Home Page
- Hits: 12927
A note for myself on some code to convert a string of two names into a string made up of the first name and then using the initial of the second name.
-- What I have John Smith Fred.Bloggs -- What I want John S. Fred B.
How?
Preg_Replace all strings between two tags
- Category: Personal Home Page
- Hits: 53853
For those of you who use Preg_Replace. Preg_replace is a function that uses regular expressions to search and replace a string.
Why?
Because my understanding with regular expressions is shady and varies from language to language, I've written this article as a quick reference point.
How?
Php convert filesizes to bytes kb mb gb
- Category: Personal Home Page
- Hits: 19534
Just a quick note on how to format a given filesize and to reduce the display output to a small string, eg:
196 bytes : displays as => "196 bytes" 12945 bytes : displays as => "12 Kb" 1478515 bytes : displays as => "1 Mb" 8798745455 bytes : displays as => "8 Gb"
Counting the occurence of a word within a string: Benchmark
- Category: Personal Home Page
- Hits: 14038
I added this article because when I was only trying to look up how to do this, this nut "the Storyteller" went and carried out a benchmark test on the most popular ways of counting the occurrence of a specific word within a string of text.
Using a HTML form and PHP to upload a file
- Category: Personal Home Page
- Hits: 23074
Basically you have a HTML form with an input field type of 'FILE' (ie. <input type="file" name="file_to_upload" />) and want a PHP file to process this. This example applies to a Linux Apache MySQL PHP (LAMP) environment.
The Solution
1. The first thing to do is check that your HTML form is setup to do this:
Page 7 of 9
Credit where Credit is Due:
Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.
Disclaimer: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience in a commercial setting.
Thank you for visiting and, as always, we hope this website was of some use to you!
Kind Regards,
Joel Lipman
www.joellipman.com
Latest Articles
Accreditation



Donate & Support
If you like my content, and would like to support this sharing site, feel free to donate using a method below:

bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4
0xb038962F3809b425D661EF5D22294Cf45E02FebF
Paypal:

Bitcoin:

Ethereum:
