php

PHP E_STRICT and __autoload()

I am using __autoload() which simply looks like this: function __autoload($class_name) { require_once($class_name . '.class.php'); } When the error reporting is E_ALL it works fine. The class is loaded, and the script runs without errors. When the error reporting is E_ALL | E_STRICT, no pages work, I simply get: "Fatal error: Clas...

php: pass large arrays of data through pages

I am trying to to solve a problem where I need to pass large arrays of data to another page, this is my scenario: The user input his/her gmail login information inside a form, I then send this information to an ajax page where i authenticate and fetch all the contacts, if the login is invalid they can try again but if it authenticated I...

get ip address in php

i am using following code to get IP address on my loclhost and i get ::1 result code is : function ip() { if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else {...

Database and OOP Practices in PHP

Its difficult to explain this situation but please see the example. I have coded a website where the page loads, I initialize a database class. I sent this class as a function parameter to any functions that needs to access database. I know this is bad approach but currently I have no clue how to do this any other way. Can you please ...

Git and PHP Deployment Tools?

I'm looking for a tool that I can use to deploy my PHP web applications. I want to be able to work locally, then when ready, deploy to the server and create a sym link to the new one, in case it doesn't work I can go back and change the sym link. I know there are some like this that use Subversion, but are there any that use Git? ...

get All textbox, combobox and radio control values in the page using php

Just wondering If there is a quick code/ short cut to get all textbox, combobox and radio button values in the current html page using php. Instead of $_Get and give names for each. I have 4 pages in my application, where a user can go back and forth, I want to retain all values the user inputted in my page, some of the controls are sta...

why cant I pass this variable to the javascript function?

I have a variable inside my php file, which I want to pass to a javascript function whenever the user clicks a link on my php page. here is the php in brief: $delete_img=$image_id.'_'.$newfilename; $display_image.="<td><img src='../temp_images/$newfilename'>"; if ($i==$extra_pic){ $display_image.="<br><a href='#' onclick='window.paren...

Drupal 6 Forms formatting

I am trying to create a form in drupal 6 that has multiple items on the same line. More specificly, I want a right alligned form what has a textfield, dropdown-box, and button all on the same line. I know how to create the items, but drupal tends to put them all on seperate lines. How do I put it on one line? Thanks ...

Disabling serving PHP files from a folder in .htaccess

I have a directory on server, from which I only want .JPG files to be served by apache - and apache should deny requests for php, php3, php5 etc files. What should I write in .htaccess? I have tried following, first two are giving 500 internal error, third one is not working at all! <Directory full-path-to/USERS> <FilesMatch "\.(php...

Tell bots apart from human visitors for stats?

I am looking to roll my own simple web stats script. The only major obstacle on the road, as far as I can see, is telling human visitors apart from bots. I would like to have a solution for that which I don't need to maintain on a regular basis (i.e. I don't want to update text files with bot-related User-agents). Is there any open s...

PHP: Do I need to escape this?

It might be a bit unusual, but I need to echo <?php. However, I think that PHP treats it as an actual <?php and starts executing code instead of treating it as a string. How can I escape <?php and ?> so they can be treated as strings? There was nothing in the manual about this. Thanks, I know this is a bit unusual. ...

Facebook Platform error: "Object cannot be liked"

I'm working on a Facebook Application that generates wall posts. In testing these posts, I've discovered that the Facebook Platform action of "liking" a post is failing. The specific error message is Object cannot be liked Unable to like this object because it is not accessible (it may have been removed or you may no longer...

Inject XML into a node using a string

I am rebuilding a nodes children by saving them out to an array as strings, trashing them in the XML, inserting a new child node into the array as a string... now I want to loop through the array and write them back out to the original node. The problem is I can't find anything on how to add a child node using a string. See below for ...

Add a function to OnLoad in Drupal

Hello, I have a HTML/text default module in the left bar of one of my skins/themes. I have some Javascript in there I'm trying to set today date to my javascript date dropdowns. I am unable to use 'body.onLoad' because Drupal is blocking it somehow? I found a solution saying I can add my javascript function here: if (isJsEnabled()) { ...

Basic URL Rewrite Problem in PHP (mod_rewrite)

In my .htaccess, I have the following RewriteEngine On RewriteRule ^users/?$ users.php RewriteRule ^users/([a-z]+)/?$ users.php?username=$1 Everything works as intended if I do http://example.com/users/ http://example.com/users/joeschmoe/ and PHP will read "joeschmoe" as the value for $_GET['username'] However, if I do ht...

Ignore data within a certain set of characters with PHP

Not sure what this is called, but is there a way I can pull data from a file, echo it, but ignore data within a certain set of characters? <?php echo file_get_contents('test.txt'); ?> Would it be possible to ignore the data in between the asterisks, and the asterisks themselves when I echo out the final function? ...

Check if a database table exists using php/pdo

Hi, I want to check if a table with a specific name exists in a database i've connected to using php and pdo. It has to work on all database backends ... MySQL, SQLite, ... best regards, andre ...

Protecting external resources required by paid iPhone App

Hi, I've developed an application that is currently in the app store weighing in at just over 400MB. The main reason for this is that the app features lots of video which at the moment is baked into the binary. For our next release we'd like to externalise this video, allowing the user to download the videos they'd like to keep on-dema...

Codeigniter: Variables/Config Items within Language Files

I have a language file with a long list of strings for my view files. My question is how to pass a variable or a config item to a language file? <?php $lang['error_activation_key_expired'] = 'The activation key you have attempted using has expired. Please request a new Activation Key <a href="'.$this->config->item('base_url').'member/re...

Examples of PHP In C++

Well I want to learn C++ and at the moment I'm only familiar with PHP and Javascript. And I thought a good way to start learning would be to transfer methods in PHP to C++. So basically I want the code snippets below in C++ The post with the best comments will get a big green tick. Also, if you know of a good beginners tutorial please...