php

Can column aliases be evaluated in the WHERE clause?

First off, I'm not an expert with MySQL queries, and I can't seem to find a solution to my problem. Example: SELECT SUM(IF(table1.col1<4,1,0)) AS score WHERE score>0 GROUP BY table1.col2 The above would give an error as the column score does not exist in table1. This is my workaround: SELECT SUM(IF(table1.col1<4,1,0)) AS score GROU...

Is Image Magick 6.2.4 always backwardly compatible with legacy versions?

To use the PHP extension for ImageMagick, I need to upgrade my server to ImageMagick version 6.2.4. However I have some legacy code that uses version 6.0.7 I saw a slashdot comment from 2006 about ImageMagick being notoriously bad for backwards compatibility but I have no personal experience of this. Looking throught the archives it ...

PHP Replace Colour in truecolorimage

Hi all, I need to find a colour within an image and replace it - if it is present. All I can find is information about replacing within an indexed image. Is there an easy way to do it with a true color image? Is it more efficient to convert a true color image to an indexed one and then replace the colour? Thanks, Mark ...

partial string comparision in php

i have stored two ip address values in two strings a = '116.95.123.111' b = '116.95.122.112' i just want to compare the first two parts of ip address i.e 116.95 part in the two strings and as it is same in both the strings my comparison should return true. how to do this partial string comparison in PHP? ...

PHP file_get_contents causes page to be inaccessible

Hi, I'm trying to use file_get_contents in php to display an RSS feed. However, when I try to load the page, it fails (as if waiting for something to complete). If I remove the code and save the file again, the page still refuses to work for 5 minutes or so, after which, it goes back to normal. Can anyone help shed any light on what is ...

Handling office open xml (xlsx) documents with PHP

Hi all, I need to create sort of a php based Excel (xslx) handling component. I figured that there are several open source projects around which are into this. Does anyone has particular experiences / advice on this for me? I.e. which one to go with, which one is to be avoided? I tend to go with PHP-Excel. thx in advance for your thou...

PHP: Convert user input in minutes to some use-able value for a calculation

Overall goal: User enters some number in minutes and I change those numbers from minutes to some usable form in a calculation. How do I convert the user input in the form of minutes to some number or value that I can use later on in this php script? <?php $minutes = $_REQUEST["minutes"]; // We initialize the total to $1.99 for the con...

How to attach and show image in mail using php?

I want to attach an image and then show it in an email. The image I want to attach is on my server. I use html in the email. How do I do this with php? (And I don't want to use any library like PEAR). ...

What's the best way to query for position changes?

I have a table of results I'd like to display: | change | position | name | score | |----------------------------------| | - | 1 | Bob | 10 | | +1 | 2 | Tom | 8 | | -1 | 3 | Sam | 7 | |----------------------------------| The change column reflects the position movement of the person, so ...

Font picker Implementation

Hi, I want to implement a font and color picker in my project. I implemented the color picker, I got it the code, but still I don't get the code to implement the font picker. Does any one know? Thanks in advance. ...

problem with preg_replace and str_replace

Hello again. $string = preg_replace("#\[name=([a-zA-Z0-9 .-]+)*]#",'<td><a href="' . "$front_page/" . str_replace(' ', '-', "$1") . '">'."$1</a></td>",$string); This part of script doesn't work: str_replace(' ', '-', "$1") I need to replace " " with "-", i also try preg_replace inside main preg_replace, str_ireplace also But this...

How can i configure my mail server in open atrium?

Hi, i have just succesfully installed open atrium, but i can't find the configuration of the mailserver... i currently cant send any mails because there is no SMTP Server defined, an without mails being send, no new users can be registered, because they recieve their pasword via mail... i hope that somebody can help me :) ...

how to modify this code to include logging of ip address to another file

please look at the simple php webpage code below how can modify my code so that a log file is created on my server which logs each visitor's ip and whether it was successfully redirected to the correct page . something like that. <?php $a = $_SERVER['REMOTE_ADDR']; if ( $a == "117.96.112.122" ) { header("Location: ad_sams_...

Caching table results for better performance... how?

First of all, the website I run is hosted and I don't have access to be able to install anything interesting like memcached. I have several web pages displaying HTML tables. The data for these HTML tables are generated using expensive and complex MySQL queries. I've optimized the queries as far as I can, and put indexes in place to impr...

PHP > Form a multi-dimensional array from a nested set model flat array.

Hello, I have been stuck on this problem for the past four days and its really starting to seriously affect my mental health! Ha. Okay, basically, I have formed a mySQL query which returns a data set all sorted perfectly of my data structure. If I was to declare it, it would look something like this: $arr = array( array( 'name' =...

PHP as a Desktop Programming Language

I'm not much of a programmer, PHP is where I'm comfortable. And sometimes I find that I need to do things, such as arrange files or rename files on a mass scale on my computer. And I think I could do this with PHP but I can't of course. So I was curious, is there a way I could run PHP files as kind of exe files. I'll probably get fla...

Passing variable argument list to sprintf()

I would like to write a function that (amongst other things) accepts a variable number of arguments and then passes them to sprintf(). For example: <?php function some_func($var) { // ... $s = sprintf($var, ...arguments that were passed...); // ... } some_func("blah %d blah", $number); ?> How do I do this in PHP? ...

php CURLOPT_INFILE gives error The FastCGI process exited unexpectedly

for sending data with curl PUT request , I am using below code $tenMB = 10 * 1024 * 1024; $fh = fopen("php://temp/maxmemory:{$tenMB}",'rw'); fwrite($fh, $this->putFields); rewind($fh); curl_setopt($this->_handle, CURLOPT_INFILE, $fh); // this line throws error I am getting below error on IIS 7 HTTP Error 500.0 - Internal ...

problem scheduling cron job at hostmonster

hello, I am trying to setup cron jobs for a website hosted at hostmonster.com. At the time of configuring timestamp when I use * * * * * the script runs perfectly. but whenever I made changes to these timstamps the script doesnot work say if I use 30 18 * * * script doesnot execute. This automated script insert data in the data...

Suppressing output from exec() calls in PHP

I have a number of command line scripts in PHP that use exec() to perform tasks such as restarting services, loading MySQL timezone files, etc. While exec() itself does not output anything to the screen, some of the commands I am running are forcing output that I can't seem to suppress (even with ob_start()/ob_end_clean()). For example...