php

Check query string (PHP)

Hello! I use a query string, for example test.php?var=1. How can i check if user type anything after that, like another string... I try to redirect to index.php if any other string (querystring) follow "var" query string. POssible to check this? For example: test.php?var=12134 (This is a good link..) test.php?a=23&var=123 (this ...

Installing PEAR without access to Internet

Hi, I need to install PEAR on a server which does not have outsite access to the net. There is no go-pear.bat in the php folder and even if it had go-pear.bat i think it needs access to the net. I looked an the Installing PEAR from a local copy from the PEAR website. But it needs PEAR to be already installed for it to work. So do any...

How should I design my rating system?

I'm building a website where users may register and create shopping guides. I want to award them points for creating shopping guides, adding stores and adding brands. It will also be possible for other users to rate the shopping guide. I'm considering to award the owner of the shopping guide more points, if the guide is rated high. But...

Accessing SimpleXML Object attribute

Have this print output from print_r($theobject); SimpleXMLElement Object ( [@attributes] => Array ( [label] => a ) [0] => Abnormal psychology : Abnormal psychology : ) Just cannot find a way to get element 0 which is "Abnormal psychology :" Lets call the object as $theobject I did $theobject[0], ...

How to implement the returnurl like SO in PHP?

It should also work after url rewriting. Is it possible?Otherwise I can only hardcode everything. ...

How is this design pattern called?

Hi. How do you call this design pattern? class Foo { protected $delegates = array(); //... public function __call($method,$argv) { //call $this->$something->$method($argv), where $something is a mapping from $this->delegates } } I can speculate, but I'm not sure, so I wanted to ask you. ...

Filter mysql results help

Hi... Im have a code that querys a mysql database against a certain criteria, and returns a result. The result then, is displayed in table rows inside a while loop, using the 'mysql_fetch_array' function: while($row = mysql_fetch_array($qry_result)){ By the way, this is a classifieds website... Here is my problem: After the resu...

Caching with PHP to take stress away from MySQL

I'm writing a web service for my application and want to know the best way to handle the possibly tons of requests I might get. A lot of the data probably won't change throughout the day but the particular script I'm writing makes 3 MySQL queries which seem a little excessive considering the data will probably be the same as the last re...

PHP Problem; looping through and adding new html tags

<form action = "numbericalInput.php" method = "Get"> Please enter the number of input areas you wish <input type = "text" name = "amountOfEntry"/> <input type = "submit" name = "GO"/> </form> <?php if(!empty($_GET("amountOFEntry")){ for($i = 0; $i < $_GET("amountOFEntry"); $i++){ <input type= "text" name = "nums[]" size ...

SVN externals and export for framework

I'm currently working on a framework for a client. The framework is based upon Zend Framework. The directory structure is: application : Application specific code application/modules/frontend : Application specific code application/modules/backend : Backend for MyFramework library/MyFramework : The custom...

Supply a different DTD location to SimpleXML / DOM for XML parsing

I have a problem with supplied XML files which don't have the right location in the XML. I'm trying to get correct XML files, but we might not succeed in getting those so I am looking at alternative solutions. As the DTD is available online, I could do a regex on the XML file and replace the DTD location, but this feels a bit hackish, an...

Controller within another Controller

Is it possible to instantiate a Controller class within another controller class using the Yii Framework For example I have controller Student and and method actionShow of class student I have the following public function actionShow() { $student = $this->loadStudent(); $studentContact = new Student_ContactController;...

PHP & CSS Output Problem

How do I set this up so that I can manipulate $backgroundcolor = "#00FFFF"; on another .php file? Initially I just want to be able to change the value of the $backgroundcolor ="#00FFFF"; From another form that is hrefed to this form (style.php) based on user input. I Tried this on this form so that I could hopefully give $backg...

SQL statement queries parameters become case sensitive how so???

Hi guys, I'm running a SQL query on my mysql database but for some reason its case sensitive like if an entry exists as 'NAME = Andrew' running a sql query like: SELECT * WHERE NAME Like 'and%' Doesn't work but SELECT * WHERE NAME Like 'And%' does work? WHat gives I'm running a php mysql set up here... ...

Image upload PHP

Here is my code; <?php define ("MAX_SIZE","500"); function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $errors=0; if(isset($_POST['Submit'])) { $image=$_FILES['image']['name']; if ...

Running multiple sites on a LAMP with secure isolation

Hi everybody, I have been administering a few LAMP servers with 2-5 sites on each of them. These are basically owned by the same user/client so there are no security issues except from attacks through vulnerable deamons or scripts. I am builing my own server and would like to start hosting multiple sites. My first concern is... ISOLATION...

PHP security question: store connection details in constants or private properties?

The title should say it all really - I was wondering if it's better to store connection variables as constants (because they can't be changed) or as private properties (because they can't be viewed). My apologies to all those who reel in horror at my lack of security nous... ...

PHP error_log performance issues

Hi, I've been trying to write an error handling class that I can use on sites, that will email me in the event of an error. Problem is, when I profile the application, it's choking on the error_log function. Here's my code (omitting the class: class ErrorHandler { private static $instance; private static $mail; private function __clone(...

PHP code to obfuscate HTML?

I know, I know - obfuscated html/js code is useless (I read the other questions on SO), but I still want to make life harder for copy-cats of my site... I'm running a php based website, which generates html output. I would like the FINAL html output (which has html, js, json and uses ajax) to be obfuscated. Is there a php function for t...

How do MVC components fit together?

I've seen a number of examples of ways MVC components fit together on the web. The Controller retrives data from the Model and passes it to the View This seems a bit verbose and messy. $model = new Model; $view = new View; $view->set('foo', $model->getFoo()); $view->display(); The Controller passes the Model to the View What if t...