php5

Call from a singleton class to a function which in turn calls that class's method

Hello, I am still looking for a way to phrase it properly (I'm not a native speaker...). So I have this class SQL which implements the singleton pattern (for obvious reasons) and I also have this function, checkUsr(), which queries the database using one of SQL's methods. Everything works fine as long as I don't call checkUsr() from w...

PHP XMLREADER - QUESTION

Hi Guys, I am pretty new to xml parsing and I am using XMLREADER to parse a huge file. Given the following XML (sample): <hotels> <hotel> <name>Bla1</name> </hotel> <hotel> <name>Bla2</name> </hotel> </hotels> And then the XMLREADER in PHP which pulls up the values to my Database: $reader = new XMLReader(); $reader->open(...

How do I choose what and when to cache data with ob_start rather than query the database?

I have a home page that has several independent dynamic parts. The parts consist of a list of recent news from the company, a site statistics panel, and the online status of certain employees. The recent news changes monthly, site statistics change daily, and online statuses change on a per minute bases. I would like to cache these panel...

what does this do

$top += $i ? 12 : 0; ...

alert box empty for php javascript

why does this script show empty alert box. I am trying to use php value in javascript <script type="text/javascript"> alert(<?php echo count($myorder) ?>); </script> thanks ...

reCaptcha integration with php

Hi there, I'm building a contact us page that also uses a reCaptcha, but im having a few issues with it. I fill in all of the fields in the contact form and the correct reCaptcha words, but the form does not submit. I'm assuming this is something to do with the validation, but wondered if someone might be able to spot where i'm going wr...

PHP 5.1.6 ArrayAccess error when iterating over object

Hi, I'm having to develop a site on PHP 5.1.6 and I've just come across a bug in my site which isn't happening on 5.2+. When using foreach() to iterate over an object, I get the following error: "Fatal error: Objects used as arrays in post/pre increment/decrement must return values by reference..." Does anyone know how to get around thi...

imagettftext problem

<?php imagettftext($im,15,0,470,$m,$black,$font,"this is testing of all"); ?> when i run this function i got the image with uneven spaces. like this: this is testin g o fall does anybody know whats the problem is??? ...

PHP custom class and function autocompletion in TextMate project

Is there a bundle which completes my custom classes and functions in a TextMate project? Like the code hints with PHP core functions? ...

PHP not sending emails, no errors in logs

I've got an Ubuntu server set up with PHP 5.2, apache and sendmail. I've got some Drupal sites that should be sending emails but are not. I don't see any errors in the apache logs and there appears to be nothing in /var/log/mail.log. What do I need to do to debug this? ...

CodeIgniter: json_decode array issues

On my client side I'm sending an ajax request with jQuery in the following matter: $.post(script.php, { "var1":"something", "var2":"[1,2,3]" }, function(data) { }, "json"); On the server side, in the CodeIgniter's controller I'm receiving the values like so: $var1 = trim($this->input->post('var1')); $var2 = trim($this->input->post('v...

Basic PHP question for Drupal Views theming

My PHP and programming knowledge is extremely basic, so this is probably a dumb question: I am theming a View in Drupal 6, and I want to add an id with a consecutive number to each item in the view (first item would have the id #item1, the second #item2, etc). I am customizing the style output (views-view-unformatted--MYVIEWNAME.tpl.ph...

PHP-How to choose XML section based on an attribute?

All, I have a config xml file in the following format: <?xml version="1.0"?> <configdata> <development> <siteTitle>You are doing Development</siteTitle> </development> <test extends="development"> <siteTitle>You are doing Testing</siteTitle> </test> <production extends="development"> <siteTit...

Add parameter to PHP

When I sent an image to the code below, uploadImage.php, through a POST method, how do I add a String parameter? <?php $hasError = false; foreach( $_FILES as $i=>$file ) { if ( $file['error'] ) { $hasError = true; } } if ( ! $hasError ) { $myFilePath = '_uploads/'.'_'.$file["name"]; $dta = file_get_contents($...

PHP Extension (memcache|memcached) not showing in phpinfo() but showing in php -m and php -i?

I am getting both modules listed as installed / configured when I use: php -m or if I use: php -i but when I use: $m = new Memcache; // or $m = new Memcache(); // or $m = new Memcached(); //or $m = new Memcached; I get the following error: Fatal error: Class 'Memcached' not found I am running on a Mac - OS X (10.5.7) with de...

General PHP question (improve a simple if/else statement)

<?php echo isset($areas['footer']) ? $areas['footer'] : null; ?> Any way to improve that? ...

PHP framework for old application

Hi experts, we have an old large application that was not built on any framework. However now we want to transfer it to a php framework. Its a new area for us so we are not sure what it takes to transfer the older application to a framework like Zend? Any help will be appreciated. thanks ...

Merge entries in XMLfile (SimpleXML in PHP)

Hello. I have this in my XML file: <product name="iphone"> <variant name="iphone" product_number="12345" price="500" picture="iphone.jpg"> <description><![CDATA[iphone]]></description> <short_description><![CDATA[]]></short_description> <deliverytime><![CDATA[]]></deliverytime> <options> ...

How to hide password in configuration files

Is there a way to hide my password for database access in my config.php configuration file ? What is the best way to do this ? I want to hide to visitors and hosting's admin :) ...

How to redirect every uri calls to one controller, except some static ones?

Hey, I'm using codeigniter and want to make my portal a bit more SEO friendly. I have a controller (articles) which handles every article on my portal. The URL looks like this: example.com/articles/category-sub-category/article-name I'm using mod rewrite module to hide my index.php, and codeigniter routing to hide the controller actio...