php

Problem with PHPs getimagesize function

I am using PHPs GD extension for jpg image manipulation. The problem is that at one point I am using the getimagesize function to get image width and height. It works fine locally as well as one one of my remote servers but not on another of my remote servers. The problem seems to arise when using getimagesize for relatively large images...

Problem with inet_pton() call within Zend framework

Hello everyone, I have a problem with using Zend framework (for YouTube data API). I created very simple PHP script for uploading YT videos using this API and it works almost everywhere - I tried it on 3 different machines (both Linux and WinXP). But after intalling it to 4th machine, I got this error: Error: inet_pton() [function.inet...

What are the major differences between PHP and Ruby?

I need a quick overview to figure out if it's worth switching from PHP to ruby. Please list some differences you know. I'm just talking about PHP and Ruby, not Ruby on Rails (that would be a bad comparison). ...

PHP APC, educate me

I'm currently implementing memcached into my service but what keeps cropping up is the suggestion that I should also implement APC for caching of the actual code. I have looked through the few tutorials there are, and the PHP documentation as well, but my main question is, how do I implement it on a large scale? PHP documentation talks ...

Recommend a Linux or browser-based Venn diagram drawing tool

I'm looking for a tool to draw good-looking Venn diagrams, for use on a Linux-based PHP site, which already employs Flash for graph drawing (Open Flash Chart 2). Free (as in beer or speech) would be nice, but isn't essential. So it should be one of the following (in my rough order of preference): Browser based (Flash) PHP library Lin...

How to solve the case when users surf to index.php

In Zend framework, using the MVC, if A user surf explicitly to http://base/url/index.php instead of just http://base/url, The system thinks the real base url is http://base/url/index.php/ and according to that calculates all the URLs in the system. So, if I have a controller XXX and action YYY The link will be http://base/url/index.php/...

<?PHP, REGEX and me. A tragedy in three acts.

Hi everyone, long time listener. First time caller... Not strictly a PHP question as it involves regular expressions but this one has got me tearing my hair out. I have 3 regular expressions that I want to create, and only one is working correctly. Now I am not sure whether this is due to the fact that: I don't understand preg_match...

How to print list using hierarchical data structure?

When I run this code: foreach ($tree as $node) { echo str_repeat(' ', $node->tree_depth * 4) . $node->id . PHP_EOL; } I get well formatted text like: Food Fruit Red Cherry Strawberry Cool Not cool Yellow Banana Meat Beef Pork But I want to create a list with <ul><li>......

Check if variable has a number php

I want to check if a variable has a number in it, I just want to see if there is one I don't care if it has any thing else in it like so: "abc" - false "!./#()" - false "!./#()abc" - false "123" - true "abc123" - true "!./#()123" - true "abc !./#() 123" -true There are easy ways of doing this if you want to know that is all numbers bu...

Compare lots of texts (clustering) with a matrix

Hello! I have the following PHP function to calculate the relation between to texts: function check($terms_in_article1, $terms_in_article2) { $length1 = count($terms_in_article1); // number of words $length2 = count($terms_in_article2); // number of words $all_terms = array_merge($terms_in_article1, $terms_in_article2); ...

What do these regex Patterns Match?

I am new to regex in PHP and understand the basic patterns however the ones below are a bit complex and I don't understand what the following pattern matches: $ret = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#... "<a href='' rel='nofollow'></a>", $ret); $ret = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[...

Should I use a framework or write my own MVC?

I have a project that is currently all over the place and i'm thinking of making it MVC. The problem is that the system is currently being used and I can not change the interface (It's in frames :s) Also there are certain things that I will need to handle myself such as password generation, login and user levels. I already have the mod...

PHP compare array

Is there anyway to compare arrays in php using an inbuilt function, short of doing some sort of loop? $a1 = array(1,2,3); $a2 = array(1,2,3); if (array_are_same($a1, $a2)) { // code here } Well you get the idea :D ...

Regex Question: Matching this pattern with hard or soft quotes

Hello, I have this achor locating regex working pretty well. $p = '%<a.*\s+name="(.*)"\s*>(?:.*)</a>%im'; It matches <a followed by zero or more of anything followed by a space and name=" It is grabbing the names even if a class or an id precedes the name in the anchor. What I would like to add is the ability to match on name=' wi...

Passing values from jQuery to PHP

Here's the situation: I'm using jquery.validate.js to validate my forms, but I need to add a server-side validation layer. jQuery Validate uses class names within form-elements to determine what it should do -- I want to fetch those class names into PHP so that I can perform the same validations on the server-side. I'm hoping to do ...

Resetting a MySQL Field value without user execution.

I need to reset a MySQL Field value automatically at midnight. It is a specific column in a specific row in a table. I know how to do this in PHP but I do not know how to execute the PHP Script at midnight without someone having to do it themselves. Do you have any viable solutions? Edit:-------------------- Preferably without using Cro...

How Do I Learn to Put it All Together

I've gone through several tutorials in various languages (currently working my through the Agile Web Development with Rails book for an attempt at practical learning) and on their own, these tutorials don't seem to give a good big picture of development. You can learn how to write arrays, define variables and several other concepts but ...

Split SMS gateway answer in PHP

Hi I am wondering what other approaches you would take to do some simple string splitting in PHP. I am receiving a response from a SMS gateway where two of the interesting values are the code used and the users text message. The code could be something like: Freetrip (lowercase, uppercase, mixed case) The user message should in the be...

MySQL Query Logging in CakePHP

Hello, I wanted to know if there is way to log the mysql queries in CakePHP being executed when we use the find method on the models, I know that rails database queries, so does Cake do the same, if so how can I enable it or use it? Shiv ...

reCaptcha values not appearing in $_POST

Hey everyone, I am trying to use reCaptcha on my site, and recaptcha_challenge_field, and recaptcha_response_field are not being added to the $_POST array on the backend - but the rest of the variables from my form are. Any ideas? I have double checked the public/private keys. Here is the generated HTML: <form action='myform.php' na...