php

file download with php (working on apache under localhost)

Hi all I'm trying to create a file download page. This page when requested should prompt the user to download a file. Here is the source code for the page: <?php header('Content-disposition: attachment; filename=zip.zip') header('Content-type: application/zip'); readfile('zip.zip'); ?> This works ok. The problems starts when I wa...

MVC - Layout containing multiple views

Hi all, I'm trying to learn the MVC design pattern. Suppose I have a site with two layouts: 1) a home page: header1 - nav - content1 - footer 2) a subpage: header2 - nav - content2 - footer My guess would be that I need two View classes for my two different layouts. But within these layouts there are repeating elements (the nav and t...

how do you check if email address is working?

is there any way to check if an email is active without sending it an email? (meaning that it does not get returned) if i have 20,000 emails in my email list, and i do decide to send all of them an email, how can automatically cross out the email address that got returned? ...

Call PHP Function based on URI

Hello all. I am looking to create a simple php script that based on the URI, it will call a certain function. Instead of having a bunch of if statements, I would like to be able to visit: /dev/view/posts/ and it would call a 'posts' function I have created in the PHP script. Any help would be greatly appreciated. Thanks! ...

Php or mysql commands - data from mysql row into text file

How do I get all data from one row from mysql table exported into text files, but formatted this way: one field under another, one per line i would like to break that data into pieces and save for example 50 lines in file1.txt then next 50 in file2.txt and so on until end (it's not round number so last file would have less lines proba...

Get Search Engines to link to sub-pages instead of index

I wrote a blogging system from scratch (http://seanhess.net). I have the last 10 posts displayed on the index page /, and each post has it's own page /post/a_simple_post. I'm getting a good rank in google when I search for specific info from my posts, but google links to the index page instead of the post page. How do I get the search en...

Curl tutorials & resources

Could anyone share good resources/tutorials about php curl? ...

Is Ruby on Rails supported by most hosts?

I'm considering shifting from PHP to Rails. Does an average web host support the Ruby language and everything that Rails needs? Does a normal Rails app using MySQL or does it handle data differently? And is it as "easy" to get an app up and running, as PHP? ...

Best method of passing/return values

Hello one and all, The reason I am asking this question is because I have landed my first real (yes, a paid office job - no more volunteering!) Web Development job about two months ago. I have a couple of associates in computer information systems (web development and programming). But as many of you know, what you learn in college and ...

Where can I find 'best practice' code samples for PHP?

I've been 'hobby programming' in PHP for around a year now in my spare time, starting off with the "PHP and MySQL for Dummies" book and working through "Beginning PHP and MySQL from Novice to Professional". As I'm sure you can imagine, my knowledge is fairly limited and I'm probably already knee-deep in bad habits! I've been working on ...

Why doesn't apache show a 404 error when I send a 404 header with php?

Hello, I have a header('HTTP/1.0 404 Not Found'); somewhere along the code but it doesn't redirect to the Apache's default 404 page for some reason. I have a Rewrite Rule on the .htaccess file that redirects every request to index.php. Could that be the problem? Thanks in advance, Omer. ...

To use prepared statements by PHP for Postgres

This is a similar question to this "When not to use Prepared statements?", but with the "how-to" -part and for PostgreSQL. I know that I need prepared statements because I make more than one call to my database during one script. I would like to get concrete examples about the following sentence Look at typecasting, validating and ...

PHP - folksonomy tag checking regex

I'm trying to create a regex for checking values of submitted tags for a free form folksonomy system. Here is what I have now. if (!preg_match('/([^-\\a-zA-Z0-9._@\'])+/',$proposedtag)) { //true, good return true; } else { //false, bad characters return false; } I want to allow: hyphen, backslash, forward slash, a-z, ...

PHP while loop find last row

$sql = mysql_query("SELECT * FROM comments WHERE user = 1"); $i = 1; while ($row = mysql_fetch_assoc($sql)) { <p>$i. <?php echo $row['comment'] ?></p> <div class="border"></div> $i++; } How could I do to not output <div class="border"></div> under the last comment? ...

php upload image, rename, thumbnail, and save both

Ive been looking at the move_upload_files function, but i dont think thats what i need. I need to upload a picture (max size 2mb png, jpg, gif only) then rename it, then create a thumbnail of it, and save both to the same directory. I figure ill upload/rename the main file first, then take that and create the thumbnail. But what functio...

a website that will compare prices of a yamaha baby grand piano

i would like to design a website that will crawl 100 other websites and post the current prices in ascending order of the same model yamaha baby grand piano. the prices on these sites will appear in simple HTML. the question is will i have to modify my algorithm for every single site, or is there some kind of artificially intelligent too...

mysql multiple queries with php

I am trying to have a search result for someones name exploded then the first name and last name each search against each field 'first' and 'last'. But need to leave room what if someone search for first last midle name like = $who = James David Smith it will exploded it and search each of the names against the first column and the last...

To have AWK's `-F, '{ print $1 }' in PHP

I run unsuccessfully $cookie = "[email protected],777"; $cookie_tripped = trim(",", $_COOKIE['login']); echo "Cookie: "$cookie_tripped[0]; It gives me Cookie: How can you do the following command in PHP? awk -F, '{ print $1 }' ...

How is duplicate HTML represented in your codebase, in a non-duplicate way?

Most HTML in a large website is duplicated across pages (the header, footer, navigation menus, etc.). How do you design your code so that all this duplicate HTML is not actually duplicated in your code? For example, if I want to change my navigation links from a <ul> to a <ol>, I'd like to make that change in just one file. Here's how I...

Zend_Search_Lucene Help

EDIT: I have managed to solve the problem by using: +"lorem ipsum" +type:photo +"lorem ipsum" +type:video Another problem though is that the index is returning correct results but with wrong id (id is a primary key). More specifically, id fields returned are 1 less than real ids (id - 1) in the database which I use to build the index...