This week I spent a lot of time working on a personal PHP project that I’m very excited about. It’s finally starting to come together and work the way I want it to, and most of the things in my open tabs have to do with that.
Using trim() in PHP
PHP has a built-in function that trims whitespace from the beginning and end of a string. This is useful if your database content has spaces around it, and you need to get rid of them.
Using TRIM in MySQL
The previous function is good if you can’t do anything about the data (say, if someone else is entering it and you don’t have access to the database itself). But if the database is yours–as mine is on this project–you can use TRIM in MySQL to strip trailing spaces (or other characters, like newlines or tabs) before it ever gets to your PHP.
PHP The Right Way
Back in 2001, I knew PHP pretty well. Through the years, I’ve kept up with it on a need-to-know basis, but I’m learning (or re-learning) the specifics and, more importantly, the modernizations that make it more secure and sophisticated than it was back then. This is an excellent resource both for people who are just learning PHP and for those of us who are trying to re-learn it and break any old bad habits.
Retro and Vintage in Modern Web Design
My current project requires a vintage look, because (surprise) it involves vintage books. Even though this list is pretty old, and some of the links don’t work (or the sites they link to have been redesigned), I was quite inspired by some of them.
Bonus: A couple months ago when I picked up my project again, I used SQLify to import my data from the Access database it’s been in for YEARS. SQLify is very versatile: You can use it to convert to and from .csv, .json, or SQL. You can import or copy and paste. When directly converting my data didn’t work for me, I ended up exporting each table from my Access database as .csv, then converting it to SQL with SQLify, copying and pasting, and manually adding it to my database in PHPMyAdmin on my server. It took a while, but hey, it worked. Although somewhere in the process I did end up with a lot of whitespace on either side of my data, which is why I ended up needing to know how to trim it. 🙂
That’s all for this week. Next week: THE PROJECT (I hope)!