php

PHP session not working with JQuery Ajax?

Update, Solved: After all this I found out that I was calling an old version of my code in the update ajax. 'boardControl.php' instead of 'boardUpdate.php' These are the kinds of mistakes that make programing fun. I'm writing a browser gomoku game. I have the ajax statement that allows the player to play a piece. $(document).ready(fu...

Is there a PHP calculation which could result in a -0 ?

I am having trouble with a complex script which sometimes (About 2 or 3 times while calulating about 90'000 values), generates a '-0' and writes it into the database. I suspect it's a string (The values which are calulated can result in integers, floats or strings.)* Is there any PHP calculation which might result in a '-0'? * = Oh, ho...

How do you get a directory listing sorted by creation date in PHP?

Hi, I have to list directories by using scandir() function but result array should be sorted according to date and time of directory created. Regards Deepak ...

help with php FOREACH loop

hi, can some please tell me what's wrong with the bellow foreach php loop. foreach ($_POST[sortlist] as $key => $value) { $sql = "UPDATE sortable SET color_order = " . mysql_real_escape_string($key) . " WHERE id = " . mysql_real_escape_string($value); $result = mysql_query($sql) or die(mysql_error());...

Page Views counter using PHP and MySQL?

I was wondering how can I alter my code so it can count the page views for each page when multiple pages are present and display the correct page views for each page. Here is my php code below. //Adds one to the counter $mysqli = new mysqli("localhost", "root", "", "sitename"); $dbc = mysqli_query($mysqli,"UPDATE counter SET counter =...

WURFL's New API Question

Hi all, I have a simple stupid question. Here's the problem, for years, my company has been using the old WURFL PHP API. Now, with the release of the new WURFL PHP API that promises a better performance, we want to use it. What I want to ask is, how do I update the cache? Can I use the old *update_cache.php*? ...

Coding style: function and procedures coding standard

Ch 7.6 of Code Complete 2 is confusing me, I've attached some sample code (in php) mind telling me which style is the best? or suggest something better? thanks Style 1 public function register($user, $pass) { if($this->model->isRegistered($user) { return false; } else if($this->twitter->login($user, $pass)) { return $this->mod...

PHP OOP, perform a function once a certain variable has been set

How can i perform a function once a variable's value has been set? say like $obj = new object(); // dont perform $obj->my_function() just yet $obj->my_var = 67 // $obj->my_function() now gets run I want the object to do this function and now having to be called by the script. Thanks EDIT my_var is predefined in the class, __set ...

Multiple values for an input in a form?

Alright, let me start with an example. I have a bunch of items and they can fall into series of categories. An item can be in multiple categories. Basically what I have is a listing of items with checkboxes grouped by category. Again an item can appear more than once. So it could look something like: Blue Items: Item 1 Item 2 Item 3 Re...

Using a 'case when' in a Doctrine select statement

I have a select query I'd like to perform with Doctrine: $resultset = Doctrine_Query::create() ->select("t.code, t.description, case when t.id_outcome = 1 then 1 else 0 end as in_progress") ->from('LuOutcome t') ->orderBy('t.rank') ->fetchArray(); And it barfs on the 'case'. The documentation does not mention that it'...

Securely Connect MySQL via PHP in ActionScript 3 using AMFPHP framework

My Flash movie would like communicate with MySQL server to fetch and save data between MySQL and SWF. I know AMFPHP can help with the communication, but is there a secure way to encrypt the texts sending between 2 sides (other than hashing password in MD5)? As far as I know, by default, AMFPHP sends out data in plain text. Also, I heard...

PHP on IIS7 and Windows Server 2008 - Pros and cons

Hi guys, Background: I work for a small microsoft based web dev company who is slowly starting to do more PHP based work. To date we've run these sites (mostly WP) through IIS6 on Windows Server 2003 although this presents problems around mod rewrites etc. We're at a stage where we can make a decision between upgrading our existing se...

is it possible to get a class return true in is_null?

I am building some kind of a proxy pattern class for lazyloading sql queries. the proxy pattern uses __call, __get and __set for relaying calls on its object, but sometimes there is no object, if the sql did not return any rows. my question is then, if i do a is_null() on the proxy class, is it possible to make the class return true th...

Page View Counter like the one here on StackOverFlow?

What is the best way to implement the page view counter like the one found here on this site where each question has a "Views" counter using PHP and MySQL?? ...

svn - 2 'packages' one using elements of the other, best way to structure this?

Hi, I have what I believe is a tricky situation but this usually indicates I'm ignorant of something quite simple. I currently have one php project that is in an svn repo, call it 'firstproject'. The working copy of this is an apache virtual host dir so I can happily run this project at any point of development through a browser. I now ...

Regular expression filtering - mimicking Expression Engine's template parsing

Hello! I'd like to mimick (reproduce) Expression Engine's fantastic template parsing method. (Pls don't ask me why not using it :)) While i'm able to find and parse simple tags like {example_param = "param_value"} i cannot parse tags where closing tag added: {cyclic_param} ... {/cyclic_param} This is the pattern i'm using: '/[\{...

How to share session between flash AS3 and PHP?

Login page in flash, user will send username and password to a php file(login.php). IF login success, it will return echo "success" and create session there. Then in flash, when i click shopping button, it will go to www.domain.com/shopping/index.php, that index.php will do a session check whether the visitor has login. But it seems like...

SSL and php logins

Hai all, i successful configured a self signed SSL certificate and configure it in the MAMP server, now if i type https://localhost:443/ it will show the certificate, now i would like to configure a httpsdocs (like htdocs) and implement a secure login, can any one help me to run a simple page using SSL ...

How to hide or display text and tags with PHP?

I was wondering how would hide the text Location if the city state and country were not present and how would I let it display if any of the variables were present? <p>Location: <?php if (!empty($city)) { echo $city .','; } if (!empty($state)) { echo $state; } if (!empty($country)) { echo ' '...

redirecting to homepage rather than 404 error page!

Hi friends, I'm working with PHP. I have an .htaccess file like below, and it redirects to homepage rather than 404 error page :/ what can be the problem here? Appreciate helps! thanks a lot! ErrorDocument 404 /new/err404.html RewriteEngine On RewriteBase /new/ RewriteRule ^login.html$ index.php?s=login&a=loginDo [QSA,L] RewriteRule ...