Skip to content

Tag: php

PHP/MySQL: Get name for specific ID

I am a beginner to MySQL and Im trying to retrieve a name for a specific ID. Here is how my database looks like: I have a table of contacts which contains ID, first and last name. I want to retrieve the first and last name for a specific ID in the same form. So I want to end up

Uploading multiple images with one input field

i have created a photography website with an admin page that uploads photos to different categories in a mysql table. This much works, but i can only upload one file at a time and i’d like to be able to select multiple images. Here’s the form And here’s the php for parsing the form I looked …

PHP filter_input_array for $_FILES?

Is there a way to filter_input_array for $_FILES? I tried but it doesn’t seem to be the same syntax as $_POST: And after quick check of the Constants List shows that it isn’t an installed definition for filter_input_array. So, should I define it some other way? DEFINE(‘INPUT_FILES’ $_F…

PHP multipart form data PUT request?

I’m writing a RESTful API. I’m having trouble with uploading images using the different verbs. Consider: I have an object which can be created/modified/deleted/viewed via a post/put/delete/get request to a URL. The request is multi part form when there is a file to upload, or application/xml when …

Replacing x or more dots

I want a clean solution to replace dots in text: Some title…. to this: Some title… Some…. title…… to this: Some… title… How can I replace every sequence of more than 3 dots with 3 dots? Answer With a regular expression based search and replaceDocs: The pattern says: M…

WordPress strip single shortcode from posts

I want to strip just the shortcodes in my blog posts. The only solution I found is a filter that I added to my functions. It removes all shortcodes including which I need for images. How can I specify a single shortcode to exclude or include? Answer To remove only the gallery shortcode , register a callback f…

Resetting array pointer in PDO results

I’m having trouble moving from MySQL SELECT methods to PDO methods. I want to iterate through a fetched array twice, both times starting with row zero. In MySQL I would use: Using PDO methods, I’m not sure how to accomplish the same thing. The code below is how I am trying to do this. The first wh…