I’m currently developing a couple of plugins for Sublime Text 2 on OS X and I would like to make them cross platform, meaning I have to find out if and where php.exe is installed. Right now I call /…
Tag: php
Keep a check whether a value if selected from dropdown list using PHP
I need to keep a check on whether a value is selected by the user from the dropdown box other than the default value which is at null position. If selected (any value other than default ) then I want to set a variable say $varSet = 1 and if not $varSet = 0, so depending on the $varSet value,
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 …
Completely arbitrary sort order in MySQL with PHP
I have a table in MySQL that I’m accessing from PHP. For example, let’s have a table named THINGS: things.ID – int primary key things.name – varchar things.owner_ID – int for joining with another table My select statement to get what I need might look like: SELECT * FROM things W…
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…