php

How to make a custom template in WordPress work as a password protected page?

I'm building a page with a custom template. The thing is, I need this page to be password protected, or at least accessible to logged in users, but even if I set it as such (Private/Password protected) in the New Pages section in WordPress Administration, it won't display the menu entry nor the content (if Private) or it would show the ...

How do I log the raw HTTP headers with a PHP script?

I'm using a cURL script to send POST data through a proxy to a script and I want to see what raw HTTP headers the cURL script is sending. List of things I've tried: echo curl_getinfo($ch, CURLINFO_HEADER_OUT) gives no output. file_get_contents('php://input') gets some HTTP headers but not all. print_r($_SERVER) also gets some HTTP head...

PHP Excel - Correct format for strings / numbers beginning with zero?

Hi, I'm trying to use PHP to create a file containing a list of phone numbers. It's working OK however if the phone number begins with zero, the digit is dropped from the excel file. Does anyone know how to set the formatting correctly so that it remains in place? Any advice appreciated. Thanks. ...

Can I assign an array just by making it equal to another array?

I have an array $x with nonzero number of elements. I want to create another array ($y) which is equal to $x. Then I want to make some manipulations with $y without causing any changes to $x. Can I create $y in this way: $y = $x; In other words, if I modify $y created in the above shown way, will I change value of $x? ...

(PHP5) Extracting a title tag and RSS feed address from HTML using PHP DOM or Regex

Hi there, I'd like to get the title tag and RSS feed address (if there is one) from a given URL, but the method(s) I've used so far just aren't working at all. I've managed to get the title tag by using preg_match and a regular expression, but I can't seem to get anywhere with getting the RSS feed address. ($webContent holds the HTML o...

Is it possible to restrict how a method can be called in PHP?

Given that my class looks like this: class Methods{ function a(){ return 'a'; } function b(){ $this->a(); } function c(){ $this->a(); } } Is it possible to ensure that function a can only be called from function b? In the above example function c should fail. I could just incl...

MYSQL - sort a list, how to always have one result at the end?

I have a table with just as ID and a value. Let's say this list have 4 items, such as Apple,Banana, Zuchinni, and Other. I want to sort the list alphabetically, but always have 'Other' be the last option. Is there a way to accomplish this using a query? ...

Describe relative angles between points (like driving directions)

I have a list of points with x, y coordinates. I know how to get the distance between points with sqrt(pow($x2 - $x1, 2) + pow($y2 - $y1, 2)) and the angle between points with atan2(y1 - y2, x1 - x2). How can I calculate the relative angle between the points (left, right, straight)? So, if I'm at point 1, what is the relative direction...

Segmentation fault when accessing a PHP page

Sometimes when one of our Apache web servers is restarted, we experience segmentation faults when any PHP page is subsequently accessed. The following line is printed in the httpd error_log: [Wed Jun 16 10:59:33 2010] [notice] child pid 31513 exit signal Segmentation fault (11) There will be one of these lines for each PHP page that is...

PHPMailer echo's from successful sent email

Hello I finally got PHPMailer to work with Google but now I am finding out that I am getting this output to the screen after the message has been sent. SMTP -> FROM SERVER:220 mx.google.com ESMTP f34sm21891943qco.35 SMTP -> FROM SERVER: 250-mx.google.com at your service, [76.28.109.170] 250-SIZE 35651584 250-8BITMIME 250-AUTH LOGIN PLAI...

PHP XML - Inserting a XML node at a specific location

Hi Guys, I want to insert a node with children at a specific location in the XML file. How do I do it? For eg. If I have an XML like: <myvalues> <image name="img01"> <src>test</src> </image> <image name="img02"> <src>test</src> </image> <image name="img03"> <src>test</src> </image> </myvalues> I want to insert: ...

filling out a table horizontal and vertically with php and mysql

hey folks, I'm fairly new to PHP so am not sure how to do this. I have records in a database that link to images (profile pictures) that i want to display 5 along and 4 down. How would I do this? Thanks alot! Jonesy ...

XML + Xslt -> Xml with PHP

Hi, I know that there are really a mass of XML XSLT php merging threads at SO. But php specific i could not found what might my problem: $xml = new DOMDocument; $xml->load("f.xml"); $xsl = new DOMDocument; $xsl->load('test.xsl'); // init and configure processor $proc = new XSLTProcessor; $proc->importStyleSheet($xsl); // import xsl do...

problem with setting a cookieless domain

Here is the header from firebug that shows the scope of the PHP Session cookie: Set-Cookie PHPSESSID=f0e2dfe56cc78be718c8154ac80d1ae2; path=/; domain=pix-all.com But still the PHP Session cookie is been sent for any requests to static.pix-all.com Cookie PHPSESSID=f0e2dfe56cc78be718c8154ac80d1ae2; What could be the problem? ...

Grammar checking API?

Are there any APIs that check the grammar of a given string? If so can you give examples? ...

Unset an array element inside a foreach loop

I'm accessing an array by reference inside a foreach loop, but the unset() function doesn't seem to be working: foreach ( $this->result['list'] as &$row ) { if ($this_row_is_boring) { unset($row); } } print_r($this->result['list']); // Includes rows I thought I unset Ideas? Thanks! ...

PHP <<< (multi-line handler?) question

I have some code as follows: $query = <<<QUERY SELECT * FROM names WHERE create_date > date('Y-m-d H:i:s'); QUERY How can I put the date('Y-m-d H:i:s') in there without breaking out of the <<< statement? ...

mysql query results sorting

I am calling the results form a query to a list on my site based on if the item is "downtown_hosted". This works fine but I would now like to sort that list DESC, but can't seem to get the syntax correct. Below is what I have: $result_events = mysql_query("SELECT * FROM events WHERE downtown='downtown_...

pdf errors with php, apache2

Hi-- I'm seeing some strange behavior from some dynamically generated PDFs using the TCPDF library in PHP. Standard lamp stack-- however, if you try to open the PDF from Windows with Acrobat Reader, it gives an error that the "file is damaged and could not be repaired". From Mac, Linux, etc. the file works fine, and opens fine. It also ...

post selextbox values to php page in jquery

I am using jquery button click to post all the values in a selectbox to a PHP page, but this code does not seem to work. Can anyone please help? <script type="text/javascript"> $(function() { $("#btn1").click(function () { var arr= new Array; $("#target_select option").each (function () { // You ca...