php

How to use jQuery AJAX for an outside domain?

I am trying to perform a simple jQuery AJAX attempt using either a .get() or a .post(). If I have a local copy on my server and do: $.get('/hash.php',...,...) I monitor in my console in firebug that the get is done and I get a response. All I change is the URI to an outside server and nothing happens. $.get('https://secure.mysite.c...

JQuery submit form after clicking on link

Here is the JQuery: $(document).ready(function() { $('#autosave').click(function() { var url = window.location.pathname; $postData = $('#content form:first').serialize() + '&' + $('#content form:first .input-submit').attr('name') + '=Save'; $.post(url, $postData, functi...

Extended updates, is there such a thing?

Quite simple really, in a php/mysql set up, I have to run around 2M point updates on 25M items (where one update covers multiple primary keys), is there a way to pull this off with the same sort of gains as extended inserts? I'm using unbuffered queries already. Its slow. NB: Searching came up with nothing, this is on a dev environment...

Fastest way to match telephony prefixes using asterisk PHP script

Hello all, and thanks in advance for the help. Background - I am writing a PHP script that needs to figure out the destination the caller is trying to reach. Telephony prefixes are strings that identify a destination. For each call, the program must find the longest prefix that matches the string. For example the number 30561234567 wou...

Security issue?

Hi guys, I am writing a small PHP application and I am not sure whether I have a security issue. So this is what the application does: the user can upload either image files (png, gif, jpg, jpeg, tiff and a few others) or zip files I check for mime-type and extension and if it's not an allowed I don't allow the upload (this is not th...

PHP - SQL: fetching results in round robin fashion

I have a table, which consists of 3 fields: id name status Every time I get the results, it should give me 5 names whose status = 1. Suppose the db contains following: id name status 1 A 1 2 B 1 3 C 0 4 D 1 5 E 0 6 F 0 7 H 1 8 I 1 9 J 1 10 K 1 11 L 1 12 M 0 1st time, fetch ...

PHP: Any logical use cases for include/requiring remote source files?

http://www.php.net/manual/en/features.remote-files.php The only time I could ever think of doing include("http://someotherserver/foo.php") would be as some sort of weird intra-server service interface, but even then I could think of a million different ways that were safer to accomplish the same thing. Still, my specific question is, ...

MVC large websites, use one controller...or many?

I have a pretty large site, and I am looking for the most time efficient way to manage it (I am the sole coder). I am trying to devise a very simple MVC structure (i don't want to use a framework) to help keep all my code in order. For a huge site, is it better to have only one controller to handle all the pages, or is it better and ea...

Can you put too much information into a variable?

I'm creating a script that makes use of the $GLOBALS variable quite a lot. Is there too much you can put into a variable? If I have a lot of information stored in $GLOBAL variable when the page loads, is this going to slow down the site much or not really? Is there a limit to how much information one should store in a variable? How doe...

Update div on AJAX submit jQuery is updating all divs...

I'm trying to update a div with an ajax post. Problem is...it's updating every div. Here's the json.php: //json.php $data['months'] = $db->escape_value($_POST['check']); $data['id'] = $db->escape_value($_POST['hidden']); $query = "UPDATE month SET months = '{$data['months']}' WHERE monthID = '{$data['id']}'"; $result = $db->query($...

swift mailer error 'Swift_RfcComplianceException' on an email that actually works?

Hi everyone, My swift mailer plugin has just thrown up an error because an email address it tried to send to isn't compliant. Problem is - the email is valid. Basically, I don't want swift mailer to be checking whether or not the email is valid I'd like it send regardless. Is that possible? here is the code which has the function whic...

Merge duplicates into one row and sum up values using php

I have a table that hows the following rows... ID | TITLE | ARTIST | ADDED | HITS | HITS THIS WEEK -------------------------------------------------------------------------------- 7505 | Track 2 | Artist 1 | 2009-08-24 10:32:41 | 1539 | 2 7483 | Track 2 | Artist 1 | 2009-08-23 16:58:35 | 1450...

Sending an attachment with php

Hello, I am trying to create an email form that allows you to send an attachment. I have pieced code together from my PHP book and several websites. When I send the email using this form the attachment ends up corrupted and the "$comments" don't seem to go through. Here is the code I am using: <?php $to = $_POST['to']; $from = $_POST[...

How do I specify environment variables when making a system call in PHP?

I'd like to call system("foo") in PHP but also specify environment variables that "foo" will have access to when it runs. This is under Linux. Any simple trick for that? ...

PHP callback just before script dies

I have a set of custom PHP scripts. They load a main PHP file (to include other files, set settings, etc.) From this script I'd like to insert a callback function that is called by the scripts that included the main file just before ending. What I intend to do is make a simple custom output cache with ob_get_contents(). I want to do ob_...

How to find the Birthday of FRIENDS Who are celebrating today using PHP and MYSQL

Hi all, How to find the Birthday of FRIENDS Who are celebrating today using PHP and MYSQL thanks in Advance... Fero ...

Sending mail when mail server is not on web host

I am hosting a client's site while they are running an exchange server at their location to handle the email. Whenever I try to send email via PHP to one of their email addresses it fails as it is looking for the address on the local system. Can I force the mail function to look outside of the server for sending mail? I'm on a Media T...

String operation in PHP

I'm now dealing with uri like /page.html?k1=1&k2=2 $str = preg_replace('/[&\?]' . $k . '=[^&]*/',"",$str); The above aims to delete $k related part in uri,but will also delete ? wrongly. How to do the right thing? ...

Save Image from URL to Amazon S3 using PHP

Hello all, I'm looking for some help and direction on how I can pull an image from a URL (these are my own images) and move/upload the image to my Amazon S3 bucket, using PHP. For example, let's say the image I need is: http://myhost.com/image.jpg I would like to be able to move this image (image.jpg) to my S3 server. Any ideas on...

Which framework for a project?

I am contemplating between three frameworks: Django, CakePHP and Zend. The project will include social aspect (members), will have a cart/checkout, lots of different forms and very heavy database usage. I would like to write most of my sql by myself but have only basic knowledge of web development. Both PHP and Python will be new languag...