I have a bit of PHP code which I need to return an even number of results from a MySQL database. I’m using the mysqli extension to execute my query. My code is approximately this at the moment: //…
Category: Questions
Convert a String to Variable
I’ve got a multidimensional associative array which includes an elements like I’ve got a strings like: How can I convert the strings into a variable to access the proper array element? This method will need to work across any array at any of the dimensions. Answer Quick and dirty: Of course the input string would need to be be sanitized
Serving large files with PHP
So I am trying to serve large files via a PHP script, they are not in a web accessible directory, so this is the best way I can figure to provide access to them. The only way I could think of off the …
Cyrillic characters in PHP’s json_encode
I’m trying to encode Cyrillic UTF-8 array to JSON string using php’s function json_encode. The sample code looks like this: ‘първи’, ‘две’ => ‘втори’…
Send and receive SMSs to a PHP script?
Can a PHP script (which can be working with a MySQL DB) send and/or receive SMSs using some sort of server-side solution? Any special server-side application, or special hardware required? And …
$_POST vs. $_SERVER[‘REQUEST_METHOD’] == ‘POST’
Some guy called one of my Snipplr submissions “crap” because I used if ($_SERVER[‘REQUEST_METHOD’] == ‘POST’) instead of if ($_POST) Checking the request method seems more correct to me because that’s what I really want to do. Is there some operational difference between the two or is this just a code clarity issue? Answer Well, they don’t do the same
HTTP Headers for File Downloads
I’ve written a PHP script that handles file downloads, determining which file is being requested and setting the proper HTTP headers to trigger the browser to actually download the file (rather than displaying it in the browser). I now have a problem where some users have reported certain files being identified incorrectly (so regardless of extension, the browser will consider
How to make PDF file downloadable in HTML link?
I am giving link of a pdf file on my web page for download, like below The problem is when user clicks on this link then If the user have installed Adobe Acrobat, then it opens the file in the same browser window in Adobe Reader. If the Adobe Acrobat is not installed then it pop-up to the user for
Detecting request type in PHP (GET, POST, PUT or DELETE)
How can I detect which request type was used (GET, POST, PUT or DELETE) in PHP? Answer By using Example For more details please see the documentation for the $_SERVER variable.
PHP: Cookie domain / subdomain control
I’m working on a site with multiple subdomains, some of which should get their own session. I think I’ve got it worked out, but have noticed something about cookie handling that I don’t understand. I don’t see anything in the docs that explains it, so thought I would see if anyone here has some light to shed on the question.