I’m trying to get PDO to work with a MySQL ‘between’. Below is my code: What gets returned is an array with ‘0’ or ‘NULL’ for values. When I hard code the end date, it acts as if start_date is set to -1, retuning me all rows before the end_date. So, what am I doing wr…
Tag: php
How can I get the total number of items in a DynamoDB table?
I want to know how many items are in my dynamodb table. From the API guide, one way to do it is using a scan as follows: However, this has to fetch all items and store them in an array in memory which isn’t feasible in most cases I would presume. Is there a way to get the total item
PHP PDO access to MySQL
I went through the process of converting mysql_* code into PDO code. I’ve run it and checked that it works and everything. I just want Stack Overflow’s review of it, to make sure that I’m killing …
PHP Script to Traceroute?
I have a website running PHP on a GoDaddy shared linux server. I need to determine if users are connected to the companies VPN. If I simply do $_SERVER[‘REMOTE_ADDR’] it gives me the clients IP address. However if I can dig deeper with a tracert, the 2nd hop would show up as the companies IP addre…
Switch between PHP versions on OS X Mountain Lion
Is it possible to have multiple versions of PHP installed on OS X Mountain Lion and freely change between them? Similar to the way MAMP allows you to. I’m wanting to get out of using MAMP and this is really the only feature holding me back. Answer Here’s a great blog post about Maintaining two ver…
How can i “merge” these two regular expression in PHP?
I’m learning regular expression, so please go easy with me! Username is considered valid when does not start with _ (underscore) and if contains only word characters (letters, digits and underscore itself): In order to merge them in one regular expression, i’ve tried the following: To be read as: …
php get values from json encode
I have an url passing parameters use json_encode each values like follow: $json = array ( ‘countryId’ => $_GET[‘CountryId’], ‘productId’ => $_GET[‘ProductId’], ‘status’ => $…
Show user’s total comment count outside The Loop in WordPress
How do I display a user’s total comment count outside The Loop? I use this code to display comment count inside the loop: That works fine inside the loop. In an attempt to make that code work outside the loop, I changed $user_id = $post->post_author; to $user_id = get_the_author_meta( ‘ID’…
Flip associative array and store new values in subarrays to prevent losing duplicated values
I have a flat associative array which may contain duplicate values. I need to restructure the data to store the original values as new keys and the original keys pushed into subarrays associated with the new keys. Answer
PHP How to echo without HTML tags
I have a sort of system where everybody can type whatever he wants. Though, they can also seem to use tags like , etc. How …