php

Setting database and access control permissions

Hi. I am part of a team creating a web application using PHP and MySQL. The application will have multiple users with different roles. The application will also be used in a geographically distributed manner. Accordingly we need to create an access control system that controls user permissions for specific database records i.e. modifi...

validating user input tags

I know this question might sound a little cheesy but this is the first time I am implementing a "tagging" feature to one of my project sites and I want to make sure I do everything right. Right now, I am using the very same tagging system as in SO.. space seperated, dash(-) combined multiple words. so when I am validating a user-input t...

How to get the Full Entry in a RSS 2.0 feed

I have used several different scripts that people have suggested for trying to parse RSS including Magpie and the SimpleXML feature in PHP. But none seem to handle RSS 2.0 well because they will not give me back the full content chunk. Does anyone have a suggestion for reading a feed like the one found at http://chacha102.com/feed/, and ...

Why should I use an MVC framework for PHP?

There are lots and lots of opinions available about what framework is the best choice as well as resources and tutorials to help you learn to use them. What I'm having a hard time finding is a clear explanation of what the "ah-ha this is why I learned all this" moment. So just to clarify, I have never used any framework and don't reall...

How do I create a unix password hash with php

I'm trying to create system users with a php script securely, In that, I'd like to be able to hash the password with the php script, so that their password shows up nowhere in the bash history. How to I take a string, and hash it so it is a unix password hash? $UX_PW = some_function('my_password'); exec("useradd -p $UX_PW newusername")...

Login Script problem

if (isset($_POST['login'])){ $query = mysql_query("SELECT id FROM users WHERE username = '".mysql_real_escape_string($_POST['username'])."' AND password = '".mysql_real_escape_string($_POST['password'])."'"); /* wrong login information? redirect to error message */ if (mysql_num_rows($query) == 0){ header("Locatio...

PHP regex: what is "class at offset 0"?

I'm trying to strip all punctuation out of a string using a simple regular expression and the php preg_replace function, although I get the following error: Compilation failed: POSIX named classes are supported only within a class at offset 0 I guess this means I can't use POSIX named classes outside of a class at offset 0. My ...

Create SQL query that orders results by which condition they meet

This is for MySQL and PHP I have a table that contains the following columns: navigation_id (unsigned int primary key) navigation_category (unsigned int) navigation_path (varchar (256)) navigation_is_active (bool) navigation_store_id (unsigned int index) Data will be filled like: 1, 32, "4/32/", 1, 32 2, 33, "4/32/33/", 1, 32 3, 34,...

Zend Framework: How do you set your layout directory in a modular application?

the directory structure I'm trying to achieve would be this: application/default/views/layouts/layout.phtml application/default/views/scripts/index/index.phtml application/admin/views/layouts/layout.phtml application/admin/views/scripts/index/index.phtml library/Zend config/config.ini public/index.php (bootstrap) but I can't figure ou...

Is there any value in PHP checking a bool vs an int?

I have the following line: $this->magicQuotes = (bool) get_magic_quotes_gpc(); I am taking the get_magic_quotes_gpc() storing it in my object as it's used many times as I generate the SQL. I am also converting it to a bool. I'm wondering if it's worth while converting it to bool. The main reason I am is for speed as the statement tha...

The counterpart of mysqli::real_escape_string?

stripslashes() ? That's lame and so 4.0. What's the 5.0 counterpart of mysqli::real_escape_string that strips all slashes added for SQL queries? Got some other questions: Tried to update a record and added a single quote in a text field, turns out phpMyAdmin escapes the string with single quotes instead of slashes - e.g. a single quot...

Any good ASP.NET CMS?

I've been trying to install DotNetNuke for the last 3 hours with no luck. What is a good and easy to install ASP.NET CMS? If there aren't any, what are some recommend PHP ones? ...

List random products from category in osCommerce

I was asked to implement a random product listing for an osCommerce on-line store. I can do some basic PHP but the store uses a framework of its own and I'm clueless how to do it. First I try to make a random list just on the front page: I open index.php and find the include(DIR_WS_MODULES . FILENAME_UPCOMING_PRODUCTS); line after wh...

Get all instances of a class in PHP

I would like to get all the instances of an object of a certain class. For example: class Foo { } $a = new Foo(); $b = new Foo(); $instances = get_instances_of_class('Foo'); $instances should be either array($a, $b) or array($b, $a) (order does not matter). A plus is if the function would return instances which have a superclass o...

Fastest way to check how many posts are in a thread with MySQL and PHP

Hi, I was wondering if it which is faster when trying to, for example, check how many posts are in a particular thread on a forum. Should I... (a) Go through each post in the database with the particular thread ID, and count how many rows or (b) Add one to a separate column in the threads database every time a thread is made, and then...

Difference between php 4 and php 5?

I'm in search of the web hosting space, and got to know the PHP version is 4.3 and MySQL Version 4.1 But i developed my application in MySQL version 5.x and PHP version 5.x Can anyone give me the differences in versions ? what all i cannot access now ? Thanks... ...

Best way for authentication in PHP

Hi Folks, What's the best and most secure way to go when writing an authentication library in a model-view-controller way? The things that give me a hard time are keeping track of the users activity and remembering users via a cookie or storing sessions in the database? Thanks in advance :). ...

Php By Reference

Hello, Can someone please explain what the "&" does in the following: class TEST { } $abc =& new TEST(); I know it is by reference. But can someone illustrate why and when I would need such a thing? Or point me to a url where this is explained well. I am unable to grasp the concept. Thank you very much. ...

How do you post the contents of form to the page in which it is?

In Yahoo or Google and in many websites when you fill up a form and if your form has any errors it gets redirected to the same page. Note that the data in the form remains as it is. I mean the data in the text fields remains the same. I tried form action="(same page here)" method="post or get". It gets redirected to the page, but the con...

how can I program in ASP.net using PHP like methods

I am a PHP programmer and I want to develop a website using visual web developer .net I knew that asp.net has many different approaches in dealing with database. However, I am familer with PHP way in programming for example: $query = "select * from table where user_id > 2" $result = mysql_query($query); while($row = mysql_fetch_array($...