I have this PHP code: $end=date(‘Y-m-d’); I use it to get the current date, and I need the date 5 years in the future, something like: $end=date(‘(Y + 5)-m-d’); How can I do this?
How to check if the request is an AJAX request with PHP
I would like to check server-side if a request to my php page is an ajax request or not. I saw two ways to do this: First way: sending a GET parameter in the request which tells the page that this is an AJAX request (=mypage.php?ajax) mypage.php: Second way: set a header to the xmlHttpRequest: client-side js:…
Difference with microseconds precision between two DateTime in PHP
I can get a datetime with microseconds in PHP with a workaround as: list($usec, $sec) = explode(” “, microtime()); echo date(“Y-m-dTH:i:s”, $sec) . “.” . floatval($usec)*pow(10,6); I need the …
file_get_contents seems to add extra returns to the data
Hi I am trying to run a simple php file open, replace, and save. Here is my code: My file opens, does the replace, and saves the file. But when I opened the file I noticed that there was an extra line return after every item that previously had only one line return. I tested printing out the data directly
shell_exec() returning null on “ls”
So I have this code and I’m only trying to make a list of the saves in another directory where the php scrip is in xampp folder and the saves are to this path /root/files/saves: <body&…
PHP Fatal error: Call to undefined function json_decode()
Apache is logging PHP Fatal error: Call to undefined function json_decode(). After some googling, it seems this problem is a result of not having the latest version of php. Oddly, running php –…
How do I get the query builder to output its raw SQL query as a string?
Given the following code: I want to get the raw SQL query string that the database query builder above will generate. In this example, it would be SELECT * FROM users. How do I do this? Answer To output to the screen the last queries ran you can use this: I believe the most recent queries will be at the
json with no index after unset encode array in php
I hope anyone can help me. My JSON isn’t indexed (i.e. there isn’t any key above any element) but after running unset() to remove an element with PHP the output JSON appears like this: How you can see there is a key before the element of JSON. I know that this behavior is caused by unset (PHP json…
Jquery removing commas
I’m using the following and it works, but the alerted value opt3 contains commas. How do I remove them? If I select a c & d the alert shows a,c,d but I want it to show acd. Answer What about this? Update: Ok. Like @jreziga mentioned. The return value of .val() will be an array. If you have a string
How can I use API to get quickbooks data without browser based OAUTH?
This is in relation to the online version of Quickbooks, QBO (not the desktop). We need our serverside code to be able to log-in and query some data from quickbooks (just like your API provides) and supply this information to our billing system. This would not involved a browser and use something like curl bu…