php

Is it acceptable and better to exclude the closing PHP tag at the end of a file?

Duplicate: What are the arguments IN FAVOR of PHP closing tags for PHP only files? I have seen a lot of PHP scripts lately without the closing PHP tag ?> I'm wondering if this is now the recommended method or if it's just people being lazy? ...

Should a PHP application perform error handling on incorrect database values?

Imagine this... I have a field in the database titled 'current_round'. This may only be in the range of 0,1,2,3. Through the application logic, it is impossible to get a number above 3 or less than 0 into the database. Should there be error checking in place to see if the value is malformed (i.e. not in the range 0-3)? Or is this just ...

How do I read in a php array, in Objective-C?

In php I have: $result = mysql_query($query); // if successful query, return the records if ($result) { // if not empty result, return array of records if (mysql_num_rows($result)) { $records = array(); while ($row = mysql_fetch_assoc($result)) { $records[] = $row; } return $records; } } In Objective-C - After th...

How can I make a fax implementation from PHP?

I am using PHP. I need to send a fax of a particular file from my website. This needs to work for any number in the world. My searches so far have recommended using SOAP. Is it not possible to send a fax like an email? Is it not possible to send a fax without a paid service? I have seen the below link, and it refers to the soapclien...

Combine PHP prepared statments with LIKE

Anyone know how to combine PHP prepared statements with LIKE? i.e. "SELECT * FROM table WHERE name LIKE %?%"; ...

the contents of iframe doesn't print in google chrome

i have a page which calls some contents in an iframe and when i try to print the contents of the iframe it prints blank in google chrome , but its working fine in mozilla and explorer how can i make it work in google chrome also? ...

Javascript Problems

I am using Javascript to store values in a stack, the problem is that the stack value remains active until the page is refreshed. When the page is refreshed the value in the stack value gets set to 'Undefined'. Is it better to implement a place to permanently store the stack values? Then even if the page is refreshed the old stack value...

Sending messages from php to java

My app is a feed aggregator. The frontend is programmed in php, but I have a Java program running periodically to update the feeds database. Under the current scheme if a user adds a feed to be aggregated he must have to wait until the aggregator runs and updates the database to see the news from the feed he subscribed. What I want to do...

google Maps getDistance without loading the page

Google maps has a function that lets you retreive the distance between two points: getDistance(), of the GDirections class. Now, this is Javascript, so it'll only be able to calculate once the page has loaded. My search form however, has the ability to indicate what's the maximum distance you want between yourself and another person an...

Array manipulation in PHP

I am using PHP. I need to implement the following logic: My $List has the following data: array('id' =>'1','flag'=>'1','place1' =>'val2' ,'place2'=>'val3') array('id'=> '1','flag'=>'0','place1' =>'val3' ,'place2'=>'val7') array('id'=> '1','flag'=>'0','place1' =>'val4' ,'place2'=>'val8') array('id'=> '1','flag'=>'0','place1' =>'val5' ,'...

player opening more than one time?

This is my site. When i will select songs for playing player.php file will open and it will play the songs selected. Everything working fine,but the problem is when o will go back and select another songs it is opening one more player window. please help me. I want only one player window has to be opened even i select other songs also...

PHP Multibyte String Functions

Today I ran into a problem with the php function strpos(), because it returned FALSE even if the correct result was obviously 0. This was because one parameter was encoded in UTF-8, but the other (origin is a HTTP GET parameter) obviously not. Now I have noticed that using the mb_strpos function solved my problem. My question is now: I...

Arrange elements into columns with Smarty

I have a php page that produces an array of elements. For the sake of simplicity let's say that it contains the numbers 1-5 in numerical order. These numbers need to be equally (or as close to equal as possible) split into two columns (using a html table) like so: 1 4 2 5 3 The number of columns might change in the future. Since t...

How to sum an attribute in a sphinx group search?

I need sphinx to sort the results by the sum of an attribute. I need to: Group the results by their IDs (done) Sort the results by the SUM of one attribute I can't find a way to sum this attribute. How could I do this? (Im using sphinx PHP API) ...

HL7 parsing in PHP

Hi all, I'm looking into options for parsing HL7 messages via PHP. I'm aware of the Net_HL7 package on PEAR but to be perfectly honest, I don't think that I want to base my code around a seemingly 'abandoned' package and even if I did, I just don't think that my brain suits the functions 'correctly'. Maybe if I had more of an HL7 backgr...

Should I use eval() or call_user_func()?

I'm working on a php project, and I want to run code that's fetched from a MySQL database. There's no chance of unsafe code being injected, so the only thing I'm worried about is performace. Should I use eval() so I can directly run the code, or parse it so that call_user_func() runs it instead? For example, if the code I fetched was "m...

Need MySQL INSERT - SELECT query for tables with millions of records

I am trying to take one step towards optimizing a 90GB+ table: Old Table Every day the table grabs approx. 750,000 records from an external source and adds them to the table with the new date. This has been going on for three years from what I understand. 97% of the records don't change from one day to the next. New Table I am tryi...

Is there a speed difference between <?php echo $var; ?> and <?=$var?>?

Is there any speed difference between these two versions? <?php echo $var; ?> <?=$var?> Which do you recommend, and why? ...

Zend_Db is ignoring my default field values!

Hi, I'm using Zend Framework 1.7 with a MySQL 5.0 database for a project I'm doing. Part of the system is a longish form that asks a user for various dates (in dd/mm/yyyy format) as well as some integer fields. In my MySQL table, all these fields have a default of null. When I come to save the form data with a function in my model (whic...

What's the deal with a leading underscore in PHP class methods?

While looking over various PHP libraries I've noticed that a lot of people choose to prefix some class methods with a single underscore, such as public function _foo() ...instead of... public function foo() I realize that ultimately this comes down to personal preference, but I was wondering if anyone had some insight into where th...