php

How can I POST a file to a REST server without writing the file to disk with PHP?

I'm trying to send an XML file to a server as part of the POST method for an internal API. All the PHP documentation points to using the $postVars['file']='@/path/to/file.xml' to actually send the file. I want to send the file from a string, but it still needs to be sent as a file upload, not a string. Help? ...

Stop continuous table generation

Hello, I am trying to stop the data in the following table from continuing to repeat itself, as in looping on the same data, crashing the browser: Here's the query: $posts = mysqli_fetch_assoc(mysqli_query($db, "SELECT * from tbl_bugresponse WHERE bugid = $id ORDER BY time")); And here's the table code: <table width="100%" class="tb...

Keep login credentials server-side via PHP (safe and secure)

So I'm trying to write a php SOAP client that requires the user to pass their login credentials for the remote SOAP server. Here is the set-up/dilemma: User logs into local site using local credentials and goes to page with SOAP client. User is now prompted for credentials for remote Soap server, which, by the way, are the same as the ...

Is there a way to change PHP core value (allow_url_fopen) inside PHP script?

Is there a way to change PHP core value "allow_url_fopen" in the PHP script? On my hosting it is set to 'off' and I need it 'on'. ...

Debugging Wordpress with E_STRICT error reporting

Hi, I have set error reporting in my development environment to E_STRICT by adding to the top of my wp-config.php file: ini_set( 'error_reporting', E_STRICT ); This shows many places where return values are passed by reference, eg $wp_the_query = &new WP_Query(); throws the error Strict standards: Assigning the return value of new by r...

Load PHP code in PHP for delayed + parametered execution?

Hi, i have two PHP files: template.php template.html.php The first is the class definition for Template. The second contains an actual HTML-based template, however with PHP constructs (hence the .PHP extension). I'd call this a hybrid html/php file. Is it possible to create some function in the Template-class (special_in...

How can I sort by column header if clicked on and then sort in reverse order when clicked on again?

I have a table of data that is dynamically being brought in with PHP. I have two Column Headers - Name and Price I am looking for a php script that lets me sort the data by clicking on one of the Column headers, and then when the user clicks on it again, I want it to sort the data in the reverse order. Or if the user clicks on the other...

Problems uploading a file in php

I am trying to upload a file to a sever using PHP. I cannot get it to work. Here is the code: if( isset($_POST['Upload']) ) { //size condition if ( $_FILES['uploaded']['size'] > 350000) { $mesg = "Your file is too large.<br>"; exit; } if( move_uploaded_file($_FILES['uploaded']['tmp_name'], "upload/" . ...

Get entire URL, including query string and anchor

Is there a way to get the entire URL used to request the current page, including the anchor (the text after the # - I may be using the wrong word), in included pages? i.e. page foo.php is included in bar.php. If I use your solution in foo.php, I need it to say bar.php?blarg=a#blahblahblah ...

Generic Declarative Expression Builder in PHP

Folks, I'm looking to build a piece of PHP5 UI that I'm pretty sure is common to a bunch of applications. Basically, it's an expression builder that allows users to specify expressions combined through logical operators (AND/OR), like this: FieldX > 3 AND FieldY = 5 FieldY = "bob" and FieldZ is not null FieldX > '5/23/2007' OR (Field...

CakePHP Auth Component "login" Method Failure in IE8 + Safari

I have a method in users_controller.php of my CakePHP project which is used to remotely log a user in through an AJAX call on a WordPress site. The method works flawlessly when called through Firefox, but when I attempt to call it either via AJAX or directly from the browser in IE8 or Safari, it simply will not log in. The Auth->login() ...

Why are my arrays showing up as 0 in php?

I'm trying to make a file that creates a array of 3 strings, than randomly displays one of the three 5 times. Can someone tell me what I'm doing wrong? <?php $pk[0] = "PK Fire!<br/>"; $pk[1] = "PK Thunder!<br/>"; $pk[2] = "PK Freeze!<br/>"; for($i = 0; $i < 5; $i++) Echo "" + $pk[rand(0,2)] + ""; ?> ...

PHP variable replacement

Is there any function which replaces params in a string? Something like this: Code: $format_str = "My name is %name."; /* this was set in a configuration file - config.php */ $str = xprintf($format_str, array('name' => 'Joe', 'age' => 150)); /* above is somewhere in main code */ ...

Retrieving MySQL records based on a variable set of points of comparison.

Let's say I have a MySQL table, people. Each record comprises a variety of properties, among these favourite_colour, country, and age_group. What I would like to do is retrieve records from this table by their similarity to a set of specific parameters. Given "Red", "United States", and "18-25", for example, the best results would be th...

How to make CodeIgniter file upload class accept all extensions?

Currently if I supply no extensions to the class it allows no extensions. I would like to allow all extensions. Is there any way to do this without hacking the core? ...

merge 2 Open source script?

I need some help on using two open sources scripts for a small project. The first one is an a URL shortener with image hosting function: http://bit.ly/18ZDo6 and the second is a pure image hosting script : chevereto (dot) com. The first script is object orientated code, and I'll like to know if it's a good approach or should I hire someb...

Problems with parent / inheritance in PHP

EDIT: I got this working now. I have updated the code: I've looked at a few examples in here, and they all look logical. But I can't get it to work. I have a class that extends my Data Access Layer (DAL). I would like to call parent class to retrieve DB results. What am I doig wrong? DAL class class DAL { protected $username; /...

Passing URL parameter with JavaScript

I have some JavaScript that creates Forward and Back buttons. However, I need to pass a parameter in the URL (?id=$idd): <a href="javascript:submitForm('mainForm','back');" title="Go back to the kit home page" style="float: left;"><img src="images/back.gif" alt="Go back to the kit home page" border="0" /></a> <a href="javascript:submitF...

How can I redirect every URL that's not requesting an JPEG or PNG image to index.php/x?

For example, I have an URL that looks for an image like this: http://example.com/img/foo.png http://example.com/img/interface/menu/bar.png http://example.com/static/users/avatars/small/3k5jd355swrx221.jpg I don't want to redirect those. They should just pass through. But then, I have URLs like this: http://example.com/reg...

Redirect if link reached from external site

I have a PHP page on a website that I'd like to be accessible only from another page on that website. If a user clicks a link to the page, or types the page's address, and does not come from the site's domain, I'd like the page to redirect the user to the index. Any ideas? ...