php

Can Django do auto-admin for my PHP app's existing schema?

I have an application in production with a sub-standard admin interface. The app is written in PHP and is backed by PostgreSQL. I have briefly tinkered with Django and am very impressed with how easy it is to get an admin interface up and running. Can someone more experienced with Django please comment on: Can I have Django build an...

Read constant UDP stream in php

how do i go about reading data being sent almost constantly to my server. the protocol is udp. if i try to read in a while(1) loop, i dont get anything. it seems like the read will only echo once all the reading is done. so it waits till the loop is done reading which it will never be. i want the socket_read to echo immediately when it g...

How to calculate a weighted mean?

My language is PHP, but the algorithm should be fairly universal. I have an associative array of (let's say) ratings and number of times that rating has been given. $ratings = array( 1 => 1, 2 => 3, 3 => 6, 4 => 3, 5 => 3 ); This is the equivalent of: [1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5], but given the...

At what point should I support IPV6 in my php scripts?

I've got quite a bit of PHP code laying around and am wondering at what point should I start upgrading the scripts to support IPV6. I know IPV6 has been on the 'list of things to do' for a long, long time but really have never seen a clear transition path on when I need to start supporting it. G-Man ...

PHP session seemingly not working

Session variables are apparently not working for me. I don't know what I'm doing wrong. This is the code that I'm using to check for a valid password: if ($input_password_hash == $password_hash) { session_start(); $_SESSION['is_user'] = 1; header("Location: ../new_look"); //or Location: index.php } else echo "Wrong password."; ...

PHP array problem

Hello. I'm sending some data over AJAX to a PHP file. It's about filter options. Anyway, I am sending it like this: filter[0][data][type] string filter[0][data][value] automobiles filter[0][field] product filter[1][data][type] numeric filter[1][data][value] 6000 filter[1][field] price This above is taken from FireBug console. Then,...

What are some methods for handling pagination of long lists?

I'm wondering if there are any standard methods of keeping the correct pagination of real-time lists. For instance, on Stack Overflow if I go to page 2, and in the period of looking at page 1 a new question was submitted, how can I keep page 2 the same as it was when I started looking at page 1? A lot of the time people will just do an ...

Keeping an array sorted in PHP

I have a PHP script which reads a large CSV and performs certain actions, but only if the "username" field is unique. The CSV is used in more than one script, so changing the input from the CSV to only contain unique usernames is not an option. The very basic program flow (which I'm wondering about) goes like this: $allUsernames = arra...

Stack Overflow / reddit voting system in php

I'm looking for examples of how to implement a StackOverflow / reddit voting system in php. Basically I want the Up and Down arrow box. Are there any good examples out there? ...

How to get the mutiple array values into explode?

I am getting this values from database. $Generic=$res['Generic']; $Trade=$res['Trade']; $Dos=$res['Dos']; $Duration=$res['Duration']; I stored the values using "implode function". How to get these values into "explode function" PLz Help me. ...

round in PHP shows scientific notation instead of full number

I'm trying to do an echo of a variable containing 1400000. so there is written: echo round(1400000); this gives 1,4E+6 instead of the full number. Anybody an idea on how to display it fully? ...

Creating an isset if fuction using php to avoid and update if the input is empty for a MYSQL update.

Hi I am newish to php and I have created an update page for Content Management System. I have a file upload in this case a picture. I have other inputs that contain text and I can get them to populate my form and thats fine and works great because the user can see what has already been entered. But the file name for the photo can not hav...

How to detect and debug stale cache entries?

I am using memcached with PHP trying for heavy caching to avoid db-reads. I am invalidating the cache on an update (application invalidates). But, stale cache data is becoming a big issue. Mostly, this is due to bug in invalidation (invalidates wrong key OR forgetting to invalidate the cache entry on an UPDATE). Is there any good method...

Can you translate php function quoted_printable_decode() to an NSString-based, objective-C function / category method?

In http://php.net/quoted_printable_decode, I found ways to do it using preg_replace. Anyone who knows any code that could convert a normal NSString to something RFC 2045 section 6.7? Thanks in advance! ...

AJAX/JQUERY/PHP issue...

I am trying to use an ajax 'POST' call through the jquery $.ajax function to send data to a php file. For some reason the callback is a success but the data is not getting to the php file. Here is an example of the code: In JS file: $.ajax({ type: "POST", url: "setData.php", data: "myPOSTvar=myData" success: f...

Automatic bug collection from PHP/apache server code

It is painful to fish out things from apache error_log. Does anybody have pointers to some better error collection mechanism. Something like what is described in "Using FogBUGZ to Get Crash Reports From Users - Automatically!", but for a PHP/apache webapp More specifically, some mechanism to hook the errors that is thrown by PHP to some...

What's the best way to display the number of items related to tags?

Hello, After following this recommendation regarding tags tables structure, I've implemented the following design: Table: Item Columns: ItemID, Title, Content Table: Tag Columns: TagID, Title Table: ItemTag Columns: ItemID, TagID I'm facing another problem, I wanna display the number each tag appears in the system. What's the best ...

Uploading big files over HTTP

I need to upload potentially big (as in, 10's to 100's of megabytes) files from a desktop application to a server. The server code is written in PHP, the desktop application in C++/MFC. I want to be able to resume file uploads when the upload fails halfway through because this software will be used over unreliable connections. What are m...

What are the security implications of not closing connection to the database after you are done with it?

I was just wondering what security issues can arise from not closing the database connection after using it. Doesn't PHP automatically close it once a new page loads? Levi ...

Choosing a PHP Framework for long-term deployment

Duplicate Question: What PHP Framework Would You Choose for a New Application and Why? We are starting a new project and I am wondering which PHP framework we should use and if we should use a framework. We decided to choose PHP instead of ASP.NET in part because we didn't want to get stucked in a unflexible paradigm (WebForms, every...