php

convert mysql timestamp to mktime

Hi, I have the following MySQL timestamp: 2009-06-23 16:21:48 How can I convert it to a format like mktime()? ...

PHP pagination - problem displaying correct content on additional pages

I found this awesome code online to help with pagination, and it's working well, the only problem is: each page displays the same 4 rows. Any ideas will be much appreciated <?php //Include the PS_Pagination class include('includes/ps_pagination.php'); //Connect to mysql db $conn = mysql_connect("localho...

PHP Sessions across sub domains

I am trying to set up the following: auth.domain.com sub1.domain.com sub2.domain.com where if the user visits sub1.domain.com or sub2.domain.com and they are not logged in, they get pushed over to auth.domain.com and can log in. sub1.domain.com and sub2.domain.com are two separate applications but use the same credentials. I tried se...

php pagination numbered page links

Hi, This is a pagination code used for the navigation, any ideas how to get this code to display simply a numbered list of the pages as links? if (isset($_GET['pageno'])) { $pageno = $_GET['pageno']; } else { $pageno = 1; } if(isset($_GET['niche'])) { $query = "SELECT count(*) FROM studies WHERE niche = '{$_GET['niche']}'"; $re...

Simple XML not working on client server

I built a site using simpleXML to pull content from XML pages. I just switched the site to the client server and the pages that pull from the XML sheet don't work anymore. Testing server was PHP version 5.2.9 Client server is PHP version 5.2.5 allow_url_fopen is on for both servers. Any ideas? class award{ var $xml; var $awards; ...

Session ID always changing - can't login to my web application from ONE PC!!! Sessions being lost!

Hi guys, we've recently done some installation but I'm facing issues with one pc in particular and its baffling. We have a webapplication installed on our local server which is accessed by all our workstations. FOr some reason we can't log into our webapplication using one workstation. The application is a PHP MYSQL collaboration system....

Storing objects in an array with php

Hi, I have a function that pulls rows from a database, the content->id and content->type are them used to dynamically call amethod in an already loaded model to get and format the objects details. Once the object is returned it is added to array. All is well except that when i come to use the array although it has the correct number of ...

How should I design my code?

I'm building a forum in PHP and MySQL (for the funs). And I'm looking for a more elegant, cleaner, nicer, smarter way of strcturing it. I usually do it like this: page.php <?php include 'header.php' ?> <?php code for this specific page ?> content <?php loops and shit all over ?> <?php include 'footer.php' ?> In the header file I h...

Change an associative array into an indexed array / get an Zend_Table_Row_Abstract as non-associative

Hi out there in Stackland. I was wondering if there was either a function or an easy way to change an associative array into an indexed array. To elaborate, I'm using the Zend framework, and I've got a point in my site where I take out a row of an SQL table as an associative array. I've passed it to javascript via an echoed in JSON. ...

PHP Function Abuse?

I have a large system that I have coded and I wish to make the code (dare I say) more simple and easy to read. Unfortunately before this, I haven't used functions much. I have many different MySQL Queries that are run in my code, I feel that if I make the various displays into functions and store them in a separate file it would make t...

How to generate unique URL variables that match to a db record?

Hello all, I wish to be able to generate URL variables like this: http://example.com/195yq http://example.com/195yp http://example.com/195yg http://example.com/195yf The variables will match to a MySQL record set so that I can pull it out. At the time of creation of that record set, I wish to create this key for it. How can I do th...

Largest possible group of friends in common?

I'm trying to come up with the largest possible group of friends that would theoretically get along with each other, i.e., each person in the group should know at least 50% of the other people in the group. I'm trying to come up with an algorithm for this that doesn't take ridiculously long; Facebook's API/cross-server talk is pretty sl...

how to switch to another page in 3 seconds in PHP?

Here is my try: @header("Content-type: text/html; charset=utf-8"); @header("Location:/index.php"); @header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 @header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past As you have seen,there is no control over "3 seconds",how to make it take effect in 3 seconds? ...

Implicit Type Conversion for PHP Classes?

Is there a way to tell the php complier that I want a specific implicit conversion from one type to another? A simple example: class Integer { public $val; } function ExampleFunc(Interger $i){...} ExamFunc(333); // 333 -> Integer object with $val == 333. [edit]... someone asked for an example. Here's an example from c#. This is a...

how to randomly choose 5 numbers out of 50 numbers in PHP?

Or is there a ready function there? ...

Displaying data in a webpage from logged text files

Hello, I have multiple text files with logged data like this: 6/23/09 17:00 0.443 6/23/09 17:05 0.443 6/23/09 17:10 0.443 6/23/09 17:15 0.443 6/23/09 17:20 0.443 6/23/09 17:25 0.443 6/23/09 17:30 0.443 ... I'd like to create a webpage that displays this data from different files in a more readable manner. I'd like to create ...

Can I pass matched variables to the new URL with mod_rewrite?

I'm quite experienced in PHP but I don't quite use mod_rewrite (although I should). All I want to ask is if it's possible to pass many variables through a single rewrite rule. For example, is it possible to rewrite this: localhost/test.php?id=1&name=test&var1=3 into this: localhost/mysupertest/ and also use the same rewrite rule f...

How to solve a while true loop as it is expensive and Risky

Hello all, I make an AJAX request to see if a sesion variable has been set. I make a GET request to this script: <?php session_start(); while(true){ if(isset($_SESSION['screen_name'])){ return true; break; } } ?> Clearly there are problems with this script and I wanted to solve these problems such as the continuou...

What does this code do?

while (list($task_id, $parent_id, $task) = mysqli_fetch_array($r, MYSQLI_NUM)) ...

PHP with sqlite3 support

How do I know if PHP is compiled with SQLite support? If it's not, and I don't have the privileges to change it, what alternatives do I have to read an SQLite database besides access to php-sqlite3 functions? ...