php

PHP: how to stop ignore_user_abort, is it a good solution for long run program

let say i have send email program which need to run arround 7 hours. but i cant open the browser for 7 hours beside cronjob, ignore_user_abort() will it be a solution? will the script stop when all email has sent and the program has finish the loop? or it will keep eating the server memory? some people said u may need to add some ou...

How to commit on a Google code branch?

How do I commit to a Google code Subversion branch by using the TortoiseSVN thingy? Apparently I am having a problem with it because TortoiseSVN is asking for a username and password. I input the email address that I used to create the project and the corresponding password for it and it didn't work. Update: Great, I was able to commi...

what is the best way to parse big JSON file and insert into database using php?

I have this huge JSON file. Currently the way I am using it is: Read the entire contents into a string Do json_decode, get the array Loop through the array one record at a time and build my SQL insert statement Problem is, the code is ugly. Also, some of the objects in these arrays are themselves arrays, and not all records contain...

PHP: Zend_Layout: Where to write business logic?

Hi, On most project I use multiple layout scripts. Sometimes I need some data in my layouts that are layout-specific, instead of page-specific. Which layout gets used though, IS page-specific. So the bootstrap or actioncontroller would be good places to select a layout. But IMHO they would not be good places to inject the data a parti...

PHP Get File Name Without File Extension

I have this code: function ShowFileExtension($filepath) { preg_match('/[^?]*/', $filepath, $matches); $string = $matches[0]; $pattern = preg_split('/\./', $string, -1, PREG_SPLIT_OFFSET_CAPTURE); if(count($pattern) > 1) { $filenamepart = $pattern[count($pattern)-1][0]; preg_match('/[^?]*/', $fil...

Get value from constructor to a function in php class.

Hello, i have a class like: class List_PendingVerify extends Rs_List { public function __construct( $id ) { } protected function loadData( ) { } } Now i how could i get value of $id in loadData function ? so that i can be able to echo $id. Thanks. ...

Checking the value of all a loops value

Hi there, I have this loop in PHP that echoes out a table of results, <table cellspacing="0" cellpadding="3"> <tr> <td><b>Content Image Title</b></td> <td><b>Content Image Type</b></td> <td><b>Headline Image</b></td> <td><b>Content Image Belongs To</b></td> <td><b>Date Created</b></td> <!--<td><b>Uploaded By</...

copy mysql blob field from one database to the other

Hi! I happen to have a database with pictures stored as blob fields. Can't help it, it was the previous developer's choice. Now I need that data in a new site and the provider won't let me copy the data the easy way (file has become 11Mb big - won't upload that and I don't have shell access). So I thought I'd write a script that opens...

Which is the more efficient way to store this ordered pair in php?

Which of the following two data structures is "better"? array('key'=>array(1,2,3,4)) OR: array('key',array(1,2,3,4)) i.e., is it better to store the array as the second element in a two element array, or as the single element in an array with the key, 'key'. Assume that for my purposes, in matters of convenience, they are equivale...

Find the name of a calling var

Anyone has an idea if this is at all possible with PHP? function foo($var) { // the code here should output the value of the variable // and the name the variable has when calling this function } $hello = "World"; foo($hello); Would give me this output varName = $hello varValue = World EDIT Since most people here 'accus...

How to highlight multiple keywords in a mouthful in PHP?

Suppose there are 3 keywords, I don't want to do this kind of replace 3 times: a => <b>a</b> str_replace ( 'a', '<b>a</b>', $str) Is it possible to do it by one run? ...

Small Php and MySql problem

I have an array of ID:s, and the ID:s are in this format: Bmw_330ci_89492822 So it's a string! Now, I have this code to find whatever is in that array, in MySQL: ($solr_id_arr is the array I mentioned above, it contains string ID:s) ex: $solr_id_arr[0] outputs Bmw_330ci_89492822 $solr_id_arr_imploded = implode(", ", $solr_id_arr);...

Stock movement in PHP

I have a software in PHP and postgres that I use for invoicing. I am running a stock management system that I created. i am trying to create a stock movement page where I can see when a part came in, where it was issued and when and also when it was credited (if it was). I am running 5 tables for the stock. My main one is part2vendor, pa...

array_combine stuck when there is no value in first array

i m using array_combine() but it display error when in first array there is no value. how to get rid of this EDIT: First array Distance_Array Array ( [0] => ) School_ID_Array Array ( [0] => ) and i m using $Coverage_ Array=array_combine($School_ID_Array,$Distance_Array); which results Coverage_ Array Array ( [] =...

How to code in OO PHP?

How can I do this in OO PHP: A form ('in newstudent.php') asks the user to enter his name, course and year. After selecting 'Submit' button, the page will go to 'records.php' records.php - contains a table that displays all the records (columns: name, course, year) when the user selects 'Submit', the new record will be added to the dat...

Calculate date difference having a large range with PHP

Hi, I need to calculate the number of decades between 2 dates possible spanning form 1708 until today - the limitations are as far as I can gather are 1970/1901 within PHP native functions. Can anyone advise? Thanks! ...

PHP change the maximum upload file size

So I have a website hosted on a pc I have no access to. I have an upload form allowing people to upload mp3 files up to 30mb big. My server side script is done in php. Problem: everytime I try and upload a file I receive a error claiming the file exceeds the max size allowed. So now I need to increase the size. My research on the web sug...

How do I stop URLs that don't exist from resolving to a file?

I don't know if this is an Apache or PHP thing but if you go to either of: mysite.com/about mysite.com/about/ it will show the mysite.com/about.php file instead of a 404 error, because the directory does not exist. I am sure this is some setting, maybe an htaccess thing, any ideas? ...

How to increment count in the replacement string when using preg_replace ?

I have this code : $count = 0; preg_replace('/test/', 'test'. $count, $content,-1,$count); For every replace, I obtain test0. I would like to get test0, test1, test2 etc.. ...

JQUERY AJAX LOAD Function Error

I loaded a second.php file in first.php using jquery ajax load function $(".divclass").click(function(){ $("#divid").load('second.php', { id : $(this).attr('id') }); // alert("view Clicked"); }); the second.php loaded second php content in first.php file success. but second.php contains some jquery function... in second.php ...