php

Registry or Singleton pattern in PHP?

I am working with PHP classes and objects now. In this question the names of fields and methods are made up just so you get an idea of what I am talking about. It is related to using the singleton and registry design patterns. Now lets say I need to access a Database object, Cache Object, Core Settings object, Session object in al...

posting data to a web page,need an alternative

To request some data from a web server, we can use the GET method,like www.example.com/?id=xyz but I want to request the data like www.example.com/xyz How can it be achieved in PHP? ...

simple php counter

Hi , I have a loop but I need to say that every time $i is printed the value of $i is a number so the start $i will be = 0 and at the end after 20 $i's it will be $i = 20 I hope some one can help Thanks ...

PHP and MySQL problem.

How do I enter the plus(+) and minus(-) signs into a MySQL database and output them + - as normal all while still using mysqli_real_escape_string(); if there is a better way please let me know. ...

How can this kind of SQL injection work even though there is not security consideration at all?

bob'); drop table students; -- In PHP,this will fail: mysql("statement1;statement2;"); There can be only one statement,so I really doubt how can the above injection actually work at all? ...

PHP Regular Expression help

Hi, I'm trying to use preg_replace to remove all characters from a string except for numeric and period characters. I can remove everything but numbers, however how can I make an exception for the '.' period character. Can anyone help me out? Thanks. ...

A good practice/project for PHP programmer

I know OOP (but not skilled) in PHP. Nowadays I want to build something, since it is the beginning of semester holiday (3 weeks). Do you have good suggestions for me? (note: I'm Statistician, and I know C, C++, Minitab, MATLAB, SPSS, SAS, R and database design) It does not need to be something related with statistics. Thanks in advance...

pChart php graph generation

I want to know a way of inverting the y-axis using pChart. I want the y-axis to start at 0 and 1,2,3,4 etc down, rather than up if that makes sense. In the case of search engine rankings a lower number is better and I want the graph to reflect that by inverting the y-axis. Any ideas? ...

php header not redirecting when using forms

Hi, Seem to have a unique problem. I'm doing form validation using a php script. I initially wrote this code in 2007. All of a sudden it stopped working, and I've been trying to figure out why. Here's the code: <?php $error_msg = ''; // Only Validate Form when it is submitted if (isset($formSubmit)) { if (!isset($_SESSION["Firs...

Unexpected '[' in Drupal 6 tpl.php

Ok, here is something strange that has had me stumped for about 45 minutes... I have a custom .tpl.php file that I am using to theme a node view. I have plenty of PHP already functioning in this template, but today I had a couple of CCK fields I wanted to move around. However, when I add my snippet in, I get "Parse error: syntax error,...

PHPUnit Test Question - How to Unit test my class

Hi, I'm trying to get into Unit testing for the obvious positives it introduces, and I'm trying to write a Unit test for a class I wrote the other day. (I know this is the opposite to TDD, please bear with me) My class, Image, is used in conjunction with some others for image manipulation. Image essentially wraps a GD image resource ...

Doctrine ORM - PHP - Zero Returned Values

I had doctrine and ORM working very well together. Then I removed three rows from my MySQL db and removed those values from my model. Now doctrine returns absolutely nothing. Not even a NULL value from the function or an error. I'm wondering if doctrine caches my schema somewhere or if I'm missing something ...

php HTTP_REFERER header, how to turn off or leave blank

Hi I'm using the following simple PHP proxy script but am getting a sporadic message at the destination site. I'm thinking that perhaps it may have something to do with the HTTP_REFERER header, although I'm not explicitly defining it. Can anyone tell me how to explicitly turn off or leave the HTTP_REFERER header blank? Thanks in advan...

jQuery Time ago from a timestamp?

Below is a really nice time ago plugin for jQuery, very similar to what they use here on SO. The problem for me is that it uses this to convert time. <time class="timeago" datetime="2008-07-17T09:24:17Z">July 17, 2008</time> That would be great except that I store time on my site in UTC timestamp and not as a formatted time, is the...

XSS Me Warnings - real XSS issues?

I've been using the free Firefox extension XSS Me from Security Compass to test for XSS problems. However, using what I understand to be safe filtering, XSS me still reports warnings. Are these accurate warnings or spurious? Using the code below as a testcase: <form method="post" action=""> <input type="text" name="param" value="<?php ...

Handling one-to-many relationship with ZF partialLoop

Lets say i'm listing musical artists, each artist has basic information like Name, Age etc. stored in an artist table. They also have entries in an Albums table (album name/album cover etc), referencing the artist table using the artist id as a foreign key. I have the Model_Artist (Artist.php) file: class Model_Artist extends Zend_Db_...

building a 'simple' php url proxy

Hi I need to implement a simple PHP proxy in a web application I am building (Its flash based and the destination service provider doesn't allow edits to their crossdomain.xml file) Can any php gurus offer advice on the following 2 options? Also, I think, but am not sure, that I need to include some header info as well. Thanks for any ...

PHP : $this->methodcall() gives error and CalledClass:methodcall() works fine

I am trying to call method getDetails() from another class which in turns calls to methods from its own class(i.e, called class) and it does so by $this->getAccount() and $this->getAddress() and in called class we have methods like $this->getAccount() and $this->getAddress() function but when I call them I get fatal error message as ...

Why can't I delete a file from a PHP daemon's child process?

I am building a simple PHP daemon script, using a php Daemon class provided at: http://www.phpclasses.org/browse/file/8958.html I'm stuck with this class for better or worse, and I don't have much time to get this done; so in order to issue custom commands to the daemon I'm just using a command file located in the /tmp directory. Howeve...

On MouseOver doTooltip in phpmysql

HI Please help to fix this code , i use <a href="http://example.com/index.html" onMouseOver="doTooltip(event,'http://example.com/image_6.06.jpg','Image TITLE')" onMouseOut="hideTip()" title="in TITLE">TITLE</a> in this code but its not work <? $sql = "select * from wallpaper order by wallpaperid desc limit 20"; $result = my...