php

Using application.ini for configuring Zend_Application Bootstrap

I have written custom resources for my Zend_Application bootstrap. In the manual the following code is given for loading them: $application = new Zend_Application(APPLICATION_ENV, array( 'pluginPaths' => array( 'My_Resource' => APPLICATION_PATH . '/resources/', ), 'resources' => array( 'FrontController' => a...

PHP Sessions Security: Storing sessions in DB vs. Changing sessions save path?

Hello, I am trying to create a more secure PHP sessions login script. Unfortunately for this project I will be working with shared hosting. Would using PHP's session_save_path() function to change the path to something other than /tmp be a secure solution? Or do I need to save the sessions in the database? Thanks! ...

how do you fix the clients outgoing port number using php?

Hi there, I'm using php (the sockets extension) to handle sending and receiving xml files. I'd like to be able to fix the outgoing clients port number as the server has a set amount of incoming connections. I find that each time the php script is run it creates a new port number. The client side script I have so far is this:- send_me...

Is it valid to re-declare or override an instance variable through inheritance?

I have an abstract ParentClass with an protected $instanceVariable. Now there's a ChildClass which has also an private $instanceVariable. It sets that to an initial value, like: private $instanceVariable = 5; So the child class overrides it and changes the visibility to private. The parent class does not assign a value to that instanc...

Postgres/PHP - What is the standard way to retrieve the ID of an inserted row?

I have searched on Google and read a couple of articles on how different people approach this problem, but I was wondering what the standard way of solving it is and also, which one will work best for my situation. I have an AJAX page that creates a new question and I need to know how to retrieve the ID from the insert query within the ...

mysql - referential integrity across multiple databases?

Hi, I have two databases in a php / mysql application. One for user data and the other for content. I have recently had to make use of inno db tables in order to enforce some referential integrity. Obviously, the user tables will be required to participate in these relationships. Is there a way to keep the data separated whilst sti...

PHP can't find a function in my class

I have a class that is getting called and for some reason one of the functions I have is being found, but the other one is not. Here is my code: <?php namespace LMVC\Database; class PDO { private static $instance = NULL; public static function setup($dsn, $username, $password) { try { self::$instance = new \PDO($dsn, $us...

Should I use a timestamp or text field in MySQl for UTC time/date

I read a mysql timestamp can only hold a value from 19700101000000 to sometime in the year 2037. I seriously doubt my app will be around then, well i'm sure it wont but any idea what will people use then for a timestamp, a text field? Below is an example of how I currently insert a mysql record with a datetime mysql field and you can ...

How to remove an element from a PHP array if the key equals 'index'?

I have this $array in which the index key could appear in any random order: array(4) { ["foo"]=> bool(false) ["index"]=> bool(false) ["bar"]=> bool(true) ["biff"]=> bool(false) } Without adjusting the position of the elements or changing the key or value, how do I remove the index element, resulting in a new $array? array(3) ...

Tokyo Cabinet cluster and PHP (via memcache)

I have 2 servers running tokyo cabinet in a cluster (2 hard drives so 4 instances of Tokyo Cabinet). if it's just one instance of tokyo cabinet it's fairly straight forward to use php memcache protocol to communicate. My question is how do you connect php if it's cluster? Option 1: $memcache->connect('memcache_host', 11211); Using thi...

mysql integer problem

i am using following code to add data into mysql database <?php $debdes = $_POST['debdes']; $debamt = $_POST['debamt']; $crdes = $_POST['crdes']; $cramt = $_POST['cramt']; $date = $_POST['date']; $cberror = "<h1>Data not Added</h1><br/><br/><h3>Please Follow The Instructions</h3>"; include_once ("db.php"); if (empty ($date)...

How to get DOMDocument to be nice to ASCII control characters?

The HTML document which I am parsing contains some ASCII control codes. I noticed that PHP's DOMDocument parser truncates text nodes when it finds ASCII control characters within the node, such as Device Control 0x13 End of Medium 0x19 File Separator 0x1C Group Separator 0x1D Is this a bug or a feature? Is there any...

How to Create a word .doc file from a .doc template in php

Hi, I need to create a word document from a word template, its something like, we need to replace the few strings (say variables) in the template with the values. Please tell how we can do this in PHP ( or cakePHP). Thanks ...

How can I get the instance that created another object's instance in php?

Hi guys, I need to track which instance created another instance. It's an instancing hierarchy not a parent-child class hierarchy. Here's an example: class Car{ private var $engine; private var $id; public function __construct(){ $this->id = nextId(); $this->engine = new Engine(500); } } class Engine{ ...

Is there a good base for me to work from for php user registration + subscription in MVC format?

Basically, I'm about to write a php script in the Zend Framework that's ONLY purpose is to handle user registration and offer AUTOMATIC MONTHLY subscriptions so that I can add other php driven scrips that they'll have access to based on their subscription status. Does something already do this? I'm looking for barebones, not something l...

PHP passing a class name becomes a string when passed to a function

Here's what I want to do: public function all($model) { $query = 'SELECT ' . implode(', ', $model::$fields) ....; } Called like this: $thing->all(Account); I get this error: Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in /home/mark/public_html/*/account.php on line 15 When inspecting $model with var_dump it tu...

PHP SOAP cannot connect to an SSL WSDL source

Trying to make Soap connection to a https:// WSDL source via PHP/Win32, but keep getting the error: Warning: SoapClient::SoapClient() [soapclient.soapclient]: I/O warning : failed to load external entity "https://... If I try to save the WSDL locally and access it then, the SoapFault->faultstring property has the message "SSL support i...

How to add date with PHP/MySQL?

I want to automatically add date in order_date field when a customer checkouts my online shop. What is the best way to do it? There are other fields like, delivery data and payment date in the same table. Is it good idea to add a hidden field so that when a cutomer submit, the date will be added? But I am not sure how to do it. Can ...

Redis - which PHP module to use?

If i check redis php supported language (http://code.google.com/p/redis/wiki/SupportedLanguages), there's 4 PHP ones: Redis PHP Bindings,phpredis,Predis,Redisent. Question is, which is the best and good to use? Thanks! ...

Is it worth learning PHP classes?

I have been learning and using PHP for several months now and I am at the stage where I can build almost anything, given the right plans and enough info. What I'm asking is although I can do just about anything, is it worth learning how to use classes for PHP and using them in place of 'normal' (can't think of the word) code? From what...