I’m using a PHP script to generate an excel CSV file from a result-set query. All works fine but when I read my excel file, I can not display leading zeros. This is my code: If I make a var_dump() of $finalData[] I see the correct value, for example ‘000198’, ‘000199’, ‘000…
PHP cURL vs file_get_contents
How do these two pieces of code differ when accessing a REST API? and They both produce the same result, judging by Answer file_get_contents() is a simple screwdriver. Great for simple GET requests where the header, HTTP request method, timeout, cookiejar, redirects, and other important things do not matter. …
php script to find web server name
Is there any php script to find the name of the web server like apache, varnish, nginx, etc. I know about netcraft and wappalyzer, but I want to have a script to run in my local machine The main …
MySQL: Group by two columns and sum
Building an inventory system. I have lots of products and each product has three different variables. So for stock totals I want to group by the two columns (product & size) and sum quantity to …
PHP checkdate variants
I found a php function checkdate() , but strangely enough it only seems to accept data in format of int $month , int $day , int $year. However I am passing the date as a string (example “2012-06-13”) …
Get most recent date from an array of dates in “Y-m-d H:i:s” format
I have the array of dates in Y-m-d H:i:s format like: I would like to know the most recent date. In other words, today is June 13th 2012, which datetime is closest to today’s date? From my sample array, I am expecting 2012-06-11 08:30:49. How can I do that? Answer Do a loop, convert the values to date, …
Create an XML file in server using SimpleXML and jQuery Ajax
What I want to do surely can be accomplished but I’m doing something wrong: I want to create an XML file when I use an Ajax call. I got the following code (synthesized). Maybe this example doesn’t work, it’s just to exemplify: HTML PHP in server In this example the PHP code works as is, the …
curl get remote file and force download at same time
I’m trying to get a remote file and force download it to user at the same time. I can’t paste the code ,the code is too long . but the curl function works ,but the problem is it doesn’t out put anything till it gets the remote file first then it force downloads it to user. I use this to
Operation not permitted – unlink on local machine
Im trying to unlink a folder on the local version of my site. I get the error: Any ideas how I can get unlink to work on my local machine? Im using MAMP. Answer See the documentation: unlink — Deletes a file and See Also: rmdir() – Removes directory You have a directory. You need to use rmdir, not unlin…
tempnam() not working on client server
I did a script, which has to load a file from a ftp-server then parses it. The code relies on tempname to store the temporarily store the ftp-file. On my developement server (with php 5.3.10), this works flawlessly, however on the client machine (with php 5.2.17) it does not and gives me: Can someone give me …