Tag Archives: object

Is this correct object oriented programming in php? [closed]

Questions: Could this be classified as correct OOP programming? class Greeting { public $greet = array(‘Hi’,’Hello’, ‘Howzit’, ‘Ola’, ‘Whats up’); function __construct($name) { $this->name = $name; shuffle($this->greet); } } $hi = new Greeting(‘INSERTNAMEHERE’); /*NAME OF PERSON GOES HERE*/ echo $hi->greet[1] .’ ‘. $hi->name; Answers:

How to pass an array of bytes reference to a COM object method

Questions: In PHP, I want to pass an array of bytes reference to a COM object method whose syntax in VB is: object.VBObjectMethod(ByRef aRawData() As Byte) where parameter aRawData is an array of bytes that specifies a data object. In PHP I am initialising the COM class and calling VBObjectMethod as follows: $theObject = new… Read More »

If DateTime Object Is Null

Questions: I am returning some search results after form submit. All is working fine, until I get to a field that is SMALLDATETIME and allows NULL. At least one of the returned rows has the field as NULL. As you can see in the code below, when it is not NULL I am converting it… Read More »

Call to a member function bindParam() on a non-object

Questions: I’m working a log-in script that I found on the web. (http://alias.io/2010/01/store-passwords-safely-with-php-and-mysql/) As I was trying to make it work, I stumbled upon this error: bool(false) Fatal error: Call to a member function bindParam() on a non-object in /srv/disk3/1446018/www/askmephilosophy.co.nf/session.php on line 25 My code: <?php include(‘config.php’); // Establishing the connection: $MyConnection = mysqli_connect(‘hostname’, ‘user’,… Read More »

Set a PHP object global?

Questions: I just started switching my project form the mysql to PDO. In my project a new PDO Object is created more or less right a the beginning of the programm. $dbh_pdo = new PDO(“mysql:host=$db_url;dbname=$db_database_name”, $db_user, $db_password); Now I would like to use this handler (is that the correct name?) in some functions and classes.… Read More »

How to return JSON Object from PHP to read from Android App

Questions: I have the following MySQL table. I need to send the dealer name from android app and send all matching rows to the app.I dont know how to set the php output.I know i should encode using json_encode(array(‘stuff’)); But i dont know how to format the data.Been checking http://www.w3schools.com/json/ It shows an example {“employees”:[… Read More »

call to a member function execute() on a non-object

Questions: My script containing that error is this: $stmt = $this->db->prepare(‘SELECT libelle,activite,adresse,tel,lat,lng FROM etablissements where type IN (‘.$in_list.’)’); $stmt->execute(); $stmt->bind_result($libelle,$activite,$adresse,$tel,$lat,$lng); The php version running on the server (not localhost) is 5.2.17 Answers: