[PHP] Sockets

2002-10-07 Thread Asmodean

Hey everyone,

Does anybody know what the current support / functionality for PHP
with sockets is? According to the documentation, all the socket_
functions should be included in PHP >= 4.1.0. I'm currently running
4.2.1 and PHP doesn't seem to recognize these functions (socket_send,
socket_write, etc).

Anybody know if there's anything special I have to do to get it
working?

// Asmodean


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




Re: [PHP] Queries - Sometimes I need to use apostrophe, other times i don't

2002-07-17 Thread Asmodean

QUOTE//

When running a mysql_query, sometimes i need to have apostrophes
surrounding variables...other times i don't
 
example...
 
$query = "SELECT * FROM table WHERE id='$id'";
 
or
 
$query = "SELECT * FROM table WHERE id=$id";
 
...it kinda seems random when it wants apostrophes and when it doesn't
want them.
 
Any ideas?

//QUOTE

Use apostrophes when $id is a string.

// Asmodean
[EMAIL PROTECTED]


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




Re: [PHP] timer on sessions?

2002-07-17 Thread Asmodean

J> Not sure how to go about setting up a function to parse the date, hour,
J> minutes, seconds, take the seconds and register them in a session var, then
J> do a check on the session var (seconds) vs. the seconds var + 5*60 (or 5
J> minutes) to time out the session and force the user to log back in.  My
J> problem is finding the correct way to check the seconds in php.  Any help or
J> pointers is appreciated.
J> Jas

time() will give you a UNIX timestamp. Use it to do the math.

-- 
Best regards,
 Asmodeanmailto:[EMAIL PROTECTED]


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




Re[2]: [PHP] timer on sessions?

2002-07-17 Thread Asmodean

J> I am not able to test from this machine so please tell me if I am right or
J> wrong on this:
J> $tmp = time();
J> $tme = time() - 5*60;
J> session_register('tmp');
if ($tmp >>= $tme) {
J> echo 'Time has not reached 5 minutes, session still valid';
J> } else {
J> echo 'Timer has reached 5 minutes, you will need to log back in to
J> continue.'; }

J> "Asmodean" <[EMAIL PROTECTED]> wrote in message
J> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>> J> Not sure how to go about setting up a function to parse the date, hour,
>> J> minutes, seconds, take the seconds and register them in a session var,
J> then
>> J> do a check on the session var (seconds) vs. the seconds var + 5*60 (or
J> 5
>> J> minutes) to time out the session and force the user to log back in.  My
>> J> problem is finding the correct way to check the seconds in php.  Any
J> help or
>> J> pointers is appreciated.
>> J> Jas
>>
>> time() will give you a UNIX timestamp. Use it to do the math.
>>
>> --
>> Best regards,
>>  Asmodeanmailto:[EMAIL PROTECTED]
>>

Let's assume you've set your session timestamp (assume it's called
$session_time) to time() at the time of login. Now, in the script...

if ((time() + 300) > $session_time) {

}

This would be a check to see if the session is still valid. Timewise.

-- 
Best regards,
 Asmodeanmailto:[EMAIL PROTECTED]


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




Re[3]: [PHP] timer on sessions?

2002-07-17 Thread Asmodean

J>> I am not able to test from this machine so please tell me if I am right or
J>> wrong on this:
J>> $tmp = time();
J>> $tme = time() - 5*60;
J>> session_register('tmp');
if ($tmp >>>= $tme) {
J>> echo 'Time has not reached 5 minutes, session still valid';
J>> } else {
J>> echo 'Timer has reached 5 minutes, you will need to log back in to
J>> continue.'; }

J>> "Asmodean" <[EMAIL PROTECTED]> wrote in message
J>> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>>> J> Not sure how to go about setting up a function to parse the date, hour,
>>> J> minutes, seconds, take the seconds and register them in a session var,
J>> then
>>> J> do a check on the session var (seconds) vs. the seconds var + 5*60 (or
J>> 5
>>> J> minutes) to time out the session and force the user to log back in.  My
>>> J> problem is finding the correct way to check the seconds in php.  Any
J>> help or
>>> J> pointers is appreciated.
>>> J> Jas
>>>
>>> time() will give you a UNIX timestamp. Use it to do the math.
>>>
>>> --
>>> Best regards,
>>>  Asmodeanmailto:[EMAIL PROTECTED]
>>>

A> Let's assume you've set your session timestamp (assume it's called
A> $session_time) to time() at the time of login. Now, in the script...

if ((time() + 300) >> $session_time) {

A> }

A> This would be a check to see if the session is still valid. Timewise.

A> -- 
A> Best regards,
A>  Asmodeanmailto:[EMAIL PROTECTED]


Wrong. My fault. ;)

It's...

if (time() > $session_time + 300) {

}

Sorry.


-- 
Best regards,
 Asmodeanmailto:[EMAIL PROTECTED]


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




Re[4]: [PHP] timer on sessions?

2002-07-17 Thread Asmodean

J> So under the time() call, comparing it to a simple numerical value such as
J> "300" it knows that you are talking about 300 seconds?  Is that because it
J> is a unix timestamp?  I previously tried using date("s") to give me the
J> seconds from today's date then tried the compare, so using time() will work
J> better.  Thanks a ton.
J> Jas

Yes. time() returns a UNIX timestamp (currently a 10-digit number)
representing the number of seconds since a certain date (sometime in
1972).

-- 
Best regards,
 Asmodeanmailto:[EMAIL PROTECTED]


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




Re: [PHP] Confused about the list() function

2002-07-17 Thread Asmodean

D> Hi,

D> I have the following situation.  I have an array of colors that I would like to 
print out.  My first course of action would be to convert the array to a string so 
that I can parse it.  My command
D> would be:

D> $color_list = explode(",", $color);

D> Now that I have a string of colors delimited by commas, I would like to parse the 
string and print out all my colors.  I have read the documentation on using the list() 
function but I find it
D> confusing.  Can someone clear the fog from my mind please?

D> Thanks,
D> Don

Assuming you have an array of colors called $color (and assuming I
haven't misread or misinterpreted any information), you can do the
following to directly print your colors.

// Prints out all colors comma-separated.
print(join(", ", $color));

// Prints out all colors linebreak-separated (HTML-wise).
print(join("", $color));

-- 
Best regards,
 Asmodeanmailto:[EMAIL PROTECTED]


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




Re: [PHP] remove header tags - include file

2002-07-17 Thread Asmodean

JPA> Hi guys, me again.
JPA> (thanks kevin, but i'm afraid you didn't understand me).

JPA> After looking for untiringly in the archives I have I decide to ask again.

JPA> This is my problem:
JPA> I want include the file html.html inside of my file index.php, but before 
JPA> include it I want to remove .. tags from my html.html file.
JPA> My pseudo code would be look like this:

JPA>  > index.php

JPA>  include_once("common.php");

JPA> header("Welcome to my page");
JPA>  include_html_file("html.html");
JPA> footer()
?>>


JPA>  > common.php
JPA> function include_html_file($f)
JPA>   {
JPA>  (your kind contribution:-) )
JPA>   }

JPA> thanks!!

JPA> --jp

How do you mean remove? Do you mean you want to include the file
html.html but not the "..." part? And why?

-- 
Best regards,
 Asmodeanmailto:[EMAIL PROTECTED]


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




Re[2]: [PHP] remove header tags - include file

2002-07-17 Thread Asmodean

JPA>  >Do you mean you want to include the file
JPA> html.html but not the "..." part?
JPA> Yes!!. In other words I just want show the part inside of  tag of the 
JPA> html.html

JPA> I know the answer is in a Regulars expression.. but.. i don't know much 
JPA> about it.


JPA> At 19:08 17-07-2002, you wrote:
>>JPA> Hi guys, me again.
>>JPA> (thanks kevin, but i'm afraid you didn't understand me).
>>
>>JPA> After looking for untiringly in the archives I have I decide to ask 
>>again.
>>
>>JPA> This is my problem:
>>JPA> I want include the file html.html inside of my file index.php, but 
>>before
>>JPA> include it I want to remove .. tags from my html.html file.
>>JPA> My pseudo code would be look like this:
>>
>>JPA>  > index.php
>>
>>JPA> >
>>JPA> include_once("common.php");
>>
>>JPA> header("Welcome to my page");
>>JPA>  include_html_file("html.html");
>>JPA> footer()
>>?>>
>>
>>
>>JPA>  > common.php
>>JPA> function include_html_file($f)
>>JPA>   {
>>JPA>  (your kind contribution:-) )
>>JPA>   }
>>
>>JPA> thanks!!
>>
>>JPA> --jp
>>
>>How do you mean remove? Do you mean you want to include the file
>>html.html but not the "..." part? And why?
>>
>>--
>>Best regards,
>>  Asmodeanmailto:[EMAIL PROTECTED]
>>
>>
>>--
>>PHP General Mailing List (http://www.php.net/)
>>To unsubscribe, visit: http://www.php.net/unsub.php

JPA> 
JPA> Juan Pablo Aqueveque <[EMAIL PROTECTED]>
JPA> Ingeniero de Sistemas
JPA> Departamento de Redes y Comunicaciones http://www.drc.uct.cl
JPA> Universidad Católica de Temuco.
JPA> Tel:(5645) 205 630 Fax:(5645) 205 628

Seems like a... strange thing to do. Anyway. Since I do not know of
any other way (if there is, anyone, tell), this is what you will have
to do.

1. Open the file with fopen()
2. Perform a regular expression on the content
3. Print the parsed cntents

For example:

$fp = fopen('html.html', 'r');
$content = fread($fp, filesize(html.html));

preg_match("/(.*?)<\/body>/s", $content, $matches);

The parsed contents are now in $matches[1].

I still don't understand why you want to do this, though. Seems like
there must be a better way.

-- 
Best regards,
 Asmodeanmailto:[EMAIL PROTECTED]


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




Re: [PHP] Please Help with LOOP!!

2002-07-18 Thread Asmodean

Hello Wee,

Friday, July 19, 2002, 2:36:40 AM, you wrote:

WK> Hi all...

WK> I'm a complete beginner in programming. Just started a few months ago. 

WK> So, I'm sorry if this is a stupid question to ask. But I'm at a dead end here and 
do not know where else to go.

WK> I'm trying to automate a checkbox name to have the name "choice1" to have 
incremental effect on the number such as the following:

WK> 
WK> 
WK> 
WK> ...

WK> And I used the following script (please don't laugh) :)

WK> Maximise this email to full screen so that you can see the script better.

WK> for($count=1; $count<=$rows; $count++) {
WK>while($query_data = mysql_fetch_array($result)) {
WK> $price = $query_data["price_lq"];
WK> $RowColor = useColor();
WK> echo "\n";
WK> echo "",$query_data["prod_brand"],"";
WK> echo "",$query_data["prod_desc"],"";
WK> echo "","$",$price,"";
WK> echo "\n";
WK>}
WK> }

WK> The result was irritating... it came up with the same name, which is "choice1" all 
the way like:

WK> 
WK> 
WK> 
WK> ...

WK> Am I doing it the wrong way? If so, how should I do it? 

WK> Please pleas help... thanks

WK> Yours,
WK> Wee Keat

WK> 
WK> "Good timber does not grow with ease; the stronger the wind, the stronger the 
trees."

echo "\n";

Your problem is with this line. Look closely at the following part:

name=\"choice",$count,"\"

You should do this:

name=\"choice" . $count . "\"

... and it will generate names like 'choice1', 'choice2', and so on.

-- 
Best regards,
 Asmodeanmailto:[EMAIL PROTECTED]


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