php

How to master java and ruby fastest for a PHPer?

I've been using PHP all the time. Any advice to taking on these two languages? ...

regular expressions: OR (|) in subpattern not working

Hi there, I have two cases to match: either # ... ([0-9]+,[0-9]+) € ... # or # ... (--) ... # Now, # ... (?:(--)|([0-9]+,[0-9]+) €) ... # isn't working, it says Unknown modifier '(' ... I'm using preg_match_all() on PHP 5.3 Those above are NOT the full expressions, just extracts! ...

Karma/reputation system

I've been creating a reddit-like site based on a very good article about popularity algorithms. I think I'm going quite well, the site's looking good and the implementation is working. What I'm missing is a karma or reputation algorithm. Much like SO, I have in mind implementing certain privileges for the best users. Do you have an ide...

How to use errordocument to redirect to a php file in the same folder?

I want to take requests for missing files in a specific folder and redirect them to program.php in that folder. This is a program I will use a lot in different places, and I would prefer to avoid specifying the name of the folder in the htaccess file. I have tried just putting: errordocument 404 program.php but the result is that the...

Cannot get my 'delete.php to send to db and mark as dead

Is this an id problem or is there something I am missing? I am trying to get it to delete a comment...On this 'delete.php' page, $prof is the user sending the delete request, on the page that I'm trying to delete from, $auth is the sender of the comment. $prof = new User($_GET['id']); $query = "UPDATE ProfileComments SET status = 'd...

Getting data returned from a jquery ajax call

I am trying to get the data return from a function called by a jquery ajax call. My function is located in a a php file and it looks liket his valid_user() { $id = $_POST('id'); if($id == 'hello'){ return true; } else{ return false; } } and here is my ajax call $.ajax({ type: "POST", url...

How to use rewriterule to redirect to a php file in the same folder?

I would like to take requests for /somefolder/style.css and handle them with /somefolder/program.php So, I put the following in my .htaccess file: rewriteengine on rewriterule ^style.css$ program.php?css=1 [R=302,L] The result is that instead of redirecting to /somefolder/program.php, the server tries to redirect to: /var/www/html...

curl not storing cookies

I'm building a web bot to login into some of my accounts on websites but one of the url's are sending cookie from javascript and curl is unable to store them. Any suggestion? ...

PHP - How to count 60 days from the add date

Let me know :) $add_date = date ("Y-m-d H:m:s"); $expiry_date = 'how?'; How to insert into db the $expiry_date for 60 days. mysql format is datetime ...

Accessing URLS by www.example.com/page instead of www.example.com/page.php

What handles the disabling of the extension? Is it APACHE or the PHP install? How would one go about configuring the web server where the .php extension is not required? Is there an option that would make both www.example.com/page.php and www.example.com/page work as the URL? ...

possible to target iframe in another html file?

Hi. Is something like this possible: <form method="post" action="myphp.php" name="myname" target="another_html/iframe_name">??? I want the php file to display its results in an iframe inside another html file... Thanks ...

Is there a PHP library equivalent to cURL that does not need to be installed?

I am trying to proxy through php for a JS RSS feed. The company I am doing this for may or may not want cURL installed. If that is the case I may need some sort of library that can simply be included in php rather than go through apache and all of that. Is there a library that can handle something like that? What other options do I have ...

Help with cURL + PHP?

I am a novice programmer at best, but I am trying to play a prank on a friend. Basically, there is a url shortener that he is using to redirect to a rickroll page, and the url shortener has a statistics page. I want to mass request the url to make the statistics go up to a ridiculously high number. I've written a PHP script that should ...

Replacing Do ... While Loops

I have the following piece of code taken from the PHP manual on the curl_multi_* entries: $active = null; do { $process = curl_multi_exec($curl, $active); } while ($process === CURLM_CALL_MULTI_PERFORM); while (($active >= 1) && ($process === CURLM_OK)) { if (curl_multi_select($curl, 3) != -1) { do { $process = ...

Crop whitespace from image in PHP

Is it possible to remove the whitespace surrounding an image in PHP? NOTE: to clarify I mean something like photoshops trim feature. Thanks. ...

Should require_once "some file.php" ; appear anywhere but the top of the file?

Is the following example appropriate for PHP's require_once construct? function foo( $param ) { require_once "my_file.php" ; // // do something here } Or is it more appropriate to only have require_once constructs at the beginning of the file? Even though the file being included is useful only in the context of the functi...

Can I use an open source framework in a project I plan to profit from?

I'm building a CMS on codeigniter. I'm modifying codeigniter in small ways to make it work with my ideas more seamlessly. But I wonder - are there any restrictions on how I can profit from it? I would think I could build a website with the CMS and charge for it. But what if say, later on I buy a server and set up several accounts for sev...

/tmp/cache directory problem

Hello, I have just started out with testing some php mvc framework In it, it has this function that throws an error. The cachedirectory is set to /tmp/cache from the config file additional: The php is hosted on an IIS server. Can someone help me out to get this working somehow? This is the function within the class function setCach...

Windows-1251 file inside UTF-8 site?

Hello everyone Masters Of Web Delevopment :) I have a piece of PHP script that fetches last 10 played songs from my winamp. This script is inside file (lets call it "lastplayed.php") which is included in my site with php include function inside a "div". My site is on UTF-8 encoding. The problem is that some songs titles are in Windows-12...

Framework Comparison and Overhead

I am working on a Facebook game which is developed using Zend framework. Right now I don't have lots of traffic and already seen quite a large # of data usage / CPU time. Actually, I'm not good at Zend. I good at coding from scratch for both PHP & JS. so, I am curious about the performance of Zend framework. becuase I'm thinking a...