php

How to upload files (multipart/form-data) with multidimensional POSTFIELDS using PHP and CURL?

I'm having problems with posting a multidimensional array with file uploads using PHP and CURL. The multidimensional array is for example: $post['question'] = 'Are you human?'; $post['answers'] = array('yes', 'no', 'maybe'); $post['file'] = '@/path/to/file'; // Output: Array( 'question' => Are you human?, 'answers' => Array( ...

The most efficient way to setup MySQL on Ubuntu Server 10 LTS?

Very soon I will setting up a web server for a client who has a very busy site. He has a forum (run on Simple Machines Forum SMF written in PHP) that cannot really be changed. I want to move this to a separate virtual private server on it's own, as it's very busy at around 40,000 hits a day with 400+ posts a day. With the version of SMF ...

How can I generate a large random token using PHP

I want to generate a large (~2 kb), random, unique block of random text for use as an authentication token. Standard hashing functions produce results that are too short. Would it be OK to use openssl's private key generation function or is there more appropriate solution I should look at? ...

PHP - open a link, in a new window?

Hi all, Sorry if this is blatantly obvious, but I've Googled this and I seriously cannot find any PHP-only way to do it. Without using an HTML or Javascript - pure PHP only (from a Controller file in a CodeIgniter site) - how can I open a browser window with a link I specify? Is it possible? Thanks! Jack Edit: it seems some people ...

Optimal MySQL design for user-specific activity feeds

I'm building a website that constructs both site-wide and user-specific activity feeds. I hope that you can see the structure below and share you insight as to whether my solution is doing the job. This is complicated by the fact that I have multiple types of users that right now are not stored in one master table. This is because the...

What is the "best practice" for choosing character encoding with PHP/MySQL applications?

I'm self-taught php programmer, so I often don't know the "correct" way to do something. I want to normalize my character encoding practices between my PHP, HTML, and MySQL data. -- live in the US, -- work on sites for people who speak English, -- most foreign languages I will encounter are western (Spanish, Italian, French) -- living...

How to use $_SERVER['REQUEST_URI'] to write a new URL and not infinitely-loop?

I have a php page and want to write a link that is based on the current URL. Like so: $alias = substr(strrchr($_SERVER['REQUEST_URI'], "/"), 1); print '<a href="'.$alias.'&sort=name">Sort by Name</a>'; On the page http://domain.com/listings , the link is written to http://domain.com/listings&amp;sort=name , which works perfectly. B...

Xdebug loaded correctly in Ubuntu but var_dump/error handling not being over-ridden

I have recently upgraded to Ubuntu 10.04 and as usual installed xdebug from the package manager. I've never had a problem after that with getting the formatted error messages and var_dumps to show up but this time they don't. I ran phpinfo() and it is definitely loading it, and I even tried running some of the custom xdebug functions an...

null $_POST variables if 3rd party cookies blocked on FF & Chrome

Hi, I'm trying to build a site that does not rely on the user enabling 3rd party cookies. For some reason, I'm noticing null $_POST variables from a simple only in Firefox and Chrome when 3rd party cookies are blocked (IE is fine). This is only with POST. The GET variables from the same script store the data normally. I have set IE ...

How to use MySQL Found_Rows() in PHP?

I try to avoid doing Count() because of performance issue. (i.e. SELECT COUNT() FROM Users) If I run the followings in phpMyAdmin, it is ok: SELECT SQL_CALC_FOUND_ROWS * FROM Users; SELECT FOUND_ROWS(); It will return # of rows. i.e. # of Users. However, if I run in in PHP, I cannot do this: $query = 'SELECT SQL_CALC_FOUND...

how to logout session if user idle in php

I am new to php and am trying to build a website. I would like to logout user session if he is idle for some time. I searched the web but i couldn't find the proper code. How do you check whether user is idle or not in php?. Can anyone help me please. ...

How do we Replace with the Hidden fields posted values in PHP

I have two hidden fields in the form (php) where these hidden fields are being replaced These hidden fields have the value from two text boxes. So we are getting the values directly from the textboxes in the action form <input type ="text1" name="text1" value=""> <input type ="text2" name="text2" value=""> <?php if(!empty($_POST['te...

php class for creating form interfaces to database tables

I often need to create html admin interfaces to administer data in tables. In other words, a page that lists all the records and lets you step through multiple pages of records, and perhaps sort or search them, along with the ability to add or delete a record, or update an existing one. Basic stuff. I do not like to use big frameworks ...

Deprecated: Function split() is deprecated. How to rewrite this statement?

I have the following statement which worked fine before PHP 5.3: list($year, $month, $day, $hour, $min, $sec) = split( '[: -]', $post_timestamp ); After upgrading to PHP 5.3, I get the Deprecated warning of the title. I am trying to parse a string with format like: 2010-08-10 23:07:58 into its component parts. ...

How to covert PowerPoint to video or flash in php

How to covert PowerPoint to video or flash in php? Or how would I call a process like this in unix Thanks! ...

php.ini config issue - testing file upload on 3 different servers

Hi, hope someone can help as I'm not sure what's going on here - I have a live site where I want to allow file uploads of over 2MB. I have set the standard config options in php.ini as follows (running phpinfo() shows these settings fine): upload_max_filesize 25M 25M post_max_size 25M 25M max_input_time 60 60 memory_limit 32M 32M...

PHP: How can I access this XML entity when its name contains a reserved word?

Hi all. I'm trying to parse this feed: http://musicbrainz.org/ws/1/artist/c0b2500e-0cef-4130-869d-732b23ed9df5?type=xml&amp;inc=url-rels I want to grab the URLs inside the 'relation-list' tag. I've tried fetching the URL with PHP using simplexml_load_file(), but I can't access it using $feed->artist->relation-list as PHP interprets "l...

Set up a PHP OAuth Provider

Alright I am trying to set up an OAuth Provider in PHP, but I just cannot get the hang of it. I've been referenced to this page a number of times, but I cannot wrap my head around it. Could someone help me out, step by step, or reference me to a more direct guide? Thank you very much. ...

Storing price in PHP. What is better double or string?

I've been making "Product Object" for my app and I've been setting attributes, when suddenly I got to price attribute and stumbled upon it with question what type better to choose? I understand, that for PHP it doesn't matter so much, but lets say for MySQL it does. Any suggestions? ...

How to display all datetime on website in user's GMT locale?

Hello, I store all datetime values as unix timestamp. Registered users can set personal GMT locale in their profile. What should I do to display all datetime on website in user's GMT locale? Thank you ...