Hi,
I have inherited a number of grossly coded PHP files, whose output I need to alter programmatically.
To achieve this, I chose to run them through another PHP file, rewriter.php, which looks approximately like this:
<?php
if(!preg_match('/^([a-zA-Z0-9\-_]*)$/', $_GET['page']))
die('Incorrect page supplied.');
ob_start('changeOutp...
I'm mostly convinced of the benefits of unit testing, and I would like to start applying the concept to a large existing codebase written in PHP. Less than 10% of this code is object-oriented.
I've looked at several unit testing frameworks (PHPUnit, SimpleTest, and phpt). However, I haven't found examples for any of these that test pr...
$sql = "select menu_id , menu_name , parent_id from menu " ;
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
$res = $dbc->query($sql);
while($row = $res->fetchRow()){
$menu[$row['parent_id']][$row['menu_id']] = $row['menu_name'];
}
function make_menu($parent)
{
global $menu ;
echo '<ul>';
foreach($parent as $menu_id=>$menu_name)...
using Fast CGI I can't get it to read the php.ini file. See my phpinfo below.
System Windows NT WIN-PAFTBLXQWYW 6.0 build 6001
Build Date Mar 5 2009 19:43:24
Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--enable-debug-pack" "--with-snapshot-template=d:\php-sdk\snap_5_2\vc6\x86\template" "--with-php-build=d:\...
Can someone give me an example of how I would delete a row in mysql with Zend framework when I have two conditions?
i.e: (trying to do this)
"DELETE FROM messages WHERE message_id = 1 AND user_id = 2"
My code (that is failing miserably looks like this)
// is this our message?
$condition = array(
'message_id = ' =>...
I am trying to read a image file (.jpeg to be exact), and 'echo' it back to the page output, but have is display an image...
my index.php has an image link like this:
<img src='test.php?image=1234.jpeg' />
and my php script does basically this:
1) read 1234.jpeg
2) echo file contents...
3) I have a feeling I need to return the outpu...
I'm using TinyMCE (WYSIWYG) as the default editor in one of my projects and sometimes it automatically adds <p> </p> , <p> </p> or divs.
I have been searching but I couldn't really find a good way of cleaning any empty tags with regex.
The code I've tried to used is,
$pattern = "/<[^\/>]*>([\s]?)*<\/[^>]*>/";
$str = preg_replace(...
I have two test computers networked together.
One has a gigabit ethernet, the other a 10 megabit.
Theoretically, data trasferred between the two should reach about 1megabytes p/s.
Now im using a PHP script to read data from one host to another using fread. Both reading file and file to be read are chmod 777.
Both computers are runnin...
Hello!
I've built a news site:
- The articles are shown on the front page ordered by date. The newest one first.
- The news are in the table "news" with the fields "id", "title", "text" and some other ones.
- All articles are tagged with 1-5 relevant tags.
- The tags are in the table "tags" with the fields "id", "tag", "article" and...
The router
$router->addRoute('catalogue', new Zend_Controller_Router_Route_Regex('(?:(uk|en)/)?catalogue/(.+)',
array(
'language' => 'uk',
'module' => 'default',
'controller' => 'index',
'action' => 'catalogue'
),
array(1 => 'language', 2 => 'param'),
'%scatalogue/%s'
));
When ...
Here's the code I'm trying to make work:
<?php
class database {
var $connection;
function database($host,$username,$password,$database){
$this->connection = mysql_connect($host, $username, $password);
mysql_select_db($database,$this->connection);
}
function query($query){
$query = mysql_query($query,$this...
i have a cookie named MVCID that's set and its value is some generated hash.
when i write this
setcookie("MVCID","", time()-60*60*24);
and load the page, not only is the contents of the cookie not being erased but it also isn't dying.
what can be the possible problem? this isnt the first time this is happening.
ps: im also trying th...
I work at a small php shop and I recently proposed that we move away from using our nas as a shared code base and start using subversion for source control.
I've figured out how to make sure our dev server gets updated with every commit to our development branch... and I know how to merge into trunk and have that update our staging se...
I'm working on a few report output scripts that need to do some rudimentary calculations on some money values.
I am aware of the limitations of floating point arithmetic for this purpose, however the input values are all in a decimal format, so if I use the arithmetic operators on them PHP will cast them to floats.
So what is the best ...
Here a sample use case:
I request a simple form via an ajax request. I want to submit the result to the same page that I requested. Is there a way to access the URL of that request in the resulting request's javascript?
Below is some code that accomplishes what I want via javascript AND PHP. The downside to this is that I have to inclu...
How do I pass information back and forth in an asp.net web application throught the html forms? I know how to do this in PHP, but I can't seem to think about it through the code-behind thing (i think that's what its called).
(note: i only started looking at asp.net a few hours ago. i decided to try it by recreating a simple page)
...
While I am working in Vim I'd like to have a slight background color change for all code inside the php tags. So for example, the background is solid black for regular XHTML markup, then displays slighly lighter inside the php tags to help me identify it quickly. Is this something I can/should do with the color scheme or is there another...
i have this function here that i have in a class
function enable_ssl() {
if ($_SERVER[HTTPS]!="on") {
$domain = "https://".$_SERVER['HTTP_HOST']."/".$_SERVER['SCRIPT_NAME'];
header("Location: {$domain}");
}
}
but the problem is when the server doesnt have ssl installed and i have this function initiating the p...
Hello,
I'm currently writing a REST service using CakePHP and I was wondering how can I send an array of item_ids through REST to an action.
class ItemsController extends AppController {
var $components = array('RequestHandler');
var $helpers = array('Text', 'Xml');
function index()
{
}
function create($itemsArr)
{
//handle...
I want to create a small function in PHP which takes in arguments like color, shape, transparency etc. and outputs a PNG image. I heard about PHP GD library but I want to know how can one create something as creative as soon.media.mit.edu
...