php

How do I make php handle file downloads of incomplete file?

So for example, I have a file being uploaded through ftp and file size changes. I do know the file size beforehand. So how would I make php to send it to clients browsers even if file is not finished uploading and waiting for file size to match before it finish buffering. The code below won't update the handle and doesn't see changes mad...

Updating a mySQL column

Hi guys, I would like to update a mySQL column, basically I would like to get a specific user in the DB, and then add the number I have to the number in the DB column. So say for instance user 12345 has 55 points, and I wanna add 25 points to his score, how would I go about updating the points column to reflect 80? Thanx in advance! ...

Python: Convert args to dict, like PHP's compact?

I want a function exactly like PHP's compact function. i.e., if I pass in a list of variable names: compact('var1','var2') it returns me back a dict: {'var1':var1, 'var2':var2} ...

CURL PHP AJAX Request

Hi Everyone! I'm new to using CURL, but I have successfully got it to submit ordinary forms in the past. I'm working with a website that uses an AJAX Request to perform a login, I can get the form to fill out the username and password but since the login button is actually a link I can't get the form to submit, is there some other way ...

Count how many times functions echo a statement.

I have a function that calls two other functions: class myClass{ function myFunc(){ for($i=0;$i<500;$i++){ $this->func1(); $this->func2(); } } function func1(){ // Does some stuff // echos statements, and can vary the amount of echoed statements while($so...

htaccess : make directories exceptions from auto_prepend?

Is there a way to make my auto_prepend command ignore my includes/ and ajax/ directories? I can write regular expressions easily it's just knowing how to markup the conditional statements... # choose which files are mother files (aka not includes or ajax) # add dochead to these files {some kind of regex conditioon here } php_value auto...

Character encoding issue between different versions of PHP, Apache and MySQL.

I recently converted an old MySQL database stored as latin1_swedish_ci to utf8_general_ci. I've now got the the HTTP header specifying UTF-8, the HTML tag on the page, and the data in the database is correctly encoded as utf8_general_ci. It all works fine on my testing server, so I upload the updated HTML files and PHP scripts to the ...

simple php SoapClient example for paypal needed

Could I get a simple example of using php's SoapClient class to make an empty call to paypal with nothing but the Version number? I have the correct WSDL url and server url so that's not what I need help with.. This is what I have: public function SOAPcall($function, $args=array()) { $args['Version'] = '63.0'; $args = new Soap...

Pattern for Wrapping Shell Commands in a Class

Despite its inadvisability, using PHP's shell commands to interact with non-php system commands remains a common way of quickly achieving certain results in web applications. Has anyone abstracted out the common use cases into a class library (something in Zend maybe?) that offers a more sane/common way of handling this? Every time I en...

adding an element to multidimensional array when within foreach loop (PHP)

Hi I'm trying to check if a certain category is allready selected by looping through an array of categories also I want to add another element to the array whci is just a bit to indicate is the category selcated my categories array looks like this 0=>array(category_id=>12,category_name=>"blogger") 1=>array(category_id=>13,category_na...

PHP Includes in Ruby on Rails?

Ive been learning PHP and tried to get into RoR and the two are always compared.My question is, is there a PHP include equivalent for Ruby on Rails. To me the ability to include PHP files is it's most valuable feature. ...

Populate a second DropDownList based on a selected value fron other DropDownList

Hi! I’m trying to link two dropdownlist depending on the value you select from the first dropdownlist. I don’t have any idea how to do this, so if you guys can point me in the right direction that would be great. What I want to do is select a value from the first dropdownlist and depending on its value show some options in the second dr...

[PHP] set the upload_tmp_dir but file no where to be found

I have a few image upload scripts and wordpress blog as well. I think the client tried to upload a 3mb+ images or so and since then everythings stopped working, to further inspection and adding error handlers i found out that it was UPLOAD TEMP DIR not FOUND i cant touch the ini file, its shared hosting but i can create a local ini fil...

php Contact Form on website and reply-to email

I have a PHP Contact form on a site I am hosing on our mediatemple grid server that was made with Rapidweaver. It works well except that the email it generates to our [email protected] is sent as [email protected]. I think the server is just using the trash/blackhole address. Any way to adjust my php or better yet, the server...

How do you use autocomplete for thousands of entries?

Is there a way to setup autocomplete in PHP/jQuery that can quickly run through thousands of rows in a database? I have a job board where the user enters his/her college - and I want to offer autocomplete. Problem is, there are 4,500 colleges in the united states and a seems like an awful solution. Is there a good way to both make th...

backing up MySQL database on the fly

Hi, i've programmed a mysql backup system for my CMS which dumps all the DB data and structure into a gzipped .sql file: $filename = DB_NAME.'_'.date('Y.m.d_H\hi_(s.'.round(microtime()*100,0).')').'.sql.gz'; exec('mysqldump --default-character-set=UTF8 --opt --compress --host='.DB_HOST.' --user='.DB_USER.' --password='.DB_PASS.' '.DB_NA...

Open .bat file in php..

Hello, I want to make an online php hexeditor, where the user uploads a file, the server performs a specified hexedit on it, and then the new file is saved on the server. I was thinking that I should write a .bat file that opens a hex editor on windows, performs the specified actions, then returns the new file. I could use the php functi...

Suggested design for submitting a table of data in PHP

Hi I'm looking for suggestions on how best to handle the submission of a database table. So far, I've generated the repeating rows data like so: <table border=1> <tr> <th>Phone Number</th> <th>Prefix CallerID with</th> <th>Seconds to ring before<br/>reaching voicemail</th> <th>Voice mailbox<br/>extension number</th> <th>Not...

How do I extract images from Google Images based on user input and place them on a page?

Hello all, I'm new to web programming, but I had an idea I could use as an instructional tool, and I was hoping I could get some guidance. Here's my idea: I want to have some form that takes the data entered by the user, submits each word in the form to google images, and retrieves the first image returned by Google Image Search. Eac...

Simple Templating Method in PHP

I'm trying to wrap my head around the best way to do a templating system for my PHP CMS. I'm a little stuck and so I'm looking for a few suggestions or ideas. Here is my desired setup: Each page is composed of various widgets (or content blocks, if you prefer). Each widget has an MVC architecture, with the View being simple, composed of...