php

How to display file names from a folder

I'm using this script to display all the images in a folder, but I can't figure out how to get each image's file name to display underneath it. Any suggestions? <?php $dirname = "images"; $images = scandir($dirname); $ignore = Array(".", "..", "otherfiletoignore"); foreach($images as $curimg){ if (!in_array($curimg, $ignore)) { ...

Changing timezone in PHP

Alright, quick question. A server is running in Eastern Time. PHP program needs to make date calculations using Central time. At the moment, I am putting this line at the very top of my script: putenv("TZ=US/Central"); Is that the best way to go about that or is there some PHP trick I'm not aware of? Cheers. ...

php link to image file outside default web directory

Here is the directory structure /domain.com /public_html /functions /image /mobile /www the /domain.com/public_html/www folder has a file index.php the default web directory is /user/public_html/www in the index file is an include that includes the functions with include"../functions/function.inc" this works without problem whe...

PHP Automatically "GET" Variables

I am desiging a new website for my company and I am trying to implement switch navigation which is what I have used on all my sites in the past. <?php switch($x) { default: include("inc/main.php"); break; case "products": include("inc/products.php"); break; } ?> For some reason when I go to index.php?x=products nothing happens, it ...

How evil is $_REQUEST and what are some acceptable Band-Aid countermeasures?

I've come across a couple of popular PHP-related answers recently that suggested using the superglobal $_REQUEST, which I think of as code smell, because it reminds me of register_globals. Can you provide a good explanation/evidence of why $_REQUEST is bad practice? I'll throw out a couple of examples I've dug up, and would love more in...

htaccess request forwarding if internal ip

Is there a possible htaccess directive that can transparently forward request from index.php to index_internal.php if the request is coming from an internal ip range? ...

php unexpected curly brace

Hello, What is wrong with this code? <?php $link = mysql_connect('localhost', 'root', 'geheim'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_select_db("ebay"); $query = "SELECT * FROM Auctions"; $result = mysql_query($query) or die(mysql_error()); $records = array(); whil...

Which is faster for PHP5 to deal with/easier to work with in PHP; XML or JSON, and file_get_contents or cURL?

Is there any reason why I should pick JSON over XML, or vice-versa if both are available? Tips for optimizing performance when dealing with data feeds are also appreciated! ...

jqGrid with JSON data renders table as empty

I'm trying to create a jqgrid, but the table is empty. The table renders, but the data doesn't show. The data I'm getting back from the php call is: { "page":"1", "total":1, "records":"10", "rows":[ {"id":"2:1","cell":["1","image","Chief Scout","Highest Award test","0"]}, {"id":"2:2","cell":["2","image","Link Badge","When you are inve...

How to Use Same Models in Different Modules in Zend Framework?

I am working on implementing Zend Framework within an existing project that has a public marketing area, a private members area, an administration site, and a marketing campaign management site. Currently these are poorly organized with the controller scripts for the marketing area and the members area all being under the root of the sit...

PHP array_intersect() - how does it handle different types?

If I've got an array of values that are basically zerofilled string representations of various numbers and another array of integers, will array_intersect() still match elements of different types? For example, would this work: $arrayOne = array('0003', '0004', '0005'); $arrayTwo = array(4, 5, 6); $intersect = array_intersect($arrayOn...

Method to Serialize Objects from appserver to web server without code duplication.

I have a web-app-database 3 tier server setup. Web requests data from app, and app gets its data from the db then processes and returns it to web for display. Standard. Currently all the data I serialize from app to web gets put into custom defined data structs that the web side then parses for display. In other words, say I have an or...

How to attach HTML file to email using content taken from DB in PHP?

Hi, How do I send mail via PHP with attachment of HTML file? -> Content of HTML file (code) is in string in DB. Is there some easy way or free script to do this? I don't want to store the file localy, I need to read it out of DB and send it straightaway as attachment (not included in body). ...

Turn OFF self-closing tags in SimpleXML for PHP?

I'm building an XML document with PHP's SimpleXML extension, and I'm adding a token to the file: $doc->addChild('myToken'); This generates (what I know as) a self-closing or single tag: <myToken/> However, the aging web-service I'm communicating with is tripping all over self-closing tags, so I need to have a separate opening and c...

PHP Convert HTML Formatted Date

Published Date returned from Twitter Search API Atom Feed as 2008-11-03T21:30:06Z which needs to be converted to "X seconds/minutes/hours/days ago" for showing how long ago twitter messages were posted. Think this can be done with php date() function using DATE_ATOM value? ...

How to use MySQL functions in Propel

I want to select records that are 1 month old or newer. The query is: SELECT * FROM foobar WHERE created_at > DATE_SUB(curdate(), INTERVAL 1 MONTH) Using Propel in Symfony, I do: $c = new Criteria $c->add(FoobarPeer::CREATED_AT, "DATE_SUB(curdate(), INTERVAL 1 MONTH)", Criteria::GREATER_THAN); What Propel generates is: SELECT...

MySQL Hashing Function Implementation

I know that php has md5(), sha1(), and the hash() functions, but I want to create a hash using the MySQL PASSWORD() function. So far, the only way I can think of is to just query the server, but I want a function (preferably in php or Perl) that will do the same thing without querying MySQL at all. For example: MySQL hash -> 464bb2cb3...

ordering a list of files in a folder using php

I am using the code below to display all the files from a directory in a drop down menu. Does anyone know how to make this alphabetical? I presume it has something to do with the sort function, I just can't figure out how! <?php $dirname = "images/"; $images = scandir($dirname); $dh = opendir($dirname); while ($file = readdir($dh)) { i...

In CodeIgniter, how can I have PHP error messages emailed to me?

I'd like to receive error logs via email. For example, if a Warning-level error message should occur, I'd like to get an email about it. How can I get that working in CI ? Thanks, Ian ...

PHP CSS Selector Library?

Is there a PHP class/library that would allow me to query an XHTML document with CSS selectors? I need to scrape some pages for data that is very easily accessible if I could somehow use CSS selectors (jQuery has spoiled me!). Any ideas? ...