Skip to content

Tag: php

Parse JSON To Create SQL Insert Statements in PHP

I’m a newbie programmer trying to find my way in the world. I’ve got my hands on JSON data that I’m trying to parse out into SQL statements to populate multiple database tables. I would like to loop through each dimension of the array and pull out specific parts of it to create an INSERT sta…

PHP DOMDocument error Entity ‘nbsp’ not defined

I use DOMDocument for editing some HTML files, but some of theme have in their names spaces. So DOMDocument automaticly change the spaces to %20 and then can’t find them. This is how looks the error exactly: How to repair this error? Answer Use DOMDocument::loadHTMLFile() instead of load(). That’s…

Submitting a form using

I’m having a little trouble with this and can’t see what I’m doing wrong. I have this form: So when the user clicks the button it should submit the form then have this PHP to act upon the form (I know that the sql isn’t a prepared statement and is vulnerable to injections but this will…

PHP $_GET/$_POST via variable variables

I’m attempting to dynamically access both the $_GET and $_POST arrays, among others, using variable variables. The reason I’m trying to do this is so that I can perform similar actions on multiple arrays without needing to declare specific iterations for each. I’m reasonably sure this is pos…

Get YouTube video title in PHP

In one of my applications I am saving a YouTube video’s id… Like “A4fR3sDprOE”. I have to display its title in the application. I got the following code for getting its title and also it’s working fine. Now the problem is if any error occurred (in case of a delete of the video) P…

php array sorting with accents

I am using this to sort according to last name: But – when in last name is accent, e.g. Šiko, Áron, etc, these names are at the end. How can I sort it properly? Answer Use multi-byte string functions. There is a function called strcoll which seems to suit your needs. More info: On how to sort an array o…