php

Why does my comment with <BR> cause my code to display in browser weirdly with PHP?

Since when did: //echo "[$sql][$result][$rows][$e]<BR>"; cause an error? The code following this comment gets spwewed out as source in the browser! Bear in mind I use php daily, I've never seen this before! I'm porting an ancient php app from an old Win2k box to a new Windoze 2003 server - apache 2.2, mysql 5.1.32, php 5.2.9, and the ...

PHP-based search frameworks

I'm going to make a small site which requires advanced search capabilities. Since reinventing the wheel isn't such a worthwhile activity, I've done a little googling and found there are some PHP based search frameworks, one of which is integrated into Zend framework. What I would like to have in the framework: Both full-text and catal...

RealPath safe?

<?php if (preg_match('/^[a-z0-9]+$/', $_GET['p'])) { $page = realpath('pages/'.$_GET['p'].'.php'); $tpl = realpath('templates/'.$_GET['p'].'.html'); if ($page && $tpl) { include $page; include $tpl; } else { include('error.php'); } } ?> How safe would you say this is? ...

What is the best way to capture data returned from a function in PHP?

I am new to programming and learning with Wordpress. the_title(); //outputs the title of the page I want to capture the title of the page into a string variable so I can manipulate it with strtolower and str_replace functions. The only way I have gotten it to work is with output buffering. ob_start(); the_title(); $result = ob_get_c...

How to use PHP to get a webpage into a variable

I want to download a page from the web, it's allowed to do when you are using a simple browser like Firefox, but when I use "file_get_contents" the server refuses and replies that it understands the command but don't allow such downloads. So what to do? I think I saw in some scripts (on Perl) a way to make your script like a real browse...

Missing Table with Simpletest in CakePHP

I'm using cakePHP and am using Simpletest as the testing suite. Whenever I run tests on the models, I get an error: Missing Database Table Error: Database table account_types for model AccountType was not found." (For whatever) Does anyone know how to fix this problem? My guess is the fixtures are not being created or something alo...

How to debug PHP with netbeans and Xdebug

I have recently tried to get going with Netbeans 6.5 after it rated so highly in the IDE review by Smashing magazine. http://www.smashingmagazine.com/2009/02/11/the-big-php-ides-test-why-use-oneand-which-to-choose/ My main reason for switching from Notepad++ is that I'd like to be able to debug my code and set through it. I have follow...

$_GET without foo

How can I use download.php?get=file.exe with without the get variable, like download.php?=file.exe, using the $_GET in PHP? ...

how to add Title, keyword and description different on every page of simple php website dynamically

How can I add a different title, keyword and description in every page's <head> of my simple php website dynamically? E.g <title>this is title</title> <meta name="keywords" content="keyword1, keyword2" /> <meta name="description" content="this is description" /> ...

Zend Framework Forms - How to I make a control an array

Using Zend form how would I make a control (element) an array? An example use case: I have a list of items and I want each item to have it's own checkbox on a form, but those checkboxes should post as an array. This means that each checkbox name is 'item[]'. How can I achive this using Zend Form? I have tried setting the isArray proper...

How to synchronise FTP directory from command line?

I have a website with PHP files and other. I would like to do one-click synchronisation between my local copy of a website and my website on the server. It would be nice if there was be a command line utility or plugin to Eclipse PDT to do this. ...

Php on zend, how to escape a variable for a query?

Hello, im doing some queries in Zend Framework and i need to make sure no SQL injection is possible in the next kind of formats. I can use mysql_escape(deprecated) and wont do all the work. If i try to use real_mysql_escape it wont be able to grab the conection with the database and i cant find how zend_filter would solve the problem. ...

Need to title headers in CSV appropriately, instead of using table column headers

I have a function that exports a table into a CSV file, then I open that file using a spreadsheet application. Is there a way to set the header of the CSV to name each column appropriately. For example: I have a table the contains first name, last name, email, and comments. And the table is set as: fname, lname, email, comments So t...

Hints on PHP Problem diagnosis?

I am not an expert in PHP, still learning it. I'd like some hints on how to troubleshoot problems. Recently I installed PHP 5.2.9 on Vista+IIS7 (phpIsapi). I ran a script that did an opendir()/readdir(). This script ran just fine on 5.2.0. On v5.2.9, it failed but I got no indication of the source of the problem. I banged aroun...

What tools can I use to deploy PHP code to an EC2 instance

We can bundle all files into an Amazon Machine Instance and upload it. But I'd like to see if there is a more efficient way to regularly upload source code on to test our app and constantly have the latest version up and running. Thanks! ...

string replace in a file with php

hi, I am writing an email module for my web app that sends a html email to a user on completion of a task such as signing up. Now as the formatting of this email may change I've decided to have a template html page that is the email, with custom tags in it that need to be replaced such as %fullname%. My function has an array in the fo...

Output (echo/print) everything from a PHP Array

Is it possible to echo or print the entire contents of an array without specifying which part of the array? The scenario: I am trying to echo everything from: while($row = mysql_fetch_array($result)){ echo $row['id']; } Without specifying "id" and instead outputting the complete contents of the array. ...

PHP: How to initialize static variables

I have this code: private static $dates = array( 'start' => mktime( 0, 0, 0, 7, 30, 2009), // Start date 'end' => mktime( 0, 0, 0, 8, 2, 2009), // End date 'close' => mktime(23, 59, 59, 7, 20, 2009), // Date when registration closes 'early' => mktime( 0, 0, 0, 3, 19, 2009), // Date when early bird discount ends ...

img src won't work with php variables

<a href="'.$productLink.'" alt="'.$productName.'"> <img src="'.$productImg1URL.'" alt="'.$productName.' '.$productType.' "> </a> Hello the img src is actually in a different directory /images I know this is probably super easy but Ive spent an hour on it and nothing. The page works but doesn't show the directory. Please help the roo...

Best Practises for locating a function definition in PHP

Is there a simple way to find the file path to where a function is defined? I currently use dreamweavers FIND in an entire directory. Would be nice to have something that doesnt require downloading the entire site tho. Any suggestions? ...