MongoDB’s PHP library allows me to connect to a collection like this (from example): $m = new Mongo(); $db = $m->comedy; $collection = $db->cartoons; But how do I specify the database and/or …
Tag: php
How to set DSN (Delivery Status Notification) for PHPMailer?
I’m trying to find out how to set DSN when using PHPMailer. I know at the SMTP Protocol level, the DSN is specified after RCPT TO, e.g. RCPT TO: NOTIFY=SUCCESS,FAILURE ORCPT=rfc822;recipientemail@gmail.com Also, I will like to direct the DSN to other than the sender address if that is possible. Apprecia…
org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
I m trying to do a registration page from an android activity connectiong the datas to my sqldatabase, I m getting this error ” org.json.JSONException: Value First of all, could anyone advise me on …
Abstract constants in PHP – Force a child class to define a constant
I noticed that you can’t have abstract constants in PHP. Is there a way I can force a child class to define a constant (which I need to use in one of the abstract class internal methods) ? Answer A constant is a constant; there is no abstract or private constants in PHP as far as I know, but you
Convert MySQL login script to PDO
I’ve written a functional login script using MySQL. However, I’ve now been told that it needs to be done using PDO, and I’ve a functional PDO connection: function getConnection() { $userName = ‘**…
What is a PHP code generator?
I’m thinking of using a php cms, a php framework or php code generator. A php cms is restricted somehow and with a php framework and a php code generator I have more freedom. But what exactly is the difference between a framework and a code generator or what do a framework share with a code generator? I…
UTF-8 safe equivalent of ord or charCodeAt() in PHP
I need to be able to use ord() to get the same value as javascript’s charCodeAt() function. The problem is that ord() doesn’t support UTF8. How can I get Ą to translate to 260 in PHP? I’ve tried some uniord functions out there, but they all report 256 instead of 260. Thanks a lot for any hel…
Storing application permissions in a database
I’m developing an application for our company that eventually will have lots of ways of restricting users to particular sections/modules. While the application is still small, I’d like to move to a new method of storing permissions that, as the application grows, will remain easy to maintain and q…
special characters turn into question marks php html
I read all the topics found on stackoverflow and other forums, it’s hosted on hostgator and I’ve never had problems with their servers before although quotes for example are transformed into question …
php: the best way to check if string ends with an element from array?
What’s the best way to check if $str1 ends with some string from $arr1? The answer true/false is great, although knowing the number of $arr1 element as an answer (if true) would be great. Example: Is there any better/faster/special way than just comparing in for-statement all elements of $arr1 with the …