php

how to loop through this array in php

I want to loop through this array: $securePages=array("admin.php","addslot.php","classpost.php"); $pagename="admin.php" Then if admin.php is found then execute this code: header("location:index.php"); exit(); How would I put together this looping statement? ...

MySQL date or PHP time?

I usually store dates as integers using PHP's time() function in a MySQL database rather than using MySQL's date format simply because it's easier to manipulate when I pull it back out, but are there any disadvantages to this? ...

mssql_fetch_array(): supplied argument is not a valid MS SQL-result resource

I am getting the above error using PHP trying to update an MS SQL server. Any idea what may be happening here? I am using a stored procedure as the basis of the update. I can successfully execute the sproc against the SQL server away from the PHP application. Any advice/help would be appreciated. ...

how do I insert output from othermodules/controllers in a view

I have a view and I want to display data that would be generated by othe modules and controllers on the page. What is the best way to do this? For example: If on a certain page I want to pull in the latest news from the news module. ...

Integrating ASP.NET applications into PHP CMS (Joomla)

We're currently working on a major overhaul for our public website, transitioning from a pretty nasty static site to a new CMS. For some reason or another, Joomla was selected as the CMS despite the company being a very heavy MS shop. This would be fine, however we have multiple ASP.NET web applications which are currently running on the...

How do I find out total number of sessions created i.e. number of logged in users?

Hi guys I have a simple membership based website where users log in and have their own profiles. I woudl like to be able to tell at any given point in time how many users or rather which users are currently logged into my website. Its a simple membership based system in php. One way I uderstand it creating a table in a db and storing l...

Implementing a voting system without requiring registration

Hey everyone, I'd like to implement a voting system on my site, without having to force them to create an account. They would ultimately be voting up/down a piece of content which has a unique ID. I know that I could store entries in a table with IP/ID, but what if there are more than one user coming from the same IP? Is there a way t...

PHP and mysql connections

Is it possible to create a connection in a PHP class file and use it in all of the different methods in the class? I am trying to open a connection in the constructor and i get an error when i get to the close connection method saying that the argument that I've provided in the mysql_close() statement isn't a valid MYSQL-Link souce. ...

Why am I getting a router error for a static route?

I have in my bootstrap public function initRoutes() { $router = new Zend_Controller_Router_Rewrite(); $route = new Zend_Controller_Router_Route_Static('register', array('module'=>'members','controller'=>'register','action'=>'index')); $router->addRoute('register',$route); } and when I go to http://domain.com/register I ge...

Best Practice for returning cross-site JSON response

I'm currently working on a small application that works like this: When the user clicks a link, an Ajax GET request is fired. The request hits a server-side PHP script. The script, which requests information for another domain, retrieves a JSON feed. The feed is then echoed back to the client for parsing. I'm not really a PHP develop...

BBCode, preg_replace, and named capturing groups

What I thought was going to be an easy implementation of two lines of code and a function, turned out to be made of fail. On my webpage, I want to be able to type [text]1[/text], and what it will do is pull the title of that ID. function textFormat($text) { $raw = array( '\'\[text\](?P<id>.*?)\[/text\]\'is' ); ...

How does a leftjoin work while using a initialized prepared statement for MySQLI?

The user comes to this page from a different page where they click on a link and it is appended with a ?photo_id= and then the id number. I want certain information to be available to the viewer when they arrive at this page. I want them to be able to see the photo, the photo name, and the photographers name. The first two are not a pro...

In Zend Framework how do you wrap form elements in a label using decorators?

I would like to wrap form elements with labels as such <label for="email">E-mail <input type="text" name="email" id="email" /></label> The only option I could find is to alter the placement; however it only accepts 'prepend' and 'append': <!-- prepend --> <label for="email">E-mail</label> <input type="text" name="email" id="email" />...

Where is the best place to sanitize user input that will be output on a webpage?

In the MVC way of doing things, where is the best place to run, for example htmlspecialchars() on any input? Should it happen in the view (it sort of makes sense to do it here, as I should be dealing with the raw input throughout the controller and model?) I'm not quite sure... What are benefits of doing it in the view or controller? Th...

Need free php based ad management system banner rotator etc - which also has client access - any ideas

Hi guys I would like to know of a simple banner management system php based - free to use which would have the facility for clients to log in and see their banner statistics. ...

Tools to convert code in PHP to ASP.NET

I am working on a self project, where I am trying to convert a website written in php to ASP.NET(C#). I came across a php to ASP.net migration assistant, but this comes as an addon for VS 2003. Is there a migration assistant add in for VS 2008. Tips/tricks for going through the migration. Are their any other open source/Commercial tool...

cakephp query

How to write this query using the find statement in cakephp $this->Form->query("Select id from forms order by id DESC LIMIT 1") ...

using Mysql Query Profiler to know the execution time of the queries and the performance in php script

I would like to use mysql query profiler in the php script. So that after i execute any queries it need to display the execution time of the query. Suggest the best way to use this also share any other scripts like query profiler. ...

How To Identify The Requested Page In PHP

Is there any easy way to identify the file initially requested by the user, ignoring get arguments and handling (at least basic) mappings like / to /index.php? Ideally what I'm looking for is something like $_SERVER['REQUEST_URI'], except it returns the same value regardless of the get arguments and that value is the file requested, not...

Jquery and javascript height different to div

I have a contianer div around all the content in the site that dynamically streches, have also got severall other divs that strech (all using the same method as 20 other sites I have). Not matter what method is use with jqueyr or javascript to get the height of the container, javascript and jquery seem to return a value bigger that heig...