I want to create a news page that includes a snippet of the latest 3 filea created in the following directory structure:
So lets say I have the following files:
/news.php
/2010/the-latest-article.php
/2009/some-long-article-name.php
/2009/another-long-article-name.php
/2009/too-old-article-name.php
/2009/another-old-article-name.php
I...
I'm working on setting up credit card processing and needed to use a workaround for CURL, and the following code worked fine when I was using the test server (which wasn't calling an SSL URL), but now when I am testing it on the working server with https, it doesn't work ("failed to open stream").
function send($packet, $url) {
$ctx =...
hello, i'v been trying to implement merge sort under php. but seems unsuccessful :( couldn't find source of error. any kind of help is very much appreciated!
function merge_sort(&$input, $start, $end) {
if($start < $end) {
$mid = (int) floor($start + $end / 2);
merge_sort($input, $start, $mid);
merge_sort($in...
Hi all.
Let's say I have a server at www.myhost.com. From there by using php I want to retrieve the html document that the php file www.anotherhost.com/somefile.php produces. I also want to use php to do this. anotherhost is not on the same server as myhost.
I know that functions such as fopen, f_get_contents and file can do this by si...
I have tried following some tutorials and I get the concept of how the apps work, basicly they are in my case a php/mysql site that loads into facebook and gives me access to the userbase instead of needing my own userbase.
Here is what I am trying right now to show on the facebook application canvas page
/* initialize the facebo...
I know there is a lot of discussion for years on best methods of filtering data with PHP but I would like to go the whitelist approach in my current project.
I only want a user to be able to use the following HTML
<b>bold</b>
<i>italics</i>
<u>underline</u>
<s>strikethrough</s>
<big>Big size</big >
<small>Small size</small>
Hyperlin...
I have a website written in-house, using a 3rd party login mechanism.
Recently we've been required to maintain PCI compliance, and I made a lot of changes in the environment. Shortly after we noticed a problem with cookies. I've rolled back all of the changes except the more difficult one of moving from php 5.3 back to 5.2.11, or what...
I use the PHP library for Facebook Connect.
The library is used as follows:
$facebook->api_client->METHOD
Here's the documentation for how to unregister users from one's Connect page: Connect.unregisterUsers
So, actually, I have everything I need, haven't I? But I can't manage to unregister users, though. How must I do this?
$faceb...
Hello,
I have a PHP script on a domain (say example.com) and this domain has three subdomains:
a.example.com
b.example.com
c.example.com
IP addresses of this all this domains is xxx.yyy.zzz.ddd and domains differ only in last octet ("ddd" part). I think it's quite ordinary for subdomains.
My question is if this fact will improve th...
Hello...
So I'm working on a PHP project that needs to allow the user to import CSV files into MySQL. The CSV files contain a "column" with a unique ID... there are duplicates. Here is where the tricky part comes in... The duplicates need to go into a separate table and not into the main table.
I have written code to do this but there...
Hi, I'm curious to know what the syntax " : " mean in php I've seen it a couple of times but I can't seem to explain it to myself. Can you also use it in a sentence....or i mean, sample code?
**edit:
sorry folks, I was referring to the ternary operator. Thanks for the other entries as well. I didn't know what to call it at first, apolo...
In Java (well, Android's version at least) all objects have a getClass() method which returns the object's class and you can then call getSimpleName() to get the human-readable name of the object. This is great for logging. I'd like to be able to do something similar in a PHP program I've been working on. Is there any way to find out wha...
Basically this is a questionnaire, but that does not only ask Yes/No type of questions. There are questions that are asked in the form of a table. Here is an example of one of the step pages for the questionnaire:
The questionnaire allows for a client to save what they have entered, log out, come back at a later point in time and contin...
All the examples I see using mysqli_fetch_object use mysql_query(), I cannot get it to work with prepared statements. Does anyone know what is wrong with this code snippet, as fetch_object returns null.
$sql = "select 1 from dual";
printf("preparing %s\n", $sql);
$stmt = $link->prepare($sql);
printf("prepare statement %s\n", is_null($st...
Still on the PHP-OOP training wheels, this question may belong on failblog.org. =)
What are the benefits of method chaining in PHP?
I'm not sure if this is important, but I'll be calling my method statically. e.g.
$foo = Bar::get('sysop')->set('admin')->render();
From what I've read, any method which returns $this is allowed to be c...
Scenario:
I have a contact form on my web app, it gets alot of spam.
I am validating the format of email addresses loosely i.e. ^.+@.+\..+$
I am using a spam filtering service (defensio) but the spam scores returned are overlapping with valid messages. At a threshold of 0.4 some spam gets through and some customer's questions are wrong...
Hello all,
I have huge PHP script which I have been running on Apache 2.2.12 and I have recently upgraded to Apache 2.2.14. However, my PHP script doesn't work as it stops at a certain point all the time. I have been trying to work out what the difference is in these two Apache versions, I have looked at this CHANGELOG and have not been...
I have a website, with a user system. I want to integrate wordpress's user system into that website's, but I still want to use the website's register/login pages. I don't want anybody to be able to login or register using Wordpress's login or registration forms. Instead, when they're try to access the login/registration pages in Wordpres...
I save some important info in $_SESSION, not in $_COOKIE. So, my question, is it dangerous? Or hacker is not able to edit $_SESSION and I'm fine?
Thank you.
edited:
By the way, is it possible also to edit $_COOKIE? I heard yes, but if yes, then how?
...
All,
I have to request a URL which returns a JSON request. I am using PHP and CURL to do this. Currently it takes around 3-4 seconds for the request and response.
Following is the curl code
$ch = curl_init();
$devnull = fopen('/tmp/curlcookie.txt', 'w');
curl_setopt($ch, CURLOPT_STDERR, $devnull);
curl_setopt($ch, CU...