php

PHP join help with two tables

Hi. I am just learning php as I go along, and I'm completely lost here. I've never really used join before, and I think I need to here, but I don't know. I'm not expecting anyone to do it for me but if you could just point me in the right direction it would be amazing, I've tried reading up on joins but there are like 20 different met...

How to get the path to the current template in Joomla 1.5?

I'm writing a component and would like to insert images from the template folder. How do you get the correct path to the template folder? ...

How to get SSL+mod_rewrite+Zend Framework MVC working together?

So, I got ZF MVC site and want to force SSL connection on everything under my /checkout/ I tried using mod_rewrite for that, so my .htaccess would look like this: RewriteEngine on RewriteRule (\/checkout.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R] RewriteRule !\.(js|ico|gif|jpg|png|css|swf|xml|avi|flv|mov|mp3|wav)$ index.php [L] Sure...

Should I put forum threads into my sitemap?

I have a website about to launch with a forum facility. Should I put each thread into my sitemap.xml file, or will Google just find the links to each thread via the forum itself? Don't worry: it doesn't require registration to read the forum. If yes, how best to keep it up to date? Doing it by hand is obviously not an option for that am...

PHP Regular Expression Question

Hi! I have a situation in which I parse a body of text and replace certain phrases with links. I then need to re-parse the string to replace a second set of phrases with links. The problem arises at this point, where certain words or phrases in the second set can be substrings of phrases already replaced in the first pass. Example: The...

Join Table On Self using Doctrine (DQL)

I'm attempting to join a table on itself using doctrine's DQL. The scenario is: I have a table of product attribute values at is linked to a products table via a reference table. The product attribute values are to serve as filters on the products, therefore, the products attribute values table needs to be joined back onto itself to ...

Saving a Base64 string to disk as a binary using PHP

As a "look under the covers" tutorial for myself I am building a PHP script to gather emails from a POP3 mailbox. While attempting to make use of binary attachments I am stuck trying to figure out what to do with the attachment information. Given a string that would be gathered from an email: ------=_Part_16735_17392833.12296539921...

PHP conditionals, brackets needed?

I was just browsing a forum and someone asked about a php file they had found on the web. It has several spots like this in the code: if ($REMOTE_ADDR == "") $ip = "no ip"; else $ip = getHostByAddr($REMOTE_ADDR); I have always thought brackets are needed to enclose what you want to do if the condition is true. Is there some other alt...

Better way to check variable for null or empty string?

Since PHP is a dynamic language what's the best way of checking to see if a provided field is empty? I want to ensure that: null is considered an empty string a white space only string is considered empty that "0" is not considered empty This is what I've got so far: $question = trim($_POST['question']); if ("" === "$question") ...

Need insight: Transitioning from CodeIgniter to Cake PHP Framework

I picked CodeIgniter as the first PHP MVC framework to learn. I've used it for a few projects and feel quite comfortable with it. I now have the opportunity to work on a project that uses Cake. My question is, how long do you think it will take to transition to this framework if I have a good grasp on CodeIgnitor? I don't want to be ov...

How do I make php nicer to the CPU?

I'm running on a shared *NIX server (run by Site5). I have a php script that runs in the background occasionally doing some offline calculations. It uses around 100% CPU while it runs. I've tried nice-ing it, like this: nice -n 19 php script.php but that doesn't seem to make any difference. Can anyone help? Thanks, Ben ...

(PHP) Object of class SoapClient could not be converted to string

This code works fine: $result = $client->__call("optionalInfo", array( new SoapParam("...", "client"), new SoapParam("...", "add_code")) ); When I try abstracting it a bit to make the script re-usable, I get this error: Catchable fatal error: Object of class SoapClient could not be converted to string The broken code is: ...

Is there a difference between $str == '' and strlen($str) == 0 in PHP?

As the title says: Is there a difference between $str == '' and strlen($str) == 0 in PHP? Is there any real speed difference and is one better to use than the other? ...

How do I fix Firefox trying to "Save image as" .htm?

Hi! We've recently implemented Amazon S3 in our site which led us to change the way we handled images. We used to call a controller /fotos.php that would read the file from disk, record some statistics, set headers and return the contents of the file as image/jpeg. All went OK until S3. Fotos.php now does a 302 redirect to the resource...

How do I make C# talk to PHP session

I have a C# web-app that I wants to integrate an PHP shopping cart, it is possible? Thanks ...

Do you prefer functioning or including within one php file?

Hi, How do you manage your php codes? Do you prefer functioning within one php file or including larger blocks of "raw code"? Edit: In fact, my code is pretty nasty, as I don't use any namespaces and classes - only functions and including. I shall look the classes up ^^. ...

Tutorials For Database-Driven Routing in Zend Framework?

I am working on a project that needs to use a database driven MVC scheme where the route to the controllers and views are controlled through a single database table. However, I haven't been able to find any tutorials that demonstrate this with a current version of the framework (they all appear to have been written several versions ago) ...

How important are constraints like NOT NULL and FOREIGN KEY if I'll always control my database input with PHP?

I am trying to create a column in a table that's a foreign key, but in MySQL that's more difficult than it should be. It would require me to go back and make certain changes to an already-in-use table. So I wonder, how necessary is it for MySQL to be sure that a certain value is appropriate? Couldn't I just do that with a language li...

How do you stop a PHP class from executing?

I'm looking for something like break for loops. Here's some example code (using Symfony's lime) where stop() would not let the class continue and I_DONT_WANT_THIS_TO_RUN() would not be executed. $browser->isStatusCode(200) ->isRequestParameter('module', 'home') ->isRequestParameter('action', 'index') ->click('Register') ->stop(...

Populating Selects from the Database using Zend_Form

What is the best way to populate a select element that is part of Zend_Form? I've used populate() to fill in various form element values but the select statements do not get populated. My solution, which works but I suspect is not ideal, is as follows: In the init() method of MyForm (which extends Zend_Form) I make a database call and...