php

Using Array "Keys" In a MySQL WHERE Clause

I have a data set that is generated by a Zip Code range search: $zips: key -> value 11967 -> 0.5 11951 -> 1.3 The key is the Zip Code (Which I need to query the Database for), and the value is the miles from the user entered zip code. I need to take the key (Zip Code) and search the database, preferably using a MySQL query similar to...

Last.fm API - Track Duration

I'm using the Last.fm API and I stuck on something seemingly fairly simple. One of the responses is the duration. Which is returned as: 222000 But how do I format (in PHP) this to look like MIN:SEC 3:42 ...

To check `0 rows` from the SQL query in Postgres / PHP

How can you check an empty database result and then make an action based this? My code which puts matching result to the if -clause while( $tags_and_Qid = pg_fetch_array( $result_tags )) { // Add the Tag to an array of tags for that question $end_array [ $tags_and_Qid['question_id'] ] ['tag'] [] = $tags_and_Qid['tag']; ...

Calculating a row position in the table

Let's say I have a table like this (this is just a simplified example, the real table I'm talking about is much more complex): CREATE TABLE media ( id INT NOT NULL AUTO_INCREMENT, title VARCHAR(255) NOT NULL, description TEXT NOT NULL, voted INT NOT NULL DEFAULT 0, rating FLOAT NOT NULL DEFAULT 0 ) ENGINE = INNODB; The voted column re...

What PHP class to use for accessing NNTP

I'd like to access NNTP servers, groups, and messages through PHP. Is there any existing class you'd recommend? Preferably PHP5 and good OOP. ...

Converting escaped html back into HTML string in flash

Using swfobject I'm passing a xml string containg html which i escape using php htmlentites. How would one go about converting it back to a valid xml string in flash as2? flashvars.xmlString = "<?xml version='1.0' encoding='UTF-8'?><names><name> Thanks ...

Is PHP exec safe?

I am trying to get exec working on a Windows server and receiving the error message "unable to fork". After googling the issue a bit, it seems the recommended fix is to give the IUSR account READ and EXECUTE permissions to c:\Windows\System32\cmd.exe. But that has got be a major security hole right? Is it safe? Is there another way to e...

How can I replace multiple foreach loops with a 'for' loop or a recursive function?

Hello: I am stuck with a bunch of foreach loops and would like to know if there is a way to hone them down to a simple 'for' loop or a recursive function? I'm trying to generate HTML with the elements nested inside each other. I guess what I'm trying to get at is an arrays of arrays. But I don't know how to move forward with what I've c...

Invalidating cached content, If-Modified Headers?

I'm having a peculiar problem: PHP SCRIPT: // checks If-Modified-Since header (if nothing has changed) // Sends HTTP/1.0 304 Not Modified // Sends Cache-control: public, must-revalidate // exits // if NO If-Modified-Since or something has changed // builds content // Sends Last-Modified: [DATE TIME] // Sends Cache-control: public, mus...

Using Doctrine with Domain Driven Design

I'm thinking of implementing a Domain Driven Design approach (similar to the one described here), but want to integrate it with the Doctrine ORM. Has anyone had any success doing anything like this? My initial instinct was to use Doctrine as the DAO layer, but it seems a a bit convoluted for Doctrine to map my database fields, and my en...

Zend_PDF text formatting

Hi, I use Zend Framework for my project. And my question is how can I convert html text like "helloworld" into PDF text to be the same using Zend_PDF ? Thx. ...

Directly fetching a list from a column's data with MySQL

Hello, Let us suppose I have to deal with lots of grandmothers that have lots of cats. I have a table granny_cat : granny_id | kitty_name -------------------- 1 Kizzy 1 Jimmy 1 Katty 2 Georges 2 Albert 3 Panther and I want to retrieve a list of granny 1 cat's, i.e. to get so...

Model handel the calls to the server using Remote Object Components.

I have a flex MVC app, only the view is using MXML. In that application, the user enters the username and password in the view. Now, i send the username and password from view to controller using code click="admin.verifyLogin(this, Username.text,Password.text)" in the controller i have a model object teacher , setting the values for...

Have GD get image from binary string

Hey everyone, Right now, I have a database that stores images in a MySQL BLOB field. I setup a script that selects and displays the images based on an ID in the URL, and I also made it so if you append ?resize=800x600, it would resize the image (in this case, to 800x600). For some dumb reason, the host that I use doesn't have Imagemagi...

Resizing images

Hello, I'm working on a forum application in PHP. In signature field I have "<img src='randomimage.png'><br>bla blah" If an image is bigger than the field it stretches my tables and looks bad. Is there any way to re size the image if its too big? Sorry for my poor English and thank you for reading Edit: The thing is that it's not on...

Extended PHP Class not accepting variables.

Hi, I am extending FPDF and want to include some external variables but it's not working. What am I doing wrong? <?php class PDF extends FPDF { public var $DocNum; public var $cliente; public var $noCliente; public var $noTienda; public var $noPedido; function Header() { $this->Image('fpdf/cabMCR.jpg...

Possible to open an e-mail created in php in Outlook?

I am trying to create a file that is essentially an e-mail with headers and all in php and then present it to the user. The User would open it in outlook and then send. ...

How do you write a Drupal module to access a .net web service

I'm a .net developer who needs to write a drupal module in php to access a .net web service. The php will have to do some local storage, I assume in the drupal data store. Can anyone recommend some good pointers on how to go about getting into drupal development? or suggest some good links on how to tackle the problem above? Thanks mu...

php: preg replace a single question mark?

How do I replace a single question mark with preg replace. ...

What changes do I need to make Magento work with PHP 5.3?

I need to upgrade my server to PHP 5.3 but have a Magento install and I know that Magento doesn't play nicely with PHP 5.3. I think that the changes won't be too extensive (from what I've read). But, I figured I would open it up to the SO crowd. Has anyone done this successfully? If so, did you take good notes? ...