php5

How to create multiple line-breaks in a dynamic image when needed?

Currently I've got the following working just fine without any problems (yet). header ("Content-type: image/png"); $string = $_REQUEST['text']; $font = 15; $width = 300; $height = 350; $image = imagecreate($width, $height); $back = ImageColorAllocate($image, 255, 255, 255); $border = ImageColorAllocate($image, 0, 0, 0); ImageFilledR...

NoSQL best practices

What are the best practices for NoSQL Databases, OODBs or whatever other acronyms may exist for them? For example, I've often seen a field "type" being used for deciding how the DB document (in couchDB/mongoDB terms) should be interpreted by the client, the application. Where applicable, use PHP as a reference language. Read: I'm also ...

Dynamically picking variable from a class

I'm trying to get data from a class in php5, where the data in the class is private and the calling function is requesting a piece of data from the class. I want to be able to gain that specific piece of data from the private variables without using a case statement. I want to do something to the effect of: public function get_data($f...

register_shutdown_function : registered function cannot include files if terminating on failure?

Greetings, I am writing some code inside a framework for PHP 5.3, and I am trying to catch all errors in a way that will allow me to gracefully crash on client side and add some log entry at the same time. To be sure to also catch parse errors, I am using register_shutdown_function to specifically catch parse errors. Here is the functi...

Bug in my preg-match

Hai all i have a big problem right now i have this sample code: preg_match_all("/\[BLOG\=\[(.*)]](.*)\[\/BLOG]/U", $this->soruces , $match_list ); and i don't know why its not will working, its print this out to me Array ( [0] => GROUPID=23|CATID=28|SORT=ASE [1] => GROUPID=23|CATID=29|SORT=ASE [2] => GROUPID=23|CATID=30|SORT=ASE ) ...

What solutions are there to send variables to a text file from php variables?

Essentially I have been trying to think of a PHP-based solution to do the following: The player needs a link ie: "http://yourdomain.com/xspf_player.swf?playlist_url=http://yourdomain.com/yourplaylistlist.xspf"> I could easily put the XSPF information in a PHP file and replace the artist name / song name with variables that retrieve th...

paypal subscription, payment information update

I am trying to design a web application(using php and mysql) in which I will ask my clients to pay via paypal subscription, which detects money from the clients paypal account automatically and transfers it to my paypal account. Now when a client logs into my web application after 3 months of time, is there a way my web application to k...

How do I CURL www.google.com - it keeps redirecting me to .co.uk

I am using CURL to check for the existence of a URL (HEAD request) but when I test it with www.google.com, it redirects me to www.google.co.uk - probably because my server is UK-based. Is there a way you can stop this from happening? I don't want to remove the CURLOPT_FOLLOWLOCATION option as this is useful for 301 redirects etc. Part...

Best way for PHP5 CLI to formulate Base Directory?

Ok say I have a code base that is contained in a folder /myProgram/ and has various folders such as /myProgram/lib/, /myProgram/docs/ and so on... How, in PHP, can I go about detecting any folders before /myProgram/ and creating a base variable so my includes and require's can be written relative to the base directory /myProgram/ allowi...

Setting up a deployment / build / CI cycle for PHP projects

I am a lone developer most of my time, working on a number of big, mainly PHP-based projects. I want to professionalize and automate how changes to the code base are handled, and create a Continuous Integration process that makes the transition to work in a team possible without having to make fundamental changes. What I am doing right...

Matching everything between html <body> tags using PHP

I have a script that returns the following in a variable called $content <body> <p><span class=\"c-sc\">dgdfgdf</span></p> </body> I however need to place everything between the body tag inside an array called matches I do the following to match the stuff between the body tag preg_match('/<body>(.*)<\/body>/',$content,$matches); b...

Difference Between getcwd() and dirname(__FILE__) ? Which should I use?

In PHP what is the difference between getcwd() dirname(__FILE__) They both return the same result when I echo from CLI echo getcwd()."\n"; echo dirname(__FILE__)."\n"; Returns: /home/user/Desktop/testing/ /home/user/Desktop/testing/ Which is the best one to use? Does it matter? What to the more advanced PHP developers prefer? ...

php-cli: What is the best way to detect the hosting OS?

I have a script which I want to run on windows under Cygwin and on Linux. I have to make distinction between the two running environment for some purposes. What is the best way to do it? ...

Getting facebox to work in the qcodo/qcube php framework

I am using a framework called qcodo (which forked as qcubed) and is a PHP framework. I want to do a very simple popup using the Facebox jquery plugin. When someone clicks on the link and shown below in line 47. Here is the file: http://github.com/allyforce/AF-upload/blob/master/Templates/profile_activity.tpl.php <a href="complete_pr...

Determine What Line a Function Was Executed From

I'm trying to build an error class and a lot of error classes I've looked at in the past use FILE and LINE to show where the error occurred, but they use them in the function so they're always the same, which is highly useless information. Aside from sending an array of containing FILE and LINE with every function (which would get to be ...

JQuery UI Nested Tabs

All, I am using JQuery UI Nested tabs. Consider the structure like this: There are 2 Main tabs: Animals, Birds. Under Animals, there are two tabs "Cats", "Dogs". Both the tabs "Cats" and "Dogs" should be loaded via AJAX when clicked.. So, the code for them is something like this: <div id="fragment-1"> <ul> <li><a href="/pub...

JQuery UI Nested Tabs - Load AJAX content into a single DIV

All, I am using JQuery UI Nested tabs. Consider the structure like this: There are 2 Main tabs: Animals, Birds. Under Animals, there are two tabs "Cats", "Dogs". Both the tabs "Cats" and "Dogs" should be loaded via AJAX when clicked.. So, the code for them is something like this: <div id="fragment-1"> <ul> <li><a href="/publ...

¿How to bind params to an statement using a loop?

Hi! I'm just learning to use PDO, and I want to bind params to a delete statement using a loop. I'm using a code like this that definitely doesn't works: public function delete_user ($post, $table='mytable') { $delete = $this->conn->prepare("DELETE FROM $table WHERE id IN (:id) "); ...

Zend MVC - get rid of public folder

All, My PHP Zend MVC Application structure is like this: billingsystem -application -design -public --index.php --.htaccess -library -- Zend whenever the application loads, it goes to index.php in public folder and it gets rerouted from there.. I want to make sure users to access the system by going http://billingsyste...

parsing text for contents of database table of limited size

I have a MySQL table of "people" as part of a web site, for example: | people_id | firstname | lastname | ----------------------------------------- | 1 | John | Lennon | | 2 | Paul | McCartney | | 3 | George | Harrison | | 4 | Ringo | Starr | | . | ....