php

MySQL SELECT with LEFT JOIN and GROUP problem

I have a main table foo with dates and values, and a table bar with exception dates and values. If the date exists in the bar table, that value applies, otherwise the default foo value. So, for example: foo id date value 1 2009-11-19 25 2 2009-11-20 50 bar id date value 1 2009-11-19 50 To select the right va...

PHP APC multiple upload does not work

Hi! I tried to use PHP APC to upload files on wamp, windows2003. But when 2 or more uploads are working at the same time, only one upload is working. It seams that I'm not the only one experiencing this error: http://pecl.php.net/bugs/bug.php?id=13719 Can anyone tell how can I fix this problem? Thanks in advance! ...

Displaying the values stored in a session(using php) into a field

Here's the situation, I created 6 pages,each of which has some text fields.I stored the values entered in these text fields in php sessions.now after the user fills up these text fields,he will be going to a confirmation page,where he will be verifying the details and then the values are submitted. Now in this confirmation page is ther...

SFTP from PHP - undefined constant CURLOPT_PROTOCOLS and CURLPROTO_SFTP?

From my php script, i need to be able to upload a csv file to a remote server via sftp. I followed the accepted answer from this question: http://stackoverflow.com/questions/717854/sftp-from-within-php Here's what my code looks like <?php error_reporting(E_ALL); ini_set('display_errors', 1); $ch = curl_init(); $localf...

Cakephp Save with a table where the primary key is not 'id'

I have an existing web application that I am converting to use CakePHP. The problem is that the primary keys for most of the tables are in this format "${table_name}_id" (story_id) instead of the CakePHP way of 'id' When ever I try to update some of the fields for a row in the story table, the Save() function will return false. Is there...

PHP readdir with european characters

I get images files which have Czech characters in the filename (eg, ěščřžýáíé) and I want to rename them without the accents so that they are more compatible for the web. I thought I could use a simple str_replace function but it doesn't seem to work the same with the file array as it does with a string literal. I read the files with re...

Is this the right way to make my website google-friendly ?

I have created several Q about correctly mapping a website with a database so that google can index it properly. However, need more info. My website is a classifieds website (PHP). Users can search ads on my site. Searching for 'BMW' will bring up only the titles of all 'bmw' ads and display them as a search result. (like google kindof)...

multiple database relationship on field other than primary key in CakePHP

I have a project that necessarily spans several databases. One database has tables: CREATE TABLE device { device_uid integer unsigned not null primary key auto_increment, os varchar(50), name varchar(50) } CREATE TABLE platform { platform_id integer unsigned not null primary key auto_increment, name varchar(50) } The oth...

Recursive php function that turns nested array into nested html blocks

Hi guys, I'm looking to write a recursive php function that would call a function to generate nested HTML blocks ( not necessarily only DIVs ). So for example, for the following array: $a = array( 'b' => 'b value', 'c' => 'c value', 'd' => array( 'd1' => array( 'd12' = 'd12 value' ), 'd2' => 'd2 value' ), 'e' => 'e valu...

How to SFTP upload files from PHP

I'm having trouble using PHP to SFTP upload files to a remote server. When I use cURL, I'm getting the error described here: http://stackoverflow.com/questions/1766822/sftp-from-php-undefined-constant-curloptprotocols-and-curlprotosftp I also tried phpseclib as suggested in: http://stackoverflow.com/questions/717854/sftp-from-within-...

How to Initialize Server only Once in PHP

I am porting an application from Java Servlet to PHP. What's the equivalent of Servlet.init() in PHP? Basically, the page uses a table that needs to be calculated. It's quite expensive operations. I am using a LAMP. I wonder if there is a way to initialize the table just once at Apache startup? ...

How to manage a pageview DB

I am interested in tracking my users' pageviews on my site. Being that traffic is expanding very quickly, I am worried about robots, etc, and I also want to be able to use tracked data live to alter the user experience (so, while I do use Google analytics, it does not serve this purpose). What is the most efficient way to store my infor...

any special php function to make a string 'url' friendly for address-bar ?

Is there any such function? If not, anybody got one? I need to make a strings submitted by users 'url friendly' because I will later on use it as an url to a post on my site. Thanks BTW, its PHP! ...

What is the equivalent to Master Views from ASP.NET in PHP?

I'm used to working in ASP.NET / ASP.NET MVC and now for class I have to make a PHP website. What is the equivalent to Master Views from ASP.NET in the PHP world? Ideally I would like to be able to define a page layout with something like: Master.php <html> <head> <title>My WebSite</title> <?php headcontent?> ...

Wordpress Navigation

I am working on a Wordpress Theme, I need to work on the navigation, I am having a little trouble creating it. The navigation I am looking for looks like this: www.neu.edu/humanities. I have gotten this far: if (is_front_page()) { wp_list_pages('title_li=&exclude=12&depth=1'); } else { // display the subpages of the current page ...

Concerning AJAX, PHP, and processing forms

I want to use AJAX to process a simple login form. I thought it'd be pretty easy, but I just can't get it all to work. index.php <html> <head> <title>AJAX Login</title> <script type="text/javscript"> var XMLHttpRequestObject = false; if(window.XMLHttpRequest) { XMLHttpRequestObject = new XMLHttpRequest(); } else if (window...

How to write a single dimension array to a file in php a.k.a. file_put_contents vs fopen+fwrite

Data: $data = array('Alice', 'Bob', 'Carol', 'David', 'Elizabeth', 'Frank'); Method A: file_put_contents('filename.ext', implode("\n", $data) ); Method 2: $fp = fopen('filename.ext', 'w'); foreach($data as $name) { fwrite($fp, $name . "\n"); } fclose($fp); Does one method have any significant penalties over the other? A...

PHP Accurate Font Width

Hi, I am trying to generate a text image. So I create a new font: $font = '../fonts/Arial.ttf'; Then I add some background for the text imagefilledrectangle($image, 0, 0, ?, 12, $green); And add text imagettftext($image, 12, 0, 0, 12, $white, $font, $text); The problem is right now I don't know how to get the width o...

Reading return values from PHP with Mootools

I have been trying to retrieve data via AJAX. I can't seem to be able to 'read' what was sent to me by PHP. Here's the code $('create_course').addEvent('submit', function(e){ e.stop(); flash.setStyle('display', 'none'); this.set('send', { onComplete: function(resp){ if ($chk(resp)) { console.log($type(resp...

MySQL Blob not showing up correctly.

Hi I asked a similar question earlier about retrieving an image from a MySQL database Blob. I am using code as: header("Content-type: image/jpeg"); // change it to the right extension print $image; //where image is the blob file This code is nested inside of a webpage, so should I still modify the header? When I include the header...