php

PHP and printing out whitespace?

I was wondering how can I print out whitespace in the following code below. <?php echo "$first_name", "$last_name" ; ?> ...

Drupal + Nginx + Php-cgi : 502 Bad Gateway error

We are running Drupal 5.x on Nginx with php-fastcgi. Things were working fine for a while. All of a sudden, we (users) are running into 502 Bad Gateway error. Restarting PHP-cgi, nginx.. rebooting machine etc did not help. Did anyone else run into this type of issue? What are the possible suspects? ...

PHP Force Download of Remote File

Hello all, I have a bunch of videos stored on my Amazon S3 storage. I'm working on creating a PHP script, very similar to the one here, where users can download the videos to their hard drive. I'd like to use something like this: <?php $file_name = $_GET['file']; $file_url = 'http://www.myamazons3.com/' . $file_name; header('Content...

Is php compiled or interpreted?

Is php compiled or interpreted? ...

Pagination and .htaccess

Hey I am currently showing results using the following url index.php?id=1 and using .htaccess to rewrite it like cat/sub-cat/ and i am using pagination and the url to the next page is index.php?page=2 etc but i can't seem to get the pagination to work with my .htaccess rewritten url so for example threads/thread-name/ shows the page fin...

When setting a session with PHP, how do you make it global to the entire site?

I am creating a session and I want a variable to be available for the entire site, so for example: Joe Soap lands on a page called red-widgets.php, - Joe's session variable is let's say 'red-widgets'. Joe then clicks on another page called blue-widgets.php. I would like the session variable to be still the original 'red-widgets'. How c...

If i do print_r in PHP, it prints the array in junk.

How can I print the array in a Tree-like format--making it easier to read? ...

Need some help with regex

Here is the suject: http://www.mysite.com/files/get/937IPiztQG/the-blah-blah-text-i-dont-need.mov What I need using regex is only the bit before the last / (including that last / too) Now this 937IPiztQG bit can change, it has a-z A-Z 0-9 - _ Heres the code i wrote but it doesnt work $code = strstr($url, '/http:\/\/www\.mysite\.com\...

Minimizing a function dealing with seconds and minutes.

Can I shorten this function? $mins = $secs - time('u'); function minutes($seconds){ return sprintf( "%2.2dm %2.2ds", floor($seconds/60),$seconds%60);} $mins_left = minutes($mins); echo "Resets in $mins_left."; ...

How to store parse_url as a string in PHP?

Hello again. I have the following code: $array = parse_url($_SERVER['HTTP_REFERER']); $Ur = $array['host']; which displays the domain just fine, but when I use this with sessions, it doesn't work. Also, I tested it with gettype and it returns Null? I thought it was an array? Anywho, how do I go about converting the above $Ur into a...

Password reset script only fires half the time [PHP, MySQL]

I had an inefficient piece of code for resetting passwords based on a user entering either their username or their email address. The PHP script branched depending on the identifier used. I collapsed it into one which now works if the user enters their username but not if they enter their email address. Here is the salient code: $identi...

C# How do I upload a file to a PHP server?

I need to upload a file to my webserver from a C# program. The problem is, I need to also POST two strings at the same time. So far, I have: HttpWebRequest HttpWReq = (HttpWebRequest)WebRequest.Create("http://localhost/test.php"); ASCIIEncoding encoding = new ASCIIEncoding(); string postD...

Java: function for arrays like PHP's join() ?

I want to join a String[] with a glue string. Is there a function for this? ...

javascript variable into php

hi to all I have a php function, in this function I have a javascript which get the value of my element from parent window. My problem now is, how can I pass this value into php variables Any help would greatly appreciated. Thanks Tirso I tried this code but I got value always 1 here is my code function do_upload() { $categories...

Set cookies on file upload in PHP

I have a php upload handler in upload.php, and there, I have to following <? setcookie("test",100,time()+3600); ?> but, when I check the cookies that are set, I dont see any "test" cookie at all. Can you please help me set a cookie on file upload? why is this upload script any different from any normal script that is accessed by the ...

Hot to update mysql_fetch_array

As you will see I am fetching the column, and trying to update column with new data. $result2 line is my problem, I don't think I can add $row[0] in there. How do I do it? $result = mysql_query("SELECT link FROM items LIMIT 3"); while($row = mysql_fetch_array($result)) { $url=($row[0]); $rez2 = get_final_url($url); $result2...

WordPress: How to display only posts that are in a certain category?

Hi, I'm pretty new to WordPress but have spent some 50 odd hours studying up on it, trying things out and such and have the feeling I got a pretty good handle on it now.. However the one thing I simply cannot get working is to have a page spit out a list of posts of a certain category. Here is my example: http://dev.jannisgundermann.c...

SQL query to collect entries from different tables - need an alternate to UNION

Hi guys, I'm running a sql query to get basic details from a number of tables. Sorted by the last update date field. Its terribly tricky and I'm thinking if there is an alternate to using the UNION clause instead...I'm working in PHP MYSQL. Actually I have a few tables containing news, articles, photos, events etc and need to collect al...

Read Next Record

I am filtering null values, in php on MYSQL. When a null value is read, I need the MySQL to read the next record. How do I go about doing that? ...

[PHP] Problem with json_encode()

Hi all, i have an simple array: array 0 => string 'Kum' (length=3) 1 => string 'Kumpel' (length=6) when I encode the array using json_encode(), i get following: ["Kum","Kumpel"] My question is, what is the reason to get ["Kum","Kumpel"] instead of { "0" : "Kum", "1" : "Kumpel" }? ...