php

using PHP how to move local file to server without upload functionality

Guys I need ur help, I have a text file which contains a text like "c:/images/myimage.jpg" Now using PHP I want to move this local image file to somewhere on server. Is it possible? Please suggest! Thanks, Jaswant ...

Php PDO::bindParam data types.. how does it work?

Hi guys, im wondering what the declaration of the data type in the bind parameter (or value) is used for... I mean, i thougth that if i define a param like int, PDO::PARAM_INT, the param must be converted in int, something like $delete->bindParam(1, $kill, PDO::PARAM_INT); //should works like $delete->bindParam(1, (int)$kill); or at ...

Storing file structure in PHP

What is the best way to store a file structure, along with files, say from a Zip file? Currently each file is a row in the MySQL database, but obviously no structure can be read from that. I want to avoid storing a binary file. All files should be plain text. Each zip/file structure is private to the user whom submitted it. ...

[Apache] Unwanted mod_rewrite behaviour

I just did a fresh install of lamp stack on ubuntu and enabled the mod_rewrite module for my default website. What I want is something similar to the drupal's queries, when the whole query string is kept in one variable. For this purposes the following mod_rewrite code may be used: RewriteRule ^(.*)$ home.php?q=$1 [L,QSA] The problem ...

Why doesn't this mail message decode correctly?

I have this code. It's from the Zend Reading Mail example. $message = $mail->getMessage(1); // output first text/plain part $foundPart = null; foreach (new RecursiveIteratorIterator($mail->getMessage(1)) as $part) { try { if (strtok($part->contentType, ';') == 'text/plain') { $foundPart = $part; brea...

How to extend a helper in CodeIgniter?

I want to add some new functions to the core string helper which is found in system/helpers folder. I think there was a 'right' way to do this using MY_String_helper or something of that sort but I can't remember exactly how it was done. Any thoughts? ...

PHP startsWith() and endsWith() functions

I need two functions that would take a string and return if it starts with the specified character/string or ends with it. For example: $str='|apples}'; echo startsWith($str,'|'); //Returns true echo endsWith($str,'}'); //Returns true ...

PHP ltrim() and rtrim() functions

I need 2 functions that take a string and the number of chars to trim from the right and left side and return it. E.g: $str = "[test]"; $str = ltrim($str,1); //becomes test] $str = rtrim($str,1); //becomes test Thoughts? ...

Screenshot of current page using PHP

Duplicate: website screenshots using php Is it possible to take a screenshot of the current page using PHP? ...

how to identify the source table of fields from a mysql query

I have two dynamic tables (tabx and taby) which are created and maintained through a php interface where columns can be added, deleted, renamed etc. I want to read all columns simulataneously from the two tables like so;- select * from tabx,taby where ... ; I want to be able to tell from the result of the query whether each column came...

create superglobal variables in php?

Hello, is there a way to create my own custom superglobal variables like $_POST and $_GET? ...

How can access the root directory of a folder

recently i worked in a project. the project has one root directory named "Project".the "Project" directory has also two sub-directory named "project_a" and "project_b". the "project_b" directory has two more sub-directory named "project_b_1" and "project_b_2". when i am on a page which is contains "project_b_2" directory then how can i a...

What is considered the best practice to handle variables stored in a configuration file?

If I use a configuration file to store for example the sitename, database host, etc.. what is the best practice to handle this? $sitename="stackoverflow.com"; and then setting global $sitename in functions DEFINE(_SITENAME,"stackoverflow.com") function vars(){return array(sitename=>"stackoverflow");} ? I would love a technical expla...

Recursive cast from SimpleXMLObject to Array

I need to recursively cast a PHP SimpleXMLObject to an array. The problem is that each sub element is also a PHP SimpleXMLElement. Is this possible? ...

PHP: 'Dynamic' callback from inside/outside a class

Hi guys, we have a problem [cit.] I need to assign a callback dynamically within a class, in base of a variable param: my goal is to have just one class (and not a main class and many extender sub-class), and inside this class if a value is X, then the funcitonX must be used, if is Y, the functionY. I know i cant explain well, i hope m...

Handling Soap timeouts in PHP

I'm working on a project where I am verifying information from a user with a SOAP web service. I currently am taking care of errors assuming that I'm receiving responses from the web service, but also need to handle the edge cases of a service timeout or unavailability. In the case of a timeout or service unavailability, I need to prete...

Show/hide fields depening on select value

Hello, I am trying to show and hide a few form fields dependent on the value of one of my select fields, I am looking to use arrays to to hold what should be show and what should not be show for each select value, to save me from a massive switch statement, but cannot figure out to do it. I am using PHP and jQuery. Any help would be g...

convert PHP(JSON) to ASP code

Can someone convert below code to ASP format? <?php $data = ' [ { "A": "test", "B": "test", "C": "test" }, { "A": "test", "B": "test", "C": "test" } ] '; print($_GET['callback'] .'('. $data .')'); while I was testing cross domain restriction workaround, this code works fine with PHP server (of course)...

How do you run a .bat file from PHP?

Can anyone tell me how to execute a .bat file from a PHP script? I have tried - exec("C:[path to file]"); system("C:[path to file]"); nothing is working. Ive checked the PHP manuals and googled around but cant find a good answer. Anyone know where im going wrong? I'm running windows 2003 server and have successfully manually ran the ...

PHP MySQL Encoding Bug?

Heres my problem. I have a mysql table called quotes. In one of the rows, a quote contains the folloqing characters ‘ and ’ Now the row collation is utf8__unicode__ci When using MySQL Query Browser and PHPMyAdmin to retrive the rows the quotes come out as intended. How ever when i retrive them from the database using PHP and display ...