php

Why won't this PHP validate?

<?php $username = "@#*(#(*#($&*#$"; if (preg_match("/^[0-9a-z-A-Z-_@ !]*/", $username)) { echo "true"; } else { echo "false"; } ?> ...

Creating a new wordpress post from twitter tweets

Hi guys, I'd like to build an application that, on interval, it checks for tweets containing a particular hashtag, and creates an individual Wordpress post for each tweet that it finds. What is the best way to do this? Are there existing plugins/tools available, or should I write my own custom plugin? I've had a look at the plugins av...

Where are my $_FILES? Ajax Uploading

I've built a form to upload images, and processed with Prototype/PHP. $('image_upload').observe('submit', function() { var params = $H(); params.set('name', $('image_title').value); params.set('from', $('from_who').value); params.set('upload_file', $('upload_file').value); new Ajax.Request('/files/upload_proce...

How to use include within a function ?

I have a large function that I wish to load only when it is needed. So I assume using include is the way to go. But I need several support functions as well -only used in go_do_it(). If they are in the included file I get a redeclare error. See example A If I place the support functions in an include_once it works fine, see Example B. ...

Is there a better way of designing zend_forms rather than using decorators?

Hi, I am currently using zend_decorators to add styles to my form. I was wondering if there is an alternative way of doing it? It is a bit difficult to write decorators. I would love the casual one using divs and css style : <input type="submit" class="colorfulButton" > It is much simpler rather than set a decorator for a certain con...

Trying to create tiny urls, getting redirect loop.

I'm trying to create tiny urls like this: site.com/abc123 goes to: site.com/index.php?token=abc123 but I keep getting redirect loops no matter what I try, or it tries to redirect to index.php?token=index.php.. Current .htaccess is: Options +FollowSymLinks Options -MultiViews RewriteEngine On RewriteRule ^([^/]*)$ /index.php...

REMOTE_ADDR and IPv6 in PHP

Is it safe to assume that $_SERVER['REMOTE_ADDR'] always returns a IPv4 address? Thanks! ...

Top 10 collection completion - a monster in-query formula in MySQL?

I've got the following tables: User Basic Data (unique) [userid] [name] [etc] User Collection (one to one) [userid] [game] User Recorded Plays (many to many) [userid] [game] [scenario] [etc] Game Basic Data (unique) [game] [total_scenarios] I would like to output a table that shows the collection play completion percentage fo...

wordpress post by email and also cats and tags

hi, i'm trying to add categories and tags to my posts. how can i achive that if i am posting by email? thanks guys. ...

How to design Models the correct way: Object-oriented or "Package"-oriented?

I know that in OOP you want every object (from a class) to be a "thing", eg. user, validator etc. I know the basics about MVC, how they different parts interact with each other. However, i wonder if the models in MVC should be designed according to the traditional OOP design, that is to say, should every model be a database/table/row (...

server|configuration problem, a php script just die with no error log & no reason

Hi (first of all, thanks for your attention & sorry for my bad english hahaha also this is not a programming error, or thats what I think, I think this is an error in some configuration of the server or something else but I dont know what) I have a php script (is running like a process of linux, its not running on the web browser) that ...

algorithm optimization: returning object and sub-objects from single SQL statement in PHP

I have an object oriented PHP application. I have a simple hierarchy stored in an SQL table (Chapters and Authors that can be assigned to a chapter). I wrote the following method to fetch the chapters and the authors in a single query and then loop through the result, figuring out which rows belong to the same chapter and creating bot...

Pay per view video solution

Hello, We are planning on building a pay per view (PPV) video solution but we have no idea from where to start. Here are the current givens: it will be hosted on Linux using PHP Database: MySQL And by PPV I mean: - going to website, selecting a movie to watch/download - going to payment portal and paying - being now able to watc...

Remove integers in array less than X with PHP

Hello. I have an array with integers of values from 0 to 100. I wish to remove integers that are less than number X and keep the ones that are equal or greater than number X. I am using PHP. Thanks! ...

How do I redirect a page in php

I'm having difficulties in the making the logout code for php to work. When I click on the logout button, it will go back to the home page, but when I click on the back button in the browser. I can still access the previous page, wherein the user must be logged on to access it. So I'm thinking of redirecting to the login page when the u...

Creating PDF's using PHP

What I am wanting to do is create a PDF ideally from HTML code. I found a class called dompdf but I'm having issues with font and page breaks. Does anyone know of another script or even a better way in general to generate PDF files? The reason why I am converting HTML to PDF is because I want someone to use a WYSIWYG editor to create t...

Joomla syntax for mysql last inserted id?

What is the joomla syntax for mysql last inserted id? ...

Reading a File into a Byte Array (PHP)

I have one file. but now need to read this file into a bytes array. In java or c++ it's very easy to do that. but not found how i can read in PHP. ...

Is there any inbuilt function to insert values in db used in Joomla framework?

Is there any inbuilt function to insert values in db used in Joomla framework? I am looking for the insert query in adminitrator folder for #__menu table and other tables, but i can only find the update select and delete queries on searching in Dreamweaver, So please tell me is there any inbuilt function that Joomla uses for insert quer...

iterate only through existing objects properties, not them from parent class?

i have a class that extends another. when i iterate the current object i get all properties, even those from the superclass. i only want to iterate through the current object. how could i do that? foreach($this as $key => $value) { echo $key . ': ' . $value; } ...