$match_expression = '/<a href="look.php\?id=(.*)" title="Look page: (.*)">(.*)<\/A>/';
$radompgr = preg_match_all($match_expression,$q2,$match, PREG_SET_ORDER);
if($radompgr == TRUE){echo "found $radompgr<br>";}else{echo "not found $radompgr<br>";} //found
for ($i = 0; $i < count($match); $i++) {
$mathcas = $match[$i][1];
$rado...
I am trying to implement the Ajax feature in the comments section of my blog. I have downloaded prototype-1.6.0.3.js and have placed it in the js folder inside webroot.
I have made the following changes in the layout file(default.ctp)
$javascript->link(array('prototype'));
Also, following code has been added to controllers
var $helpe...
I'm working on setting up caching for my site, but am having difficulty testing whether the caching is working properly or not. I've got the following in my controller:
public function read($id, $slug = null)
{
$this->cache = Cache::instance();
$story = $this->cache->get("story".$id);
if (!$story) {
$story_model = new Story_M...
Hey!
My script consists of two parts.
The first part generates HTML page.
The second part loads a resourse from the net and saves it into a file.
Loading is a long operation and can take up to 10 seconds.
The first and the second parts are completely indepenent (loading has no impact on the look of the page).
At the end of the first pa...
Hi all!
I'm making a website which allows people to upload files, html pages, etc... Now I'm having a problem. I have a directory structure like this:
-/USERS
-/DEMO1
-/DEMO2
-/DEMO3
-/etc... (every user has his own direcory here)
-index.php
-control_panel.php
-.htaccess
Now I want to disable PHP, but enable Server-si...
I know this is not exactly reflection, but kind of.
I want to make a debug function that gets a variable and prints a var_dump and the variable name.
Of course, when the programmer writes a call to the function, they already know the variable's name, so they could write something like:
debug( $myvar, 'myvar' );
But I want it to be qui...
Apologies if this has already been answered many times, but I was unable to find the answer and I was flummoxed.
I have a mysql query which seemingly outputs the result I want when I run it in the database - however when I run the query through PHP, it does not output correctly.
In the database, dates are stored like this:
2009-08-13T...
Hi,
I need to load a PHP file into a variable. Like include();
I have loaded a simple HTML file like this:
$Vdata = file_get_contents("textfile.txt");
But now I need to load a PHP file.
...
How would I sort the following CSV file using PHP? I would like to sort by last name. Do I use regex somehow to get the first letter in the last name? Any help is appreciated
Here is an excerpt of my CSV file - with a ";" delimiter between names and addresses
John C. Buckley, M.D.;123 Main Street, Bethesda MD 20816
Steven P. Wood;34...
Hello there,
I completely have no idea how to do this as I am not a regexp expert..
But I wanted to search and count a specified CASE-INSENSITIVE text in a long string, for example:
the function:
int count_string ( string $string_to_search, string $input_search )
example usage and result:
$my_string = "Hello my name is John. I love...
Hi all,
I'm trying to determine the best way of deploying new versions of an established web application. In the past, I've done it a couple different ways but this time we're looking to do something a little different/better.
We're using development/staging/production servers. After the development is done and the basic functionality...
I almost always have a PHP resize script (using GD) in websites for my clients. No matter how many times I tell them to resize their huge 7MP images from their digital camera before uploading them, they still never do it. The result is an "Out Of Memory" error from the server, and the image doesn't get resized, because the original ima...
Hi guys,
I am trying to implement a password reset functionality on my company website where if a user needs to reset her password, she can click on a link and a new, randomly generated password will be sent to her inbox.
I am using the PHP mail() function. Now, I am running PHP5 on an Ubuntu machine. In php.ini I have declared SMTP as...
On my homepage I have a list of posts, and at the top I want to show only the most recent "sticky" post, followed by the rest of the posts. Is there a way to achieve this?
Bonus points for only using one query_posts().
(I know how to do it using two query_posts(), but I'm looking for a less taxing solution.)
...
Hi all!
I'm making an MSN client in PHP, which makes a persistent socket connection to one of Microsoft's servers:
//Connect to second server
$server2 = explode(":", $xfr[3]);
$socket2 = pfsockopen($server2[0], (int)$server2[1], $errno, $errstr, 999999);
$_SESSION["socket"] = $server2;
echo '<b>Connected to 2nd server.</b><br />';
Th...
Hi.
I have two tables with the following structure:
table name: friends
uid (PK)(FK)
friend_id (PK)(FK)
table name: posts
post_id (AI)(PK)
post_text
uid (FK) //poster id
I'd like to select posts that were only made from friends of user x.
My inital plan was to use the following code:
SELECT posts.post_text INNER JOIN friends ON po...
using PHP and MySQL
i have grabbed an array of facebook user ids from facebook.
Now i want to find the corresponding username in my application for this array.
Clearly in my application the user table contains unique username and unique fb_uid values.
my rudimentary understanding oof programming led me to 2 ways:
1) use a loop and r...
I need help with regular expressions. What I'm looking for is a regex that looks for link-tags like this:
<link rel="stylesheet" href="style.css" type="text/css">
Irrespective of where href="" is positioned, I would like to look it up in the link-tag and put a variable named $url in front of style.css with a / following. If it finds ...
<!-- MEMCACHE empty -->
The above is now causing issues for a script as it is now placed at the top of the XML files I'm trying to remotely access. simpleXML doesn't like the fact the XML file is no longer well formed. I tried escaping the errors but that didn't seem the do the trick. Can anyone point me in the direction on how ...
A friend of mine is getting this error on ALL of her websites. They are all on the same server, externally hosted.(the hosting company says they cant help with scripting problems)
Each site even gives the exact some line number, but they all use different Index.php files. I am a bit stumped here, has anyone seen anything like this befor...