php

Regexp for validating .au domain names

Hi, I need a quick regexp for validating that a string is a valid .au domain name. For example: xxx.com.au xxx.net.au xxx.org.au xxx.biz.au xxx.--.au all of these should be considered valid. This should be pretty simple for someone not as hopeless with regexps as I am. Any ideas? ...

Wrong logic in If Statement?

$repeat_times = mysql_real_escape_string($repeat_times); $result = mysql_query("SELECT `code`,`datetime` FROM `fc` ORDER by datetime desc LIMIT 25") or die(mysql_error()); $output .=""; $seconds = time() - strtotime($fetch_array["datetime"]); if($seconds < 60) $interval = "$seconds seconds"; else if($seconds < 3600) $interval ...

Summing a field from all tables in a database

Hello, I have a MySQL database called "bookfeather." It contains 56 tables. Each table has the following structure: id site votes_up votes_down The value for "site" is a book title. The value for "votes_up" is an integer. Sometimes a unique value for "site" appears in more than one table. For each unique value "site" in the enti...

Session timeouts in PHP: best practices

What is the actual difference between session.gc_maxlifetime and session_cache_expire() ? Suppose I want the users session to be invalid after 15 minutes of non-activity (and not 15 after it was first opened). Which one of these will help me there? I also know I can do session_set_cookie_params() which can set the user's cookie to exp...

Allowing users to bump an input they submitted every hour?

So, I want people to be able to "bump" what they've wrote in my database but at the same time only allow the input to be in the table ONCE at a time. For Example: Jim's code is 5555. Jim enters his code and it shoots to the very bottom of the table. After 34 minutes he tries to enter his code in again (Because various other people h...

How can I ensure my user's data is valid in PHP and MySQL?

I have a web form that takes 2 string values and 2 integer values from a user and stores them in a database. How can I ensure that the ints are actually ints and sanitze input so that Bobby Tables doesn't pay me a visit? Here is my forms code: if(isset($_POST['submit'])) { $formTitle = $_POST['title']; $formAuthor = $_POST['au...

PHP function and variable inheritance

Can someone help me understand variable/function inheritance in PHP classes. My parent class has a function which is used by all the child classes. However each child classes needs to use it's own variable in this function. I want to call the function in the child classes statically. In the example below, the 'world' is displayed, as op...

PHP/MySQL Activity (ala facebook)

This may be a hairy question but. Say I have Followers: -user_id -follower_id Activities: -id -user_id -activity_type -node_id Pulling a users activity is fairly easy. But what is the best way to get a followers activity? A subselect? It seems like it is incredibly slow as users get more and more followers. Any ideas to speed this...

Displaying Logged in Content on a Website

Hi Everyone: I'm not quite sure how to describe this in words without making it overly complex, so here is basically what I want to happen: The user goes to my website, let's say: www.example.com/ The server goes to another website, example2.com, which has a field where their users should enter their username and password The server i...

Supplied argument is not a valid MySQL result resource???

I get this error when I use this code for people to input data. The submit form won't be listed cause it's not useful in this circumstance: function some_more_custom_content() { $output="<BR>"; ob_start(); if ($_REQUEST['code'] != "") { $code = $_REQUEST['code']; $query="INSERT INTO `fc` (`code`,`datetime`) values ('" . mysq...

cakephp, jquery, .ajax(), dataType: json

is it possible to be able to do without a view for a cakephp controller function? i am trying to have my server return a datatype that is not a string - but an array my controller function : function test() { $this->layout = 'plain'; $task['Numbers']['uno'] = 'mooo'; $task['Numbers']['dos'] = 'says the cow'; ...

PHP stripping strings..

Hi all, I would like to strip everything in a string before a - and leave what's after that. For example: 15.11-101 I want to strip 15.11 and leave 101. I've tried a few different things, but can't seem to get it working, if anyone could help me out, that'd be fantastic :) Cheers Leanne ...

Codeigniter & PHP - forcing a 404?

In codeigniter, as you know, a page of the form: /class/function/ID, where class is the controller name, function is the method within the controller, and ID is the parameter to pass to that method. The typical usage would be (for a book site for example) to pass the book id to the function which would then query the database for approp...

php image hosting sharing script

Anything like this exist in the open source world? I can roll my own, but im looking to save time if possible. Looking for something that will allow users to upload files and recieve a shortened URL to share. Possible have an api to allow other services to send pictures and return the shortened address. ...

Split MYSQL results into 4 arrays..

Hi all, I have a mysql query which spits out the following: Array ( [0] => stdClass Object ( [bid] => 18 [name] => Cafe Domingo [imageurl] => sp_domingo.gif [clickurl] => # ) [1] => stdClass Object ( [bid] => 19 [name] => Industrial ...

What is the function for moving local files in Symfony?

Example, move /var/www/1.jpg to /var/www/aaa/1.jpg ...

What's after PHP?

Possible Duplicate: What Should I Learn After PHP? Ive been doing PHP for the past 2 years and I'm quite comfortable with it, I can do most things and I'm finding it harder to find challenges. Which is good I suppose. But as I become more experienced I'm hearing bad things about it. That in the grand scheme of programming it's ...

Php error log shortens strings

I read call stack in Magento, but they are unreadable due to string shortage, eg: include('/var/www/oneste...') How can I see full string, in this case full path? ...

.htaccess rewriting url to page or directory

For my site I have a RewriteRule that points the URL http://www.mysite.com/work to a work.php file. I also have a directory called "work" that has files in it, like project1.php, project2.php, etc... What rules would I have to write so that the URL http://www.mysite.com/work knows to go to the work.php file, but the URL http://www.mysit...

Configuring already installed PHP to work with already installed ncurses (MAMP).

I have installed MAMP and the PHP it came with wasn't compiled with ncurses. I've tried to use port to install ncurses and it seems that it already exists on my system so now I was wondering if there was a way to get PHP to use it without having to recompile PHP --with-ncurses. In other words: Can PHP be configured to use ncurses withou...