php

How do I best create objects from configuration files?

I have a collection of PHP classes that can be instantiated traditionally using constructors. Now I want to add the ability to instantiate these objects using YAML configuration files. Here's an example of a configuration file describing a web form: title: Contact fields: message: type: text required: true topic...

php convert to byte ,

in java i can cast number to byte for example System.err.println((byte)13020); the result will be -36 how can i do the same in php ? ...

Printing to Dot Matrix printers from Web Apps

Hello, I am not familiar with Dot Matrix printers but I have a customer with a WebApp that generates invoices, print checks, etc.. Currently they are printing directly from the server, meaning that the printer must be connected to the server or that the server needs a way to connect to the remote printer. As you can imagine this generat...

MySQL+PHP: Implementing a good Model

In MVC-Model View Controller design you implement the model to work seperately and contain buisness logic, pulling information down from the database. I struggle so much with the design of implementing a good model. I know what information needs to be pulled down from the database, I just don't know the best way to implement it. I think...

Pass Values Between Two Forms

Hello, Is there any way to pass values between two forms. Let's say, I have two html form. At Form 1, there's one field called name and submit button. At Form 2, there's two field called name and email and submit button. What I want to get is, At form 1, when i fill Form 1 name field and click submit, it will carry me to form 2 and n...

Zend Framework : Detecting wich controller or page you are using / are on

Hi guys! Im trying to detect wich controller Im am using or what controller Im on and then change my menu accordingly to the page Im on. ( Make a selection in the menu so the user can see were he is on the page! ) I really dont know what to write to check what its using... <? if($this->url(array("controller" => "index", "action" => ...

File Upload Deny Animated GIFs (using PHP/Zend Framework)

i am thinking i may want users to be able to upload static GIFs but not animated ones. say for avatar's as they may look ... unprofessional and distracting. is there a way in PHP or Zend Framework that i can validate a file upload that way? ...

accessing json data

hi there, I am using this array( as an example) http://pastebin.com/M0ZJgAVs i am using json_encode() on it and fetching it using javascript does anyone care to tell me to get the num rows would i simply use var numrows = json['numrows']; and to loop over each row would i use for(row in json['rows']) { } and then inside tha...

Count number of times a character appears in a url using PHP

Hello, I want to count the number of times "/" appears in this url Here is my code $url = "http://www.google.com/images/srpr/nav_logo14.png"; $url_arr = eregi(".",$url); echo count($url_arr); It displays on "1" Appreciate all help Thanks Jean ...

Best practices in scheduling PHP scripts

Hi, For a project I need to schedule several PHP scripts. Some of the scripts are a bit complicated (ie. send mail, do database stuff, use several external webservices, use external files and classes etc). The problem is that these scripts also need to be called from the browser, and they do use some of the variables in the $_SERVER arr...

Files organization: Where should exception extended classes be placed ?

Let's say we have several exception classes that extends exception. My question is, in order to proper organize our files, where should those classes be placed ? i.e - Are they helper classes? One on it's on file? Ok. Respecting naming conventions. Ok. But then we group those files and in what folder should we put them? On a folder...

saving and reading a xml file getting from the other url

Hello guys,' may be i am going to ask some stupid question but i don't have any idea about php that's why i want to know it i never worked in php and now i have to do it so please provide me some useful tips, i have XML file that is coming from a different URL and i want to save it on the server then i have to read it and extract it to...

how to use ebay api for particular search results?

I have a php website in which i want to add ebay api such that when a user searches for any car or by text cars he can be able to see cars listed in ebay for sale. and user must not be able to search anything except cars and different brands of cars. Please Tell me how can i achieve this... Thanks in advance........ ...

Any way i can check if a url points to a valid image (using JS/PHP/ZendFramework)?

i am developing a test/learning app. i wonder how can i test if an image from another site/domain ... i broke up my validation logic to the following exists is an image is of valid type is of a specific dimensions is below a max size - say i want the image to load quickly. tho the hosting resource is not mine. ...

insert multiple data in xml with php dom

since i'm new to xml, i tried out the code over here, to insert data into xml, which works. But I would like to insert multiple data into xml. how would i achieve that? for example: <root> <no>1</no> <activity>swimming</activity> <date>29/7/2010</date> <others> <data1>data1</data1> <data2>data2</data2> <data3>data3</data3> s...

Relationship with Tables MySQL

Hello, I have some small issue with relationships with tables as below: I have created a login and registration script which has the following table name: members: fields: member_id, firstname, lastname, login, password Now i have made another table with this table name: phone fields: member_id, phoneid, name, number, prefix, time,...

check if the file exists, if not, create

how do i check using php dom, if an xml file exists, and if not create it. <?php header("Location: index.php"); $xmldoc = new DOMDocument(); $xmldoc->load('sample.xml'); $newAct = $_POST['activity']; $root = $xmldoc->firstChild; $newElement = $xmldoc->createElement('activity'); $root->appendChild($newElemen...

In-depth explanation of Magento's Store / Store View / Website layers?

Could anybody point me towards a good technical explanation of Magento's Store Views/Websites system on a programming level? I am considering a customization of the system, but am not yet sure which one of these levels to use. ...

in my localhost crypt function not working php

Hi in my localhost (WAMP-WINDOWS-VISTA) echo substr($pwd,0,2); --> executing fine echo crypt($pwd,substr($pwd,0,2));--> WHILE EXECUTING System gets hang But this snippet working fine in my live. How to fix this issue... ...

PHP - reformat multidimensional array to insert into MYSQL?

Hello, how can I parse php array like this: $cars= array( "Ford"=>array("C-Max"=>array("length"=>"4333","width"=>"1825","height"=>"1560"),"Escape"=>array("length"=>"4480","width"=>"1845","height"=>"1730") ,"Explorer"=>array("length"=>"4912","width"=>"1872","height"=>"1849"),"Fiesta"=>array("length"=>"3950","width"=>"1973","heigh...