php

Is there a way to return the id of a row that was just created in MySQL with PHP?

When I create a new entry in my MySQL database, I'd like the query to return the id of the table that was just created. If it cannot do this, is there another way to find out the this id? The reason I want to do this is so I can link a new row to the row that spawned it (and there's no guarantee that they're consecutive) ...

php pagination class that i downloaded gives me errors

hi, here is the script im using http://www.goodphptutorials.com/out/Simple_PHP_MySQL_Pagination this is the code i put on the page (excluding all other code) //pagination $page = 1; // how many records per page $size = 10; // we get the current page from $_GET if (isset($_GET['page'])){ $page = (int) $_GET['page']; } // create t...

How to enable locale en_EN on centOS to get i18n gettext working

I have a development version of my PHP website and when I moved it to my production server on centOS OS I discovered my locale version of en_EN is not working. Could you please tell me what can cause that and what to do to get this working? I use setlocale and gettext to use i18n in PHP. ...

How to enable notices on my development server

I have a development version of PHP on Apache. I moved it to production and got this weird notices in my website. I don't have it on development version. How to enable these notices on my development version of website to fix them? ...

How to create a friendly date format (for example "submitted 2 days ago"

I'm meaning to format dates on my social web app much like Digg.com and other sites do. There, you see very friendly dates, such as: just now 3 minutes ago one hour ago 2 weeks ago 6 monts ago ...you get the idea. Before I wrap my head around creating such a thing, does anyone know of any ready-to-go script for this where I simply in...

Constant server variables?

What's the easiest way of storing a single number on a server so that any script can access it, using PHP? Currently, I have a number stored in a file, but this seems somewhat inelegant. ...

Setting Substr to larger than string length

This is more of underlying PHP execution question. What are the positives or negatives to the two following methods for limiting string size? function max_length($string, $length) { return (strlen($string) > $length)?substr($string, 0, $length):$string; } substr($string, 0, $length); The case I am worried about is when the string ...

Why isn't my MySQL database insertion working?

$author = $_SESSION['username']; $subject = $_POST['subject']; $body = $_POST['body']; $branched = $_POST['branched']; $time = time(); $branchedFrom = $_POST['parent']; $id = $_POST['parent']; $next = 0; $previous = 0; $branchedTo = 0; mysql_query("INSERT INTO offtopic VALUES('', '$author', '$subject', '$body', '$time', '$next', '$pre...

PHP session_start fails

I'm trying to start the session in a header page in my webiste. But it seems there might be some sort of bug because it fails with the following error: Warning: session_start() [function.session-start]: open(\xampp\tmp\sess_a7430aab4dd08d5fc0d511f781f41fe5, O_RDWR) failed: No such file or directory (2) in D:\Development\PHP\tt\Include\h...

What's the maximum size for an int in PHP?

Ignoring the special libraries that allow you to work with very numbers, what's the largest int you can store in PHP? ...

Is there a standard place to put the version number in the source code?

I want to have one file where I can check which version is installed. Its a PHP program so you can look into the files. I was thinking if there is a standardized place to put it since in the Zend Framework or the HTMLpurifier I can't find the version number at all. I would also want to add it to the Zend Framework and HTMLPurifier if th...

How do I update MySQL row in PHP?

I have a MySQL database that I'm working with, but when I try to update a row in it, it doesn't work. Here's the update code I'm working with: mysql_query("UPDATE offtopic SET next = '$insert' WHERE id = '$id'"); ...

Using javascript with the twitter API

Hey everyone, I'm interested in making a twitter client using Adobe Air, but I'm kinda stuck right now, as I can't figure out a better way to connect to the twitter REST API since it needs authentication. Currently, the client sends a request to my server (a php script using curl) with the twitter username/password (unencrypted) in GET...

How to retreive information from Check Box?

My problem is a little bit complicate. (I use PHP) I have two arrays, (simple arrays array[0] = string, array[1] = string...) OK, now I will display the content of two arrays in a webpage. The first array contain names and the second images URL. Images and names are already displayed (my problem isn't here). But now I want to do somet...

Tips for managing a large number of files?

There are some very good questions here on SO about file management and storing within a large project. Storing Images in DB - Yea or Nay? Would you store binary data in database or in file system? The first one having some great insights and in my project i've decided to go the file route and not the DB route. A major point aga...

Is it better to use a prepared Select statement when you are only doing one select?

I am currently writing a CRUD class in PHP using PDO. I like the security that prepared statements provide, but I have heard that they also prevent databases like mysql from using the queryCache. Is it better to use a prepared Select statement when you are only doing one select at a time? or would just $pdo->quote() suffice the securit...

Sorting x and y coordinates in an array in PHP most efficently?

Currently I have an array that contains x and y coordinates of various positions. ex. $location[0]['x'] = 1; $location[0]['y'] = 1 This indicates id 0 has a position of (1,1). Sometimes I want to sort this array by x, and other times by y. Currently I am using array-multisort() to sort my data, but I feel this method is inefficient s...

Can I detect IE6 with PHP?

Is there a way to use PHP to detect if the page is being loaded using IE6? ...

Is there a reason I should not start with C#

I think I'm leaning toward C# and .net as a concentration language for learning web development. I would like to learn good programming fundamentals and I've looked at pretty much everything else. The four I've narrowed it down to have been C#, Python, Ruby and PHP. Is there a reason to stay away from C# (and I don't think the cost iss...

Best technique for caching results from queries that change infrequently

I have a php web application where certain data changes on a weekly basis but is read very frequently often. The SQL queries that retrieve the data and the php code for html output are fairly complex. There are multiple table joins, and numerous calculations - but they result in a fairly basic html table. Users are grouped, and the ta...