php

PHP function to encode & etc. characters to corresponding HTML entities

Hi Guys, Does anybody know of a PHP function to encode strings containing special characters like & etc. to strings containing corresponding HTML entities? The purpose is to display string data on a webpage without causing XML parsing errors. ...

Hiding xml from users while passing it into flash

We have a little in-house LMS with courses built in Flash. Scores are updated and retrieved with POSTs to PHP scripts which query a MySQL database. All the course content and quiz questions are in xml files. Those XML files are easily accessible from a user's Temporary Internet Files (sort of SCORM style, for those familiar with it) and ...

How to determine the length (in pixels) of a string being renderred on a web page?

Hi Guys, If I know the font size (12) and the font family (calibri), is there a way to determine the length (in pixels) a given string will take after it will be rendered? I am absolutely certain that the said font would be used. Are there any lookup tables for this purpose to determine the length in PHP code itself? I am writing a PHP...

How to modify code with a New BSD License?

So I found some code (a PHP class) that almost does what I want it to do. At the top is a phpdoc block with info about the original author and the license being New BSD License. I want to respect the original author, so what can/should I do if I want to change some of the original code? Sorry if this is a stupid question. ...

php4 decode string to display as html

I'm very new to PHP and I have a small task of displaying a class list from an XML file. I have managed to figure that part out that took longer than expected. I'm running into some descriptions that have html characters that are not displaying on my page. I have tried numerous ways and nothing seems to work for me. Please take a loo...

PHP syntax question

I found this line of code and I'm trying to comprehend what it's doing. The part I'm not familiar with is the question mark and the colon. What are these characters used for? $string = $array[1] . ($array[0] === 47 ? '' : ' word'); ...

Emulate multiple inheritance in php

I have a system of Models: abstract class R00_Model_iUnique { } abstract class R00_Model_iFamilyUnique extends R00_Model_iUnique { } // for models with hierarchy abstract class R00_Model_iTaggedUnique extends R00_Model_iUnique { } // for models with tags // and, for example class R00_Model_User extends R00_Model_iUnique { } class R00_M...

urls with item title

I was used to putting id's in the URL to map to an item in the database: /hotels/1 but what if I want to get the name of the hotel with an id of 1 and put it in the URL and replace spaces with hyphens? /hotels/hotel-bianca I am using Kohana and there is the concept of routing (which is pretty much present in all MVC frameworks), but ...

A loop until in the stored procedure

I am trying to write a procedure that will fire the same select query till the number of results are more than 0. If the "interval 2 hour " returns 0 records then the "interval 4 hour" criterion should be used and if there are still no records fetched, then lastupdate > current_date() should be used in the where clause. These are the 2...

php4 xml output not displaying html

I'm really not liking my experience with php but I think it is a learning curve. Can someone look at my code and let me know why my html tags don't show for some of my classes? $g_books = array(); $g_elem = null; function startElement( $parser, $name, $attrs ) { global $g_books, $g_elem; if ( $name == 'AFFILIATEXML' ) ...

Grouping associative array keys - in the same order

I have the following 2 arrays and would like to combine them. I'm more interested in the keys than their values. I'd like to take this $arr1 = array( 'tom' => "1", 'sally' => "20" // unique 'larry' => "2", 'kate' => "3", 'dave' => "23" //unique ); $arr2 = array( 'tom' => "11", 'larry' => "12", 'drummer' => "2",...

export query result as CSV through PHP

Say I have stored a query in a variable called $query. I want to create small hyper link called "export as CSV" on the results page. How do i do this? ...

How to use cms systems like drupal and so on for crawl only?

I want to display the data by my own, use cms to crawl the data only. Anyone can share the experience and give me some clue where the entry point is? ...

PHP Object Validation

I'm currently working on an OO PHP application. I have a class called validation which I would like to use to check all of the data submitted is valid, however I obviously need somewhere to define the rules for each property to be checked. At the moment, I'm using arrays during the construction of a new object. eg: $this->name = arra...

php code analysis

$test = 'aaaaaa'; $abc = & $test; unset($test); echo $abc; It outputs 'aaaaaa',which is already unset,can you explain this? ...

PHP Static Variables

$count = 5; function get_count() { static $count = 0; return $count++; } echo $count; ++$count; echo get_count(); echo get_count(); I guessed it outputs 5 0 1 and it's right,but I need a better explanation? ...

mysql muliple queries in one statement

I've looked around on stackoverflow for a similar question, but haven't found exactly what I was looking for, so here goes. In myPHPAdmin you can have mulitple queries in one statement and it executes it for you, eg:' UPDATE `test` WHERE `test2` = 4; UPDATE `test` WHERE `test4` = 8; UPDATE `test` WHERE `test8` = 1; Now if I try to do ...

how to store chechbox value in php

I have checkbox of condition apply where I want to store string value "Condtion Apply". But, I get inserted error so give solution how to store value in database ...

Error with MySQL syntax using REPLACE INTO

I am getting syntax error with the following statement REPLACE INTO users (screenname, token, secret) VALUES( '$screenname', '$token', '$secret' ) WHERE 'screenname' = $screenname The table has a primary key named id, which auto-increments. ...

call time reference issue with php

function get_arr($arr) { unset($arr[0]); } $arr1 = array(1,2); $arr2 = array(1,2); get_arr(&$arr1); get_arr($arr2); echo count($arr1); echo count($arr2); I got : Warning: Call-time pass-by-reference has been deprecated; If you would like to pass it by reference, modify the declaration of get_arr(). If you would like ...