Re: [PHP] getting the search words from a google query

2009-08-18 Thread kranthi
can you provide a sample URL that you have in your mysql database ?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Undefined Offset Error with Pagination and Sessions

2009-08-18 Thread kranthi
may be you can use a couple of var_dumps to see what's happening
behind the screens.


and... use a debugger like xdebug.. it'll be of help

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: PHP and CGI

2009-08-18 Thread kranthi
try adding

AddType application/x-httpd-php .pl --> or whatever extension your
perl script has

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: PHP and CGI

2009-08-18 Thread sono-io


On Aug 18, 2009, at 7:13 PM, Shawn McKenzie wrote:


I assumed that the problem was that he
knew PHP and he had downloaded a Perl cart and didn't know Perl.


	That's exactly the case.  I have been running my business on a Perl  
cart for the last 5+ years, and I can't switch to a PHP cart just  
yet.  I was just hoping to add some functionality with PHP.  Perl was  
much harder for me to grasp than PHP, and from what I can tell, you  
can't embed Perl in HTML as easy as you can with PHP, so I've switched  
languages.  I guess I was hoping for too much. =:(


Thanks,
Frank

P.S.  Does anyone know of a good Perl mailing list?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: PHP and CGI

2009-08-18 Thread Shawn McKenzie


Andrew Mason wrote:
> If you already have it written in Perl, I would recommend writing the
> rest of functionality in Perl.
>
>   
Please reply all.  I agree, but I assumed that the problem was that he
knew PHP and he had downloaded a Perl cart and didn't know Perl.

-Shawn

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] daemon without pcntl_fork

2009-08-18 Thread Lars Torben Wilson
2009/8/18 Per Jessen :
> Lars Torben Wilson wrote:
>
>> Again, that's not a daemon. If it is sufficient to run a background
>> process then that's fine, but that doesn't make it a daemon (although
>> it shares some things in common with a daemon). The background process
>> still has a controlling terminal (even if input and output have been
>> redirected), and a fully-implemented daemon will typically perform
>> other tasks which make it a good system citizen, such as: becoming
>> session leader, chroot'ing to / so that the filesystem it was started
>> from can be unmounted if necessary, and so on.
>
> Torben, you're really just splitting hairs - the OP didn't ask for the
> definition of "daemon', he just wanted a script to run continually as
> if it was a daemon.  Besides, I did also suggest using either setsid or
> openSUSEs startproc.

Thank you for the lecture. Your opinion of my post on this is quite
beside the point. If Jim needs a daemon, then he should probably use a
daemon coded the best way possible. If not, then that's fine too. As
you correctly pointed out, there are ways to fake it. I simply feel
that Jim should be made aware of potential drawbacks. That's perhaps
splitting hairs--it's also being thorough. Clients don't tend to
appreciate being told that a lack of thoroughness arose from a fear of
splitting hairs.


Regards,

Torben

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: PHP and CGI

2009-08-18 Thread Shawn McKenzie
sono...@fannullone.us wrote:
> I've searched high and low for an answer to this.  Hopefully someone
> here might know.  Can PHP be used under a CGI?  I tried to put the
> following code on one of my perl shopping cart pages but it doesn't work:
> 
>  echo "";
> for ($year = date("Y") ; $year <= date("Y") + 8 ; $year++) {
> echo "$year\n";
> }
> echo "";
> ?>
> 
>  It works fine on a .php page.  I know that SSI will not work under
> CGI, so maybe it's the same for PHP.  Is there anyway to get this to work?
> 
> Thanks,
> Frank

PHP can run under CGI, however you're asking about mixing PHP with Perl.
 CGI != Perl.  CGI is the interface that your scripts have to the
programs that run them (i.e. Perl or PHP, etc...).

I've never done it, but to have both Perl and PHP parsed in one file,
you'd have to configure Apache (or your webserver) to parse the file
using PHP and then Perl.  Not sure if it would do this sequencially though.

Another option may be to put the PHP in its own PHP file and then fetch
it into your Perl script.

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] PHP and CGI

2009-08-18 Thread Daevid Vincent
 

> -Original Message-
> From: sono...@fannullone.us [mailto:sono...@fannullone.us] 
> Sent: Tuesday, August 18, 2009 5:10 PM
> To: PHP General List
> Subject: [PHP] PHP and CGI
> 
>   I've searched high and low for an answer to this.  
> Hopefully someone  
> here might know.  Can PHP be used under a CGI?  I tried to put the  
> following code on one of my perl shopping cart pages but it doesn't  
> work:
> 
>  echo "";
> for ($year = date("Y") ; $year <= date("Y") + 8 ; $year++) {
>   echo "$year\n";
> }
> echo "";
> ?>
> 
>It works fine on a .php page.  I know that SSI will 
> not work under  
> CGI, so maybe it's the same for PHP.  Is there anyway to get this to  
> work?

Well, if you already have the page coded in Perl, why not just write those 5
lines in perl?!

It's a straight up for loop basically and some print statements. You're not
hitting a database or using anything remotely PHP-esque there.

I'm not so sure you can just mix and match parsers. I recall years ago some
talk of doing this, but I think it's just so rare and really impractical
that it's not worth setting up even if you can do it with some Apache magic.
Stick to one pre-processor language. Either all PHP or all Perl but not
both.

Daevid.

"Some people, when confronted with a problem, think 'I know, I'll use XML.'"
Now they have two problems. 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] PHP and CGI

2009-08-18 Thread sono-io
	I've searched high and low for an answer to this.  Hopefully someone  
here might know.  Can PHP be used under a CGI?  I tried to put the  
following code on one of my perl shopping cart pages but it doesn't  
work:


";
for ($year = date("Y") ; $year <= date("Y") + 8 ; $year++) {
echo "$year\n";
}
echo "";
?>

	 It works fine on a .php page.  I know that SSI will not work under  
CGI, so maybe it's the same for PHP.  Is there anyway to get this to  
work?


Thanks,
Frank

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Really quick try/catch question

2009-08-18 Thread Nathan Nobbe
On Tue, Aug 18, 2009 at 1:29 PM, Brian Dunning wrote:

> I have a "new SimpleXMLElement()" that is occasionally throwing:
> 'Exception: String could not be parsed as XML'
>
> Will this catch it when it happens, or am I missing something?
>
> function domyfunction() {
>// This does some stuff to exit the script gracefully
> }
>
> try {
>$xmlobject = new SimpleXMLElement($xml);
> } catch($e) {
>domyfunction($e);
> }


you need to add the name of the class you want to capture, or an ancestor
thereof,

try {
  ..
} catch(Exception $e) {
 ..
}

-nathan


[PHP] Really quick try/catch question

2009-08-18 Thread Brian Dunning

I have a "new SimpleXMLElement()" that is occasionally throwing:
'Exception: String could not be parsed as XML'

Will this catch it when it happens, or am I missing something?

function domyfunction() {
// This does some stuff to exit the script gracefully
}

try {
$xmlobject = new SimpleXMLElement($xml);
} catch($e) {
domyfunction($e);
}



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] DB Question | A hotel reservation scenario

2009-08-18 Thread Floyd Resler
I would create a room history table that contained three fields: room  
number, status, date stamp.  Each time the status of a room changes  
insert a new record into the table with the current status and date/ 
time.


Take care,
Floyd

On Aug 18, 2009, at 10:45 AM, Behzad wrote:


Dear list,
e-Greetings!

I'm faced with an interesting and challenging problem.

Consider a database, designed for a hotel.
At any given time, each room has a different status: It's Busy or  
Reserved,

or Free.

It's easy to retrieve number of Free rooms at the current time.
But how can I count the number of rooms that were busy during the  
last week

?

I would appreciate if you take a brief moment of your time and share  
your

opinion.

Thank you in advance,
-b



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Undefined Offset Error with Pagination and Sessions

2009-08-18 Thread Ralph Deffke
by having a quick look on it, u have to work on a session base? otherwise it
could be done by the post data only. I'm trying to avoid to work on the
session, because it makes live a bit easier. if u can try.

I'm telling this, because as u metioned to unset the session stuff is wierd
and I wouldn't trust the session vars any more anyway.

ralph_def...@yahoo.de


""Miller, Terion""  wrote in message
news:c6b04cb6.49e1%kmille...@springfi.gannett.com...
Formatted as PHP
http://pastebin.ca/1534058


and a note before I get chewed about the weird setting and unsetting at the
top with the sessions...because believe I see it...but if you take the
unset() out..nothing works, I can't figure that out and maybe that is a
blatent thing I'm missing (prob) but I know that checking if a sesion is set
then immediately unsetting it is not logical, and I tried putting it like if
isset else unset but same results, nothing work all variables error'd  out
as undefined.



On 8/18/09 11:49 AM, "Miller, Terion"  wrote:

Hi Folks, after days of trying lots of different things, I'm must grovel to
the list and post my problem...which is I am unable to get my pagination to
work, it seems to not carry the session to the next page and I get the
"undefined offset error"

The page code is posted here since my email client seems to mess up the code
formatting: http://pastebin.ca/1534024

Thanks to any and all who have a look.
Terion


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Undefined Offset Error with Pagination and Sessions

2009-08-18 Thread Miller, Terion



On 8/18/09 12:44 PM, "Shawn McKenzie"  wrote:

Miller, Terion wrote:
> Hi Folks, after days of trying lots of different things, I'm must grovel to
> the list and post my problem...which is I am unable to get my pagination to
> work, it seems to not carry the session to the next page and I get the
> "undefined offset error"
>
> The page code is posted here since my email client seems to mess up the code
> formatting: http://pastebin.ca/1534024
>
> Thanks to any and all who have a look.
> Terion
>

First off the $_SESSION array doesn't exist because you haven't started
the session with session_start().

--
Thanks!
-Shawn
http://www.spidean.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Oh Sorry for confusion but yes the session_start() is at the very very top of 
the page along with a bunch of other data connection stuff, I just didn't 
include in the troublesome script.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Undefined Offset Error with Pagination and Sessions

2009-08-18 Thread Shawn McKenzie
Miller, Terion wrote:
> Hi Folks, after days of trying lots of different things, I'm must grovel to
> the list and post my problem...which is I am unable to get my pagination to
> work, it seems to not carry the session to the next page and I get the
> "undefined offset error"
> 
> The page code is posted here since my email client seems to mess up the code
> formatting: http://pastebin.ca/1534024
> 
> Thanks to any and all who have a look.
> Terion
> 

First off the $_SESSION array doesn't exist because you haven't started
the session with session_start().

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Undefined Offset Error with Pagination and Sessions

2009-08-18 Thread Miller, Terion
Formatted as PHP
http://pastebin.ca/1534058


and a note before I get chewed about the weird setting and unsetting at the top 
with the sessions...because believe I see it...but if you take the unset() 
out..nothing works, I can't figure that out and maybe that is a blatent thing 
I'm missing (prob) but I know that checking if a sesion is set then immediately 
unsetting it is not logical, and I tried putting it like if isset else unset 
but same results, nothing work all variables error'd  out as undefined.



On 8/18/09 11:49 AM, "Miller, Terion"  wrote:

Hi Folks, after days of trying lots of different things, I'm must grovel to
the list and post my problem...which is I am unable to get my pagination to
work, it seems to not carry the session to the next page and I get the
"undefined offset error"

The page code is posted here since my email client seems to mess up the code
formatting: http://pastebin.ca/1534024

Thanks to any and all who have a look.
Terion


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: DB Question | A hotel reservation scenario

2009-08-18 Thread Behzad
Based on Ashely's reply, I created the following scheme:

The table "Rooms" has the following fields.

- id (PK)
- room_no (varchar)
- status (ENUM: Busy, Reserved)

the other table, "RoomLogs", has the following fields:
- room_id (the id from above table)
- status_modified_on (date)
- status (enumerated value - 'busy','reserved')

The problem is to generate a graph to display status of rooms in different
periods of
time (daily, weekly, monthly).
X Axis = Status (Busy, Reserved)
Y Axis = Number of rooms with a certain status (the last status for each
room makes sense)


On Tue, Aug 18, 2009 at 8:13 PM, Ralph Deffke  wrote:

> to answer this is in fact not possible on the base of information u give.
>
> I dont think there is a general db outlay for hotels. it depends how the
> "booking" tables are designed.
>
> does the application excist or u are doing a new one?
>
> if it excist, have a look how the availability of a room is calculated and
> then go from there. it would be the same calculation, just with backwards
> dates.
>
> hope that helps
>
> ralph_def...@yahoo.de
>
>
>
> "Behzad"  wrote in message
> news:470fa6660908180745i6bb6a442xd53d2c02fac7b...@mail.gmail.com...
> > Dear list,
> > e-Greetings!
> >
> > I'm faced with an interesting and challenging problem.
> >
> > Consider a database, designed for a hotel.
> > At any given time, each room has a different status: It's Busy or
> Reserved,
> > or Free.
> >
> > It's easy to retrieve number of Free rooms at the current time.
> > But how can I count the number of rooms that were busy during the last
> week
> > ?
> >
> > I would appreciate if you take a brief moment of your time and share your
> > opinion.
> >
> > Thank you in advance,
> > -b
> >
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Kind regards,
-behzad


[PHP] Undefined Offset Error with Pagination and Sessions

2009-08-18 Thread Miller, Terion
Hi Folks, after days of trying lots of different things, I'm must grovel to
the list and post my problem...which is I am unable to get my pagination to
work, it seems to not carry the session to the next page and I get the
"undefined offset error"

The page code is posted here since my email client seems to mess up the code
formatting: http://pastebin.ca/1534024

Thanks to any and all who have a look.
Terion


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: DB Question | A hotel reservation scenario

2009-08-18 Thread Ashley Sheridan
On Tue, 2009-08-18 at 21:02 +0430, Behzad wrote:
> Based on Ashely's reply, I created the following scheme:
> 
> The table "Rooms" has the following fields.
> 
> - id (PK)
> - room_no (varchar)
> - status (ENUM: Busy, Reserved)
> 
> the other table, "RoomLogs", has the following fields:
> - room_id (the id from above table)
> - status_modified_on (date)
> - status (enumerated value - 'busy','reserved')
> 
> The problem is to generate a graph to display status of rooms in different
> periods of
> time (daily, weekly, monthly).
> X Axis = Status (Busy, Reserved)
> Y Axis = Number of rooms with a certain status (the last status for each
> room makes sense)
> 
> 
> On Tue, Aug 18, 2009 at 8:13 PM, Ralph Deffke  wrote:
> 
> > to answer this is in fact not possible on the base of information u give.
> >
> > I dont think there is a general db outlay for hotels. it depends how the
> > "booking" tables are designed.
> >
> > does the application excist or u are doing a new one?
> >
> > if it excist, have a look how the availability of a room is calculated and
> > then go from there. it would be the same calculation, just with backwards
> > dates.
> >
> > hope that helps
> >
> > ralph_def...@yahoo.de
> >
> >
> >
> > "Behzad"  wrote in message
> > news:470fa6660908180745i6bb6a442xd53d2c02fac7b...@mail.gmail.com...
> > > Dear list,
> > > e-Greetings!
> > >
> > > I'm faced with an interesting and challenging problem.
> > >
> > > Consider a database, designed for a hotel.
> > > At any given time, each room has a different status: It's Busy or
> > Reserved,
> > > or Free.
> > >
> > > It's easy to retrieve number of Free rooms at the current time.
> > > But how can I count the number of rooms that were busy during the last
> > week
> > > ?
> > >
> > > I would appreciate if you take a brief moment of your time and share your
> > > opinion.
> > >
> > > Thank you in advance,
> > > -b
> > >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
> 
You should add a 'free' type to the first table (just the first one) to
indicate whether a room is free or not also.

As for counting the number of rooms that were busy last week, think
about what that actually means. Does that mean all rooms that were busy
the entire time, all rooms that were busy at least part of the time
during that week, etc?

Thanks,
Ash
http://www.ashleysheridan.co.uk




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] getting the search words from a google query

2009-08-18 Thread Ashley Sheridan
On Tue, 2009-08-18 at 21:23 +0530, MURTUZA KUTUB Â  wrote:
> hey,
> 
> i am a beginner at php and i need your help.
> 
> i have a list of urls visited on a particular day in mysql database.
> using php i find out all the websites that have a google search.
> now i need to strip apart the google query from the entire url.
> i think parse function is used for it but i am not sure how it is used etc.
> 
> if possible plz send me a small snippet as an example.
> 
> cheers.
> 
> -
> Bits-Pilani Goa Campus (http://www.bits-goa.ac.in)
> 
> 
Have you looked at the URL strings themselves? You can see that with a
Google query, the search words appear as part of the q= part of the
string.

Thanks,
Ash
http://www.ashleysheridan.co.uk




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] getting the search words from a google query

2009-08-18 Thread MURTUZA KUTUB  
hey,

i am a beginner at php and i need your help.

i have a list of urls visited on a particular day in mysql database.
using php i find out all the websites that have a google search.
now i need to strip apart the google query from the entire url.
i think parse function is used for it but i am not sure how it is used etc.

if possible plz send me a small snippet as an example.

cheers.

-
Bits-Pilani Goa Campus (http://www.bits-goa.ac.in)


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: DB Question | A hotel reservation scenario

2009-08-18 Thread Ralph Deffke
to answer this is in fact not possible on the base of information u give.

I dont think there is a general db outlay for hotels. it depends how the
"booking" tables are designed.

does the application excist or u are doing a new one?

if it excist, have a look how the availability of a room is calculated and
then go from there. it would be the same calculation, just with backwards
dates.

hope that helps

ralph_def...@yahoo.de



"Behzad"  wrote in message
news:470fa6660908180745i6bb6a442xd53d2c02fac7b...@mail.gmail.com...
> Dear list,
> e-Greetings!
>
> I'm faced with an interesting and challenging problem.
>
> Consider a database, designed for a hotel.
> At any given time, each room has a different status: It's Busy or
Reserved,
> or Free.
>
> It's easy to retrieve number of Free rooms at the current time.
> But how can I count the number of rooms that were busy during the last
week
> ?
>
> I would appreciate if you take a brief moment of your time and share your
> opinion.
>
> Thank you in advance,
> -b
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] DB Question | A hotel reservation scenario

2009-08-18 Thread Arno Kuhl
-Original Message-
From: Behzad [mailto:behzad.esl...@gmail.com] 
Sent: 18 August 2009 04:46 PM
To: PHP General Mailing List
Subject: [PHP] DB Question | A hotel reservation scenario

Dear list,
e-Greetings!

I'm faced with an interesting and challenging problem.

Consider a database, designed for a hotel.
At any given time, each room has a different status: It's Busy or Reserved,
or Free.

It's easy to retrieve number of Free rooms at the current time.
But how can I count the number of rooms that were busy during the last week
?

I would appreciate if you take a brief moment of your time and share your
opinion.

Thank you in advance,
-b
-

You get that information from the history table. I presume there is some
sort of a history table?

Cheers
Arno


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Help on pregreplace

2009-08-18 Thread Vladan Stefanovic
You should check out preg_quote() function which puts a backslash in front 
of characters (escapes them) that have a special meaning in regular 
expressions.


Regards,
Vladan Stefanovic


"Merlin Morgenstern"  wrote in message 
news:12.62.22194.004ba...@pb1.pair.com...

Hi there,

I am highlighting keywords with the help of pregreplace. This works great 
with one limitation. If the word that has to be replaced contains a slash, 
preg throws an error. So far I could not find a fix. Can someone help?


Here is the code:


   $pattern = "/\b($words)\b/is";
   $replace = 'style="background:#FF;color:#FC;">\\1';

   return preg_replace($pattern,$replace,$str);

Thank you in advance,

Merlin 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help on pregreplace

2009-08-18 Thread Tom Worster
On 8/18/09 10:56 AM, "Merlin Morgenstern"  wrote:

> 
> 
> Ashley Sheridan wrote:
>> On Tue, 2009-08-18 at 16:00 +0200, Merlin Morgenstern wrote:
>>> Hi there,
>>> 
>>> I am highlighting keywords with the help of pregreplace. This works
>>> great with one limitation. If the word that has to be replaced contains
>>> a slash, preg throws an error. So far I could not find a fix. Can
>>> someone help?
>>> 
>>> Here is the code:
>>> 
>>> 
>>> $pattern = "/\b($words)\b/is";
>>> $replace = '\\1';
>>> return preg_replace($pattern,$replace,$str);
>>> 
>>> Thank you in advance,
>>> 
>>> Merlin
>>> 
>> Well, a slash has a special meaning inside PHP strings, more so for
>> double quoted strings. Are you correctly escaping the slash as a double
>> slash so that it's not interpreted by the string as an escaped
>> character, as you will need to as the preg_replace will be interpreting
>> it as an escape sequence to match?
>> 
>> Thanks,
>> Ash
>> http://www.ashleysheridan.co.uk
>> 
>> 
>> 
> HI, replacing the delimiter slash by ~ solved the problem. Thank you

which means that words with ~ in them will fail. as Al pointed out,
preg_quote() is a more general solution. it escapes all tricky pcre
characters as well as the delimiter.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help on pregreplace

2009-08-18 Thread Merlin Morgenstern



Ashley Sheridan wrote:

On Tue, 2009-08-18 at 16:00 +0200, Merlin Morgenstern wrote:

Hi there,

I am highlighting keywords with the help of pregreplace. This works 
great with one limitation. If the word that has to be replaced contains 
a slash, preg throws an error. So far I could not find a fix. Can 
someone help?


Here is the code:


$pattern = "/\b($words)\b/is";
$replace = '\\1';
return preg_replace($pattern,$replace,$str);

Thank you in advance,

Merlin


Well, a slash has a special meaning inside PHP strings, more so for
double quoted strings. Are you correctly escaping the slash as a double
slash so that it's not interpreted by the string as an escaped
character, as you will need to as the preg_replace will be interpreting
it as an escape sequence to match?

Thanks,
Ash
http://www.ashleysheridan.co.uk




HI, replacing the delimiter slash by ~ solved the problem. Thank you

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] DB Question | A hotel reservation scenario

2009-08-18 Thread Bastien Koert
On Tue, Aug 18, 2009 at 10:45 AM, Behzad wrote:
> Dear list,
> e-Greetings!
>
> I'm faced with an interesting and challenging problem.
>
> Consider a database, designed for a hotel.
> At any given time, each room has a different status: It's Busy or Reserved,
> or Free.
>
> It's easy to retrieve number of Free rooms at the current time.
> But how can I count the number of rooms that were busy during the last week
> ?
>
> I would appreciate if you take a brief moment of your time and share your
> opinion.
>
> Thank you in advance,
> -b
>

query using the BUSY status as a parameter? But really you haven't
given enough to ascertain whether the structure is set to allow this
to happen


-- 

Bastien

Cat, the other other white meat

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] DB Question | A hotel reservation scenario

2009-08-18 Thread Ashley Sheridan
On Tue, 2009-08-18 at 19:15 +0430, Behzad wrote:
> Dear list,
> e-Greetings!
> 
> I'm faced with an interesting and challenging problem.
> 
> Consider a database, designed for a hotel.
> At any given time, each room has a different status: It's Busy or Reserved,
> or Free.
> 
> It's easy to retrieve number of Free rooms at the current time.
> But how can I count the number of rooms that were busy during the last week
> ?
> 
> I would appreciate if you take a brief moment of your time and share your
> opinion.
> 
> Thank you in advance,
> -b

Keep a table that lists all the rooms along with their current status

Keep another table that has these fields:
  * room_id (the id from above table)
  * status (enumerated value - 'busy','reserved')
  * start_date
  * end_date

Then you perform your query using a join of these two tables, within a
particular date range. I've left out 'free' from the second table
because there's no point updating the table for a period if a room is
not being used.

You could also have start_date and end_date as datetime fields, as every
hotel i've ever been in has a set time for check-in and another for
check-out.

Thanks,
Ash
http://www.ashleysheridan.co.uk




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Help on pregreplace

2009-08-18 Thread Al



Merlin Morgenstern wrote:

Hi there,

I am highlighting keywords with the help of pregreplace. This works 
great with one limitation. If the word that has to be replaced contains 
a slash, preg throws an error. So far I could not find a fix. Can 
someone help?


Here is the code:


   $pattern = "/\b($words)\b/is";

   $replace = '\\1';
   return preg_replace($pattern,$replace,$str);

Thank you in advance,

Merlin


best insurance

http://us2.php.net/manual/en/function.preg-quote.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] DB Question | A hotel reservation scenario

2009-08-18 Thread Behzad
Dear list,
e-Greetings!

I'm faced with an interesting and challenging problem.

Consider a database, designed for a hotel.
At any given time, each room has a different status: It's Busy or Reserved,
or Free.

It's easy to retrieve number of Free rooms at the current time.
But how can I count the number of rooms that were busy during the last week
?

I would appreciate if you take a brief moment of your time and share your
opinion.

Thank you in advance,
-b


Re: [PHP] daemon without pcntl_fork

2009-08-18 Thread Per Jessen
Lars Torben Wilson wrote:

> Again, that's not a daemon. If it is sufficient to run a background
> process then that's fine, but that doesn't make it a daemon (although
> it shares some things in common with a daemon). The background process
> still has a controlling terminal (even if input and output have been
> redirected), and a fully-implemented daemon will typically perform
> other tasks which make it a good system citizen, such as: becoming
> session leader, chroot'ing to / so that the filesystem it was started
> from can be unmounted if necessary, and so on.

Torben, you're really just splitting hairs - the OP didn't ask for the
definition of "daemon', he just wanted a script to run continually as
if it was a daemon.  Besides, I did also suggest using either setsid or
openSUSEs startproc. 


/Per

-- 
Per Jessen, Zürich (28.5°C)


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] daemon without pcntl_fork

2009-08-18 Thread Lars Torben Wilson
2009/8/18 Per Jessen :
> Jim Lucas wrote:
>
>> Does anybody know how to use PHP as a daemon without the use of
>> pcntl_fork.
>>
>
> Sure. Just start it and leave it running.
>
>> I want to launch a daemon out of the /etc/rc.local when the system
>> starts.
>
> Yep, I do that all the time.
>
>> Anybody have any idea on how to do this?
>
> On an openSUSE system I would just use 'startproc', but elsewhere you
> could use setsid or nohup.  I.e. create your CLI script with a
> hash-bang, then start it
>
> nohup 

Re: [PHP] Help on pregreplace

2009-08-18 Thread Ashley Sheridan
On Tue, 2009-08-18 at 16:00 +0200, Merlin Morgenstern wrote:
> Hi there,
> 
> I am highlighting keywords with the help of pregreplace. This works 
> great with one limitation. If the word that has to be replaced contains 
> a slash, preg throws an error. So far I could not find a fix. Can 
> someone help?
> 
> Here is the code:
> 
>   
> $pattern = "/\b($words)\b/is";
> $replace = '\\1';
> return preg_replace($pattern,$replace,$str);
> 
> Thank you in advance,
> 
> Merlin
> 
Well, a slash has a special meaning inside PHP strings, more so for
double quoted strings. Are you correctly escaping the slash as a double
slash so that it's not interpreted by the string as an escaped
character, as you will need to as the preg_replace will be interpreting
it as an escape sequence to match?

Thanks,
Ash
http://www.ashleysheridan.co.uk




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Help on pregreplace

2009-08-18 Thread Merlin Morgenstern

Hi there,

I am highlighting keywords with the help of pregreplace. This works 
great with one limitation. If the word that has to be replaced contains 
a slash, preg throws an error. So far I could not find a fix. Can 
someone help?


Here is the code:


   $pattern = "/\b($words)\b/is";
   $replace = '\\1';
   return preg_replace($pattern,$replace,$str);

Thank you in advance,

Merlin

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: File or directory?

2009-08-18 Thread Ashley Sheridan
On Tue, 2009-08-18 at 13:30 +0300, Ollisso wrote:
> On Tue, 18 Aug 2009 13:00:37 +0300, Clancy  wrote:
> 
> > On Sun, 16 Aug 2009 23:24:05 -0600, george.lang...@shaw.ca (George  
> > Langley) wrote:
> >
> >> is_dir()
> >>
> >> 
> >>
> >> is_file()
> >>
> >> 
> >>
> > I specifically asked about FTP under PHP.  As far as I can see neither  
> > of these references
> > have anything to do with FTP.
> >
> 
> http://ca3.php.net/manual/en/wrappers.ftp.php
> 
> Supports stat()   No  As of PHP 5.0.0: filesize(), filetype(), 
> file_exists(),  
> is_file(), and is_dir() elements only. As of PHP 5.1.0: filemtime().
> 
> should work if PHP >= 5.0.0
> 
> -- 
> Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
> 
That only works if you have used the file wrapper functions to open the
remote FTP connection. Some FTP hosts don't support the use of these
wrappers I believe also.

What is wrong with using ftp_rawlist() ?

Thanks,
Ash
http://www.ashleysheridan.co.uk




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: File or directory?

2009-08-18 Thread Ollisso

On Tue, 18 Aug 2009 13:00:37 +0300, Clancy  wrote:

On Sun, 16 Aug 2009 23:24:05 -0600, george.lang...@shaw.ca (George  
Langley) wrote:



is_dir()



is_file()



I specifically asked about FTP under PHP.  As far as I can see neither  
of these references

have anything to do with FTP.



http://ca3.php.net/manual/en/wrappers.ftp.php

Supports stat()	No	As of PHP 5.0.0: filesize(), filetype(), file_exists(),  
is_file(), and is_dir() elements only. As of PHP 5.1.0: filemtime().


should work if PHP >= 5.0.0

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] HTML text extraction

2009-08-18 Thread Richard Heyes
HI,


> ...

The easy way (Back to the Future 2 anyone...?) would be to use
strip_tags() first:

http://uk.php.net/strip_tags

--
Richard Heyes
HTML5 graphing: RGraph - www.rgraph.net (updated 8th August)
Lots of PHP and Javascript code - http://www.phpguru.org

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: File or directory?

2009-08-18 Thread Clancy
On Sun, 16 Aug 2009 23:24:05 -0600, george.lang...@shaw.ca (George Langley) 
wrote:

>is_dir()
>
>
>
>is_file()
>
>
>
I specifically asked about FTP under PHP.  As far as I can see neither of these 
references
have anything to do with FTP.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] HTML text extraction

2009-08-18 Thread Ashley Sheridan
On Tue, 2009-08-18 at 01:37 -0700, leledumbo wrote:
> Usually, a website gives preview of its articles by extracting some of the
> first characters. This is easy if the article is a pure text, but what if
> it's a HTML text? For instance, if I have the full text:
> 
> 
>   bla bla bla
>   
> item 1
> item 2
> item 3
>   
> 
> 
> and I take the first 40 characters, it would result in:
> 
> 
>   bla bla bla
>   
> item
> 
> As you can see, the tags are incomplete and it might break other texts below
> it (I mean, other than this preview). I need a way to solve this problem.
> 
> -- 
> View this message in context: 
> http://www.nabble.com/HTML-text-extraction-tp25020687p25020687.html
> Sent from the PHP - General mailing list archive at Nabble.com.
> 
> 
You could do a couple of things:

  * Extract all the content and use strip_tags() to remove all the
HTML markup. In the example you gave it might look a bit odd if
the content suggests it was originally a list.
  * Access the extracted content through the DOM, and grab the
textual content you need using node values. That way, you can
limit it to a specific character count of content, and with a
bit of work, you can preserve the original markup tags too

Thanks,
Ash
http://www.ashleysheridan.co.uk




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] HTML text extraction

2009-08-18 Thread leledumbo

Usually, a website gives preview of its articles by extracting some of the
first characters. This is easy if the article is a pure text, but what if
it's a HTML text? For instance, if I have the full text:


  bla bla bla
  
item 1
item 2
item 3
  


and I take the first 40 characters, it would result in:


  bla bla bla
  
item

As you can see, the tags are incomplete and it might break other texts below
it (I mean, other than this preview). I need a way to solve this problem.

-- 
View this message in context: 
http://www.nabble.com/HTML-text-extraction-tp25020687p25020687.html
Sent from the PHP - General mailing list archive at Nabble.com.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] daemon without pcntl_fork

2009-08-18 Thread Per Jessen
Jim Lucas wrote:

> Does anybody know how to use PHP as a daemon without the use of
> pcntl_fork.
> 

Sure. Just start it and leave it running. 

> I want to launch a daemon out of the /etc/rc.local when the system
> starts.

Yep, I do that all the time.

> Anybody have any idea on how to do this?

On an openSUSE system I would just use 'startproc', but elsewhere you
could use setsid or nohup.  I.e. create your CLI script with a
hash-bang, then start it 

nohup