php

How to lookup a url on a page

I'm new to Regular Expressions and things like that. I have only few knowledge and I think my current problem is about them. I have a webpage, that contains text. I want to get links from the webpage that are only in SPANs that have class="img". I go through those steps. grab all the SPANs tagged with the "img" class (this is the har...

Asynch page call from a bookmarklet with CodeIgniter

I'm trying to make a bookmarklet that will take the url of the current page you are on and send it to an application written in PHP with CodeIgniter. The problem I keep running into, however, is that I can do a standard AJAX call because it's cross-domain so it's disallowed and I can't figure out a way to use the JSONP via GET method, s...

autoloader with upper and lowercase classname

I am using this class in php for autoloading. http://pastebin.com/m75f95c3b But when I have somewhere class Bar extends Foo And I have a file called foo.class.php it won't find the class. But when i chagne the filename to Foo.class.php it will find the class. I am trying to add some functionallity to my class to always find the fil...

shopping cart sometimes makes sales for $0...how to troubleshoot?

I am not using a pre-made shopping cart, I programming it myself. It works perfectly fine 99% of the time, but about once every couple months an order goes through for $0. I cannot figure out why. I make a test purchase with the same product and all the same info and I cannot get it to be $0 for me. I am not sure how to go about trouble ...

Matching fixed-format numbers in regex

Quick regex question (since i am horrible at it) I have a field that can only have either: XXXXXXXXXX or XXXXXX-XXXX where X is a real number. Bonus if the regex works well with PHP's regex functions. The Answer: Here's the code from RoBorg's answer, for those interested. if(!preg_match("/^\d{6}-?\d{4}$/", $var)) { // The entry...

Cannot get the "+" sign to display

I have this value in a mysql database: "A+" it's the name of a magazine. I can see it sitting in the database, however i cannot manage to have it display via php. When i fetch the sql data, it outputs "A " I tried utfencode() utfdecode() htmlentities() ... to no avail. I fail to diagnose the problem. In case it matters, i fetch this ...

Simple PHP tool to display arbitrary emails

Does anyone know of an existing tool to render a HTML-display for emails? I have access to the mail-source as text and need some kind of function/class/miniframework/... to get an Outlook-like display as a HTML-page. I looked into Horde and roundcube and I would really like to avoid having to extract the functionality from those big pr...

Calling remote php functions from an iPhone app

Anyone have any suggestions on how to set up both the php and the cocoa side of calling php functions? As a quick idea of what I want to do, I want to be able to to populate two tables with data and add/remove data from the db. So I want to set up a few functions in php that I can call from my iPhone code that will return values from my ...

In PHP 5.x, how can I detect if a class is abstract or not at run time?

I'm looping through an array of class names in PHP, fetched via get_declared_classes(). How can I check each class name to detect whether or not that particular class is an abstract class or not? ...

Fatal error: Class 'MySQLi' not found

I am doing a tutorial and getting this error: Fatal error: Class 'MySQLi' not found (LONG URL) on line 8 the code on line 8 is: $mysqli = new MySQLi($db_server, $db_user, $db_pass, $db_name) or die(mysqli_error()); I saw online someone said to to see if it was turned on in my Phpinfo() but there wasn't anything listed in there under f...

How to display Japanese characters on a php page?

I'm trying to display Japanese characters on a PHP page. No loading from the database, just stored in a language file and echo'ed out. I'm running into a weird scenario. I have the page properly setup with UTF-8 and I test a sample page on my local WAMP server and it works. The moment I tested it out our development and production ...

.htaccess redirect if file doesn't exist

So here's what I'm trying to do. I have a simple framework and I am using mod rewrite to rewrite the urls so that they point to the correct files. I have a process folder which sits inside the web folder (the web folder is where all the actual website files like images, css, etc are). This works great but what I am trying to do now is t...

How to tell if a function is defined in php

How do I determine if a function is defined in php? I'd like to do something like: if(! function_defined(money_format)) // function not defined on windows { function money_format($str) { ... } } Is this possible in php? ...

Which PHP framework should I choose between ZendFramework and YII?

Which PHP framework should I choose between ZendFramework or YII? Points I need to consider: Performance (assuming an accelerator is used) Documentation stability of framework less to code. ...

Fast case counting

I have a large number of strings to process in php. I want to "fix" them to be title case (using ucwords(strtolower($str))) but only if they are all upper or all lower case already. If they are already mixed case, I'd just rather just leave them as they are. What is the fastest way to check for this? It seems like foring through the ...

Is it possible to get all emails from an inbox in GMail?

Is it possible to get all of my emails from your GMail inbox rather than only unread email? My current PHP script only gets unread email but I want the whole inbox. I am making use of PHP and CURL. Firstly, is it possible to do this? If so, can someone give me some hints on how to achieve this? ...

PEAR::DB Error, Extension Not Found

I am attempting to install phpBugTracker on our web server. When I attempt to test the database connection on the installation screen, I get an error screen that reads "DB Test Failure... DB Error: extension not found". The error is being thrown from the following function: function test_database(&$params, $testonly = false) { // ...

How to get the X,Y coordinates of a point in a PDF

I have a PDF template file. It has a bunch of fields I need to write to using PHP. How can I easily determine the xy coordinates of a field in the file? Right now I am using xy locations but trial and error is very time consuming. Is there a better way to do this? Or even an easy way to get the xy coordinates of a point in a pdf file? ...

multi-user application record locking - best method?

I'm developing a php / mysql application that handles multiple simultaneous users. I'm thinking of the best approach to take when it comes to locking / warning against records that are currently being viewed / edited. The scenario to avoid is two users viewing the record, one making a change, then the other doing likewise - with the po...

PHP - Best practices evaluating IF statement

Consider the following if(!count($_POST)) { echo 'something'; } if(empty($_POST)) { echo 'something'; } if(!$_POST) { echo 'something'; } Each line above pretty much do the same thing. I haven't been particular about which one I use. Should I be more particular? Does it really matter? ...