[PHP] How to show proper time to users from around the world

2007-08-29 Thread Hemanth
Hi friends,

Is there a solution to showing the proper time and date at user
browsers
and also recording proper USER times in the database operations in
mysql

Hemanth

-- 
www.ValueAds.bizso easy
FREE India Classifieds
Jobs, Matrimony, Property and more
A Bangalore, India Venture.


Re: [PHP] How to show proper time to users from around the world

2007-08-29 Thread mike
On 8/29/07, Hemanth <[EMAIL PROTECTED]> wrote:
> Hi friends,
>
> Is there a solution to showing the proper time and date at user
> browsers
> and also recording proper USER times in the database operations in
> mysql

if you have the opportunity to have them input the time, you can then use

putenv("TZ=America/Los_Angeles") before any time operations and they
will be localized. it will accept any of the timezone library
definitions (or what you select for instance on unix libraries)

there's also a new date extension available as of one of the latest
php versions i believe that makes it even easier.

http://us3.php.net/manual/en/ref.datetime.php has the info.

for mysql data exchange you can use FROM_UNIXTIME and
UNIX_TIMESTAMP(NOW()) for example; if you dig it out from the database
and use the PHP functions it will localize it properly still. i don't
even fuss with this stuff anymore, i have a date formatting function
which takes $visitor['timezone'] (which is pre-populated with a
default, and overridden if the user has defined a different one) and
uses putenv("TZ=$foo") before i do the actual date/function calls -
it's been working flawlessly for years. i could probably update it now
to use the new extension too, natively maybe it would work slightly
faster than environment setting.

trying to detect the timezone offset from the browser i do not think
can be done consistently. i don't think i've seen anything that is
considered foolproof for that. maybe just DST checks...

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



[PHP] Socket takes a long time to 'finish'

2007-08-29 Thread Alvar Saenz-Otero

Hello,

I have a small but somewhat annoying issue.

Whenever I open a socket to another server, the file is read very 
quickly, but it takes the up to 30 seconds or so to close the connection...


Here is what I do:
  $sever = "server.mit.edu";
  $url = "/link";
  $port = 80;
  $user_agent = $_SERVER['HTTP_USER_AGENT'];
  $server_protocol = $_SERVER['SERVER_PROTOCOL'];

  $valsencoded = "";
  while (list($key,$value) = each ($content))
 $valsencoded .= urlencode($key) . "=" . urlencode($value) ."&";
  $valsencoded = substr($urlencoded,0,-1);

  $content_length = strlen($valsencoded);

  $headers = "POST $url $server_protocol
Content-Type: application/x-www-form-urlencoded
Host: $server
Content-Length: $content_length

";

  // open socket
  $socket = fsockopen($server, $port, $errno, $errstr, 60.0);
  if (!$socket) {
$error = "ERROR: cannot contact Mailman server";
return array(false,$error,$error); }

  if ($errstr) {
$error = "ERROR: fSockOpen Error ($errno): $errstr";
return array(false,$error,$error); }

  fputs($socket, $headers);  // send headers
  fputs($socket, $urlencoded);  // send post data

  // "tried stream_set_timeout($socket,3)" here

  // get the returned page
  while (!feof($socket))
  {
$buf = @fgets($socket, 2048);
$htmlreturned .= $buf;
  }
  fclose($socket);

If I put a debug 'echo "BUF: $buf\n" inside the while loop, I see the 
returned html from the post show up pretty much immediately, within 
about a second, maybe less.


However, the process 'stalls' after that for between 15-30 seconds, and 
then ends correctly.


I have tried to use timeouts, but they did not have any effects (did not 
really expect them to, but just in case).


My setup is Debian 4.0, php 5.2.0-8+etch7. Unfortunately I don't know 
the other server OS's/applications.


I found similar questions in posts from 2002 and 2003, but there were no 
replies (2002-04-30 guido.d.berger and 2003-11-25 thomas weber).


Any ideas greatly appreciated,

Alvar

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



[PHP] How to run and terminate C++ program(*.exe) with PHP?

2007-08-29 Thread Aram Shatakhtsyan

How to run C++ program(*.exe) with PHP, and then terminate it.

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



Re: [PHP] Socket takes a long time to 'finish'

2007-08-29 Thread Eddie Dunckley
On Wed 29 Aug 07, Alvar Saenz-Otero wrote:
> Hello,
> I have a small but somewhat annoying issue.
> Whenever I open a socket to another server, the file is read very
> quickly, but it takes the up to 30 seconds or so to close the
> connection...
>
> Here is what I do:
>$sever = "server.mit.edu";
>$url = "/link";
>$port = 80;
>$user_agent = $_SERVER['HTTP_USER_AGENT'];
>$server_protocol = $_SERVER['SERVER_PROTOCOL'];

just a wild guess, but try to use perhaps http1.0 instead of 1.1, and
try to add into the header that you prepare and send a 
Connection: close\r\n


-- 
Eddie Dunckley - [EMAIL PROTECTED] - Realtime Travel Connections 
IBE Development, www.rttc.co.za, cell 083-379-6891, fax 086-617-7831
Where 33deg53'37.23"S 18deg37'57.87"E Cape Town Bellville Oakdale ZA
 "I used to have a handle on life, but it broke."

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



[PHP] Heredocs

2007-08-29 Thread RodgerW

Are heredocs supported by PP 5.2.3 running in WinXP/Apache2.2.4 ?
I prrint via heredocs and its not working. Print with single quotes and 
double quotes work.



string init method 3: heredocs



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



[PHP] Heredocs

2007-08-29 Thread RodgerW

Are heredocs supported by PHP 5.2.3 running in WinXP/Apache2.2.4 ?
I prrint via heredocs and its not working. Print with single quotes and 
double quotes work.



string init method 3: heredocs



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



Re: [PHP] How to run and terminate C++ program(*.exe) with PHP?

2007-08-29 Thread shiplu
On 8/29/07, Aram Shatakhtsyan <[EMAIL PROTECTED]> wrote:
>
> How to run C++ program(*.exe) with PHP, and then terminate it.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
PHP can do anything. But the matter is where the host permits to do such.

// See the following algorithm
function exec_php($host){
if (its $host that runs php as a module) {
  then it depends on the rights of $host
   if ($host is in the group of root){
  $host can do any thing.
   } else {
  $host will do those tasks that its been permitted.
   }
}
}

If (you are root and running php as a CLI){
   you can do anything (whatever you wish)
}.
if (you are normal user and running php as a CLI){
   you cant do some specific task like killing process.
}

// see the function definition above.
exec_php(apache);
exec_php(IIS);

I think you got it.
sorry for the approach. But it makes clear logic. :)

Thanks.

-- 
shout at http://shiplu.awardspace.com/

Available for Hire/Contract/Full Time


RE: [PHP] Trying to understand sessions and using them to authenticate...

2007-08-29 Thread Ford, Mike
On 28 August 2007 15:56, Stut wrote:

> Jason Pruim wrote:
> > One other question, to logout, can I just call a file that has
> > session_destroy() and a header("Location: ???"); in it? Or should I
> > do something else for logging out?
> 
> foreach (array_keys($_SESSION) as $key)
>  unset($_SESSION[$key];
> session_destroy();

$_SESSION = array();
session_destroy();
session_commit();
setcookie(session_name(), "",
ini_get('session.cookie_lifetime'),
ini_get('session.cookie_path'),
ini_get('session.cookie_domain'));


Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
JG125, The Headingley Library,
James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730  Fax:  +44 113 812 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



Re: [PHP] Heredocs

2007-08-29 Thread Aaron Gould

RodgerW wrote:

Are heredocs supported by PHP 5.2.3 running in WinXP/Apache2.2.4 ?
I prrint via heredocs and its not working. Print with single quotes and 
double quotes work.



string init method 3: heredocs
END;   
?>







It works here on 5.2.3.  Try removing ALL whitespace before and after 
the "END;" portion of your heredocs.  If there's whitespace, it doesn't 
work.


--
Aaron Gould

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



RE: [PHP] Heredocs

2007-08-29 Thread Jay Blanchard
[snip]
Are heredocs supported by PP 5.2.3 running in WinXP/Apache2.2.4 ?
I prrint via heredocs and its not working. Print with single quotes and 
double quotes work.


string init method 3: heredocs


The closing identifier must begin in the first column of the line. Looks
like yours is tabbed or spaced over.

http://us.php.net/manual/en/language.types.string.php#language.types.str
ing.syntax.heredoc

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



RE: [PHP] Heredocs

2007-08-29 Thread Edward Kay
> Are heredocs supported by PP 5.2.3 running in WinXP/Apache2.2.4 ?
> I prrint via heredocs and its not working. Print with single quotes and
> double quotes work.
>
>   
>   string init method 3: heredocs
>  print <<< END
>   Test
>   END;
>   ?>
>   
>

This won't work because you've indented the closing identifier. Read the big
Warning box at
http://uk2.php.net/manual/en/language.types.string.php#language.types.string
.syntax.heredoc

Edward

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



Re: [PHP] Heredocs

2007-08-29 Thread Thijs Lensselink
On Wed, 29 Aug 2007 13:01:07 +0200, RodgerW <[EMAIL PROTECTED]> wrote:
> Are heredocs supported by PHP 5.2.3 running in WinXP/Apache2.2.4 ?
> I prrint via heredocs and its not working. Print with single quotes and
> double quotes work.
> 
>   
>   string init method 3: heredocs
>  print <<< END
>   Test
>   END;
>   ?>
>   
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

Remove the spaces before END;

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



Re: [PHP] Trying to understand sessions and using them to authenticate...

2007-08-29 Thread Richard Heyes

Ford, Mike wrote:
> On 28 August 2007 15:56, Stut wrote:
>
>> Jason Pruim wrote:
>>> One other question, to logout, can I just call a file that has
>>> session_destroy() and a header("Location: ???"); in it? Or should I
>>> do something else for logging out?
>> foreach (array_keys($_SESSION) as $key)
>>  unset($_SESSION[$key];
>> session_destroy();
>
>$_SESSION = array();
>session_destroy();
>session_commit();
>setcookie(session_name(), "",
>ini_get('session.cookie_lifetime'),
>ini_get('session.cookie_path'),
>ini_get('session.cookie_domain'));

$_SESSION = array(); will usually suffice.

--
Richard Heyes
+44 (0)844 801 1072
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support

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



Re: [PHP] Socket takes a long time to 'finish'

2007-08-29 Thread Alvar Saenz-Otero


Thank you!  Either of the two options fixed it!  My guess is that 
HTTP 1.0 does not need the "Connection: close" while HTTP 1.1 does. 
So I had to fix one of the two... I did both, just so that my script 
has better compatibility in the future.


Thanks again,

Alvar

At 06:59 2007/08/29, Eddie Dunckley wrote:

On Wed 29 Aug 07, Alvar Saenz-Otero wrote:
> Hello,
> I have a small but somewhat annoying issue.
> Whenever I open a socket to another server, the file is read very
> quickly, but it takes the up to 30 seconds or so to close the
> connection...
>
> Here is what I do:
>$sever = "server.mit.edu";
>$url = "/link";
>$port = 80;
>$user_agent = $_SERVER['HTTP_USER_AGENT'];
>$server_protocol = $_SERVER['SERVER_PROTOCOL'];

just a wild guess, but try to use perhaps http1.0 instead of 1.1, and
try to add into the header that you prepare and send a
Connection: close\r\n


--
Eddie Dunckley - [EMAIL PROTECTED] - Realtime Travel Connections
IBE Development, www.rttc.co.za, cell 083-379-6891, fax 086-617-7831
Where 33deg53'37.23"S 18deg37'57.87"E Cape Town Bellville Oakdale ZA
 "I used to have a handle on life, but it broke."


=
Alvar Saenz Otero, PhD
MIT Space Systems Laboratory
617.699.7311 cell
[EMAIL PROTECTED]

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



[PHP] Round

2007-08-29 Thread Koen van den Boogaart
Is it expected behaviour that



outputs

float(-0) 

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



Re: [PHP] Round

2007-08-29 Thread Richard Heyes

Koen van den Boogaart wrote:

Is it expected behaviour that



outputs

float(-0) 



Yes. You (probably) want:



http://uk.php.net/manual/en/function.round.php

--
Richard Heyes
+44 (0)844 801 1072
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support

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



RE: [PHP] Regular expression - URL validator

2007-08-29 Thread Wagner Garcia Campagner
Thanks again Jim,

That's what i really need.

I'm testing this function...

If i put a URL like www.example.com, then it works fine and turns it to
http://www.example.com

But if i put a URL like http://www.example.com, then it also put another
header so it turns to http://http://www.example.com

I also tried with the strstr function, but receive the same response.

Thanks in advance,
Wagner.



-Original Message-
From: Jim Lucas [mailto:[EMAIL PROTECTED]
Sent: terça-feira, 28 de agosto de 2007 18:35
To: [EMAIL PROTECTED]
Cc: PHP General
Subject: Re: [PHP] Regular expression - URL validator


Wagner Garcia Campagner wrote:
> Thanks Jim,
>
> Your sugestion worked perfect for me!!
>
> I have another question:
>
> After i validate this URL i want to put a link with this URL in my page.
>
> The problem is that if the URL is like (www.aol.com), when i create the
> link, this URL is appended with the URL of my site. The result is a link
> pointing to: http:///www.aol.com
>
> But if the URL is like (http://aol.com), then the link is created correct.
>
> Is there a way to avoid the first situation... so the link is created
> correct?
>
> Thanks again,
> Wagner.
>
You could always do a string comparison for http(s)? in the url

if ( strpos($url, array('https://', 'http://')) === false ) {
$url = 'http://'.$url;
}

--
Jim Lucas

"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
 by William Shakespeare

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



[PHP] Internet Explorer Caching

2007-08-29 Thread Charlene
I've been having problems with Internet Explorer caching php programs.  
I'm using the following code:


   header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
   header("Pragma", "no-cache");
   header("Expires", "-1");

And it used to work, but now, according to Windows Explorer its giving 
it 3 hours to expire.


Charlene

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



Re: [PHP] Internet Explorer Caching

2007-08-29 Thread Richard Heyes

Charlene wrote:
I've been having problems with Internet Explorer caching php programs.  
I'm using the following code:


   header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
   header("Pragma", "no-cache");
   header("Expires", "-1");

And it used to work, but now, according to Windows Explorer its giving 
it 3 hours to expire.


Are you sure? By default PHP pages/scripts don't send any caching 
headers and hence don't get cached. You can check this using: 
http://www.fiddlertool.com


--
Richard Heyes
+44 (0)844 801 1072
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support

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



Re: [PHP] Round

2007-08-29 Thread Koen van den Boogaart
No, I want it to go to float(0), so minus the minus. "-0" doesn't exist in 
math, as far as I know. Probably a precision thing.

"Richard Heyes" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Koen van den Boogaart wrote:
>> Is it expected behaviour that
>>
>> 
>>
>> outputs
>>
>> float(-0)
>
>
> Yes. You (probably) want:
>
>  var_dump(round(-0.26, 1));
> ?>
>
> http://uk.php.net/manual/en/function.round.php
>
> -- 
> Richard Heyes
> +44 (0)844 801 1072
> http://www.websupportsolutions.co.uk
>
> Knowledge Base and HelpDesk software
> that can cut the cost of online support 

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



Re: [PHP] Regular expression - URL validator

2007-08-29 Thread Jim Lucas

Wagner Garcia Campagner wrote:

Thanks again Jim,

That's what i really need.

I'm testing this function...

If i put a URL like www.example.com, then it works fine and turns it to
http://www.example.com

But if i put a URL like http://www.example.com, then it also put another
header so it turns to http://http://www.example.com

I also tried with the strstr function, but receive the same response.

Thanks in advance,
Wagner.


Give this a shot

ftp://www.google.com";);
echo "\n";
echo fixurl("http://www.google.com";);
echo "\n";
echo fixurl("https://www.google.com";);
?>

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] Round

2007-08-29 Thread Jim Lucas

Koen van den Boogaart wrote:

Is it expected behaviour that



outputs

float(-0) 


What version of PHP are you running.

I'm running 5.1.6 and I get float(0)

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] Round

2007-08-29 Thread Richard Heyes

Koen van den Boogaart wrote:
No, I want it to go to float(0), so minus the minus. "-0" doesn't exist in 
math, as far as I know. Probably a precision thing.


Ok, then try abs() first then.

--
Richard Heyes
+44 (0)844 801 1072
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support

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



Re: [PHP] Round

2007-08-29 Thread Daniel Brown
On 8/29/07, Richard Heyes <[EMAIL PROTECTED]> wrote:
> Koen van den Boogaart wrote:
> > No, I want it to go to float(0), so minus the minus. "-0" doesn't exist in
> > math, as far as I know. Probably a precision thing.
>
> Ok, then try abs() first then.
>
> --
> Richard Heyes
> +44 (0)844 801 1072
> http://www.websupportsolutions.co.uk
>
> Knowledge Base and HelpDesk software
> that can cut the cost of online support
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Richard (Heyes) is right.



Tested on 5.0.4 and 5.2.3.

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Hey, PHP-General list
50% off for life on web hosting plans $10/mo. or more at
http://www.pilotpig.net/.
Use the coupon code phpgeneralaug07
Register domains for about $0.01 more than what it costs me at
http://domains.pilotpig.net/.

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



Re: [PHP] Round

2007-08-29 Thread Jim Lucas

Daniel Brown wrote:

On 8/29/07, Richard Heyes <[EMAIL PROTECTED]> wrote:

Koen van den Boogaart wrote:

No, I want it to go to float(0), so minus the minus. "-0" doesn't exist in
math, as far as I know. Probably a precision thing.

Ok, then try abs() first then.

--
Richard Heyes
+44 (0)844 801 1072
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support

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




Richard (Heyes) is right.



Tested on 5.0.4 and 5.2.3.


Think this through before you respond...

Try this



does this give you the desired results?

What if I expected -1 for the last answer?


--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] Round

2007-08-29 Thread Richard Heyes

What if I expected -1 for the last answer?


Then only use abs() if the result from round() is zero;

--
Richard Heyes
+44 (0)844 801 1072
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support

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



Re: [PHP] Round

2007-08-29 Thread Zoltán Németh
2007. 08. 29, szerda keltezéssel 09.29-kor Jim Lucas ezt írta:
> Daniel Brown wrote:
> > On 8/29/07, Richard Heyes <[EMAIL PROTECTED]> wrote:
> >> Koen van den Boogaart wrote:
> >>> No, I want it to go to float(0), so minus the minus. "-0" doesn't exist in
> >>> math, as far as I know. Probably a precision thing.
> >> Ok, then try abs() first then.
> >>
> >> --
> >> Richard Heyes
> >> +44 (0)844 801 1072
> >> http://www.websupportsolutions.co.uk
> >>
> >> Knowledge Base and HelpDesk software
> >> that can cut the cost of online support
> >>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> > 
> > Richard (Heyes) is right.
> > 
> > 
> > 
> > Tested on 5.0.4 and 5.2.3.
> > 
> Think this through before you respond...
> 
> Try this
> 
>  var_dump( round(-0.26) );
> var_dump( abs( round(-0.26) ) );
> var_dump( round(-1.26) );
> var_dump( abs( round(-1.26) ) );
> ?>
> 
> does this give you the desired results?
> 
> What if I expected -1 for the last answer?

why would you expect -1 for the last one?
abs(-1) should return 1 AFAIK

that's what the above code produces too.

greets
Zoltán Németh

> 
> 
> -- 
> Jim Lucas
> 
> "Some men are born to greatness, some achieve greatness,
> and some have greatness thrust upon them."
> 
> Twelfth Night, Act II, Scene V
>  by William Shakespeare
> 

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



Re: [PHP] Round

2007-08-29 Thread Daniel Brown
On 8/29/07, Zoltán Németh <[EMAIL PROTECTED]> wrote:
> > Think this through before you respond...
> >
> > Try this
> >
> >  > var_dump( round(-0.26) );
> > var_dump( abs( round(-0.26) ) );
> > var_dump( round(-1.26) );
> > var_dump( abs( round(-1.26) ) );
> > ?>
> >
> > does this give you the desired results?
> >
> > What if I expected -1 for the last answer?

It didn't take much thinking this time if you were expecting
-1 for the last answer, you'd be wrong.  ;-P

The very nature of abs() is to return an absolute number, which is
never a negative.

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Hey, PHP-General list
50% off for life on web hosting plans $10/mo. or more at
http://www.pilotpig.net/.
Use the coupon code phpgeneralaug07
Register domains for about $0.01 more than what it costs me at
http://domains.pilotpig.net/.

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



Re: [PHP] Round

2007-08-29 Thread Jim Lucas

Daniel Brown wrote:

On 8/29/07, Zoltán Németh <[EMAIL PROTECTED]> wrote:

Think this through before you respond...

Try this



does this give you the desired results?

What if I expected -1 for the last answer?


It didn't take much thinking this time if you were expecting
-1 for the last answer, you'd be wrong.  ;-P

The very nature of abs() is to return an absolute number, which is
never a negative.



Exactly my point, abs() is not the answer

if he had any negative number that did not round to zero, say it would round to -2, then having the 
abs() in the calculations would return 2 instead of -2, which would be wrong.


From what I read from the OP, I don't think this is what he was looking for.

the op was asking why he got -0 instead of 0.  not for a solution to fix it.

ok, better example.



But, from what the OP says, he would get -0 instead of 0 for the 4th entry.  Am 
I correct with this?

if so, you could try casting it as an int like so

var_dump( (int)round(-0.26) );

That might fix the problem

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare

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



[PHP] Pragmatically changing a "Record Number"

2007-08-29 Thread Jason Pruim

Hi Everyone,

I think after I get this question answered, I can stop asking for  
awhile since my project will be done, at least until the users say  
"What happened to XYZ" then I'll ask again :)


I asked on a MySQL list about "Resetting a auto increment filed" so  
that there arn't any gaps in the record number.


So to say it another way, I have a table that has 900 records in it,  
I've added 3 records, but then deleted 2 of those which puts the  
actual record count at 901 but my auto increment field starts at 904  
on the next insert.


Is there away with PHP that I can pragmatically change that value to  
the total records in the database more so then a representation of  
the actual record number?



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]




RE: [PHP] Pragmatically changing a "Record Number"

2007-08-29 Thread Jay Blanchard
[snip]
Is there away with PHP that I can pragmatically change that value to  
the total records in the database more so then a representation of  
the actual record number?
[/snip] 

1. Changing the values in an auto-increment column is just Bad[tm],
especially if you are using it as a unique index.

2. You can get a row count using mysql_num_rows()

3. Ask yourself, "Is it important to keep the auto-increment field
contiguous?"

4. You can always display a row number with PHP that is contiguous, but
not representative of the actual column.
 

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



Re: [PHP] Round

2007-08-29 Thread Koen van den Boogaart
I'm running 5.2.3. Reaction on above discussion: of course this problem can 
be solved with all sorts of solutions, but my question is: is it good that a 
function returns a number that doesn't exist? I once posted a bug report 
about a wrong round()-result, though it wasn't a bug, but a consequence of 
the limited precision of PHP when using floats. So I'm just checking, before 
shouting out loud that there's something wrong.

So, again: my question is not how to solve this, but whether or not this is 
expected behaviour.

"Jim Lucas" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Koen van den Boogaart wrote:
>> Is it expected behaviour that
>>
>> 
>>
>> outputs
>>
>> float(-0)
> What version of PHP are you running.
>
> I'm running 5.1.6 and I get float(0)
>
> -- 
> Jim Lucas
>
>"Some men are born to greatness, some achieve greatness,
>and some have greatness thrust upon them."
>
> Twelfth Night, Act II, Scene V
> by William Shakespeare 

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



Re: [PHP] Pragmatically changing a "Record Number"

2007-08-29 Thread Jason Pruim


On Aug 29, 2007, at 1:58 PM, Jay Blanchard wrote:


[snip]
Is there away with PHP that I can pragmatically change that value to
the total records in the database more so then a representation of
the actual record number?
[/snip] 

1. Changing the values in an auto-increment column is just Bad[tm],
especially if you are using it as a unique index.


It's not yet, and I don't plan to have it be part of a unique index,  
unless I absolutely need to onceI look into being able to search...


2. You can get a row count using mysql_num_rows()



3. Ask yourself, "Is it important to keep the auto-increment field
contiguous?"


The main reason for changing it is I do currently have an option to  
sort by record number, although, if I add a Record number in php, but  
still have it sort based off of the record number stored in the  
database, it would still sort right, but also look right...




4. You can always display a row number with PHP that is contiguous,  
but

not representative of the actual column.




I think you may have made me go a different way in my thinking. Thank  
you :)



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

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



Re: [PHP] Internet Explorer Caching

2007-08-29 Thread Satyam

I'm sending these headers:

  header('Cache-Control: no-cache, must-revalidate'); // HTTP/1.1
  header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past

I don't remember where I took them from, but they are working fine for me.

Satyam


- Original Message - 
From: "Richard Heyes" <[EMAIL PROTECTED]>

To: "Charlene" <[EMAIL PROTECTED]>
Cc: 
Sent: Wednesday, August 29, 2007 5:50 PM
Subject: Re: [PHP] Internet Explorer Caching



Charlene wrote:
I've been having problems with Internet Explorer caching php programs. 
I'm using the following code:


   header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
   header("Pragma", "no-cache");
   header("Expires", "-1");

And it used to work, but now, according to Windows Explorer its giving it 
3 hours to expire.


Are you sure? By default PHP pages/scripts don't send any caching headers 
and hence don't get cached. You can check this using: 
http://www.fiddlertool.com


--
Richard Heyes
+44 (0)844 801 1072
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support

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



--
No virus found in this incoming message.
Checked by AVG Free Edition. Version: 7.5.484 / Virus Database: 
269.12.10/977 - Release Date: 28/08/2007 16:29





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



Re: [PHP] Internet Explorer Caching

2007-08-29 Thread Nate
that's from php.net...
" PHP scripts often generate dynamic content that must not be cached
by the client browser or any proxy caches between the server and the
client browser. Many proxies and clients can be forced to disable
caching with:


Note: You may find that your pages aren't cached even if you don't
output all of the headers above. There are a number of options that
users may be able to set for their browser that change its default
caching behavior. By sending the headers above, you should override
any settings that may otherwise cause the output of your script to be
cached.

Additionally, session_cache_limiter() and the
session.cache_limiter configuration setting can be used to
automatically generate the correct caching-related headers when
sessions are being used. "

On 8/29/07, Satyam <[EMAIL PROTECTED]> wrote:
> I'm sending these headers:
>
>header('Cache-Control: no-cache, must-revalidate'); // HTTP/1.1
>header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
>
> I don't remember where I took them from, but they are working fine for me.
>
> Satyam
>
>
> - Original Message -
> From: "Richard Heyes" <[EMAIL PROTECTED]>
> To: "Charlene" <[EMAIL PROTECTED]>
> Cc: 
> Sent: Wednesday, August 29, 2007 5:50 PM
> Subject: Re: [PHP] Internet Explorer Caching
>
>
> > Charlene wrote:
> >> I've been having problems with Internet Explorer caching php programs.
> >> I'm using the following code:
> >>
> >>header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
> >>header("Pragma", "no-cache");
> >>header("Expires", "-1");
> >>
> >> And it used to work, but now, according to Windows Explorer its giving it
> >> 3 hours to expire.
> >
> > Are you sure? By default PHP pages/scripts don't send any caching headers
> > and hence don't get cached. You can check this using:
> > http://www.fiddlertool.com
> >
> > --
> > Richard Heyes
> > +44 (0)844 801 1072
> > http://www.websupportsolutions.co.uk
> >
> > Knowledge Base and HelpDesk software
> > that can cut the cost of online support
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> >
> > --
> > No virus found in this incoming message.
> > Checked by AVG Free Edition. Version: 7.5.484 / Virus Database:
> > 269.12.10/977 - Release Date: 28/08/2007 16:29
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
-Nate
http://swapinvites.com

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



Re: [PHP] Pragmatically changing a "Record Number"

2007-08-29 Thread Jim Lucas

Jason Pruim wrote:

3. Ask yourself, "Is it important to keep the auto-increment field
contiguous?"


The main reason for changing it is I do currently have an option to sort 
by record number, although, if I add a Record number in php, but still 
have it sort based off of the record number stored in the database, it 
would still sort right, but also look right...


Are you thinking mysql reuses auto-increment number?  If so, your mistaken.

MySQL will not reuse an auto-increment unique value.

say you have an empty table with an auto-increment column.

You add 5 row

your next id to be used is 6.

if you delete id # 2 and 3

the next id to be used will still be 6 not 2

it does not go back and fill in the holes/gaps

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare

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



RE: [PHP] Round

2007-08-29 Thread PHP-Gen
I believe there is some confusion on what ABS actually does.  Ignoring all
the rounding that you are trying to do ABS is a very simple function.

ABS definition: Returns the absolute value of number.

What that means is.

Abs(1) = 1
Abs(2) = 2
Abs(3) = 3
Abs(0) = 0
Abs(-1) = 1
Abs(-2) = 2
Abs(-3) = 3

Simply put, returns the positive value of the number given.  Thus if you put
it on a negative number it will always return positive.

This most likely doesn't help what your trying to do, but I wanted to
clarify this as you keep stating you are expecting a -1 when you use the ABS
function.  Unless someone has some trick that I don't know about, ABS will
NEVER return a negative number.


-Original Message-
From: Jim Lucas [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 29, 2007 1:43 PM
To: Daniel Brown
Cc: Zoltán Németh; php-general@lists.php.net
Subject: Re: [PHP] Round

Daniel Brown wrote:
> On 8/29/07, Zoltán Németh <[EMAIL PROTECTED]> wrote:
>>> Think this through before you respond...
>>>
>>> Try this
>>>
>>> >> var_dump( round(-0.26) );
>>> var_dump( abs( round(-0.26) ) );
>>> var_dump( round(-1.26) );
>>> var_dump( abs( round(-1.26) ) );
>>> ?>
>>>
>>> does this give you the desired results?
>>>
>>> What if I expected -1 for the last answer?
> 
> It didn't take much thinking this time if you were expecting
> -1 for the last answer, you'd be wrong.  ;-P
> 
> The very nature of abs() is to return an absolute number, which is
> never a negative.
> 

Exactly my point, abs() is not the answer

if he had any negative number that did not round to zero, say it would round
to -2, then having the 
abs() in the calculations would return 2 instead of -2, which would be
wrong.

 From what I read from the OP, I don't think this is what he was looking
for.

the op was asking why he got -0 instead of 0.  not for a solution to fix it.

ok, better example.



But, from what the OP says, he would get -0 instead of 0 for the 4th entry.
Am I correct with this?

if so, you could try casting it as an int like so

var_dump( (int)round(-0.26) );

That might fix the problem

-- 
Jim Lucas

"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
 by William Shakespeare

-- 
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] Pragmatically changing a "Record Number"

2007-08-29 Thread Stephen
--- Jason Pruim <[EMAIL PROTECTED]> wrote:

> So to say it another way, I have a table that has
> 900 records in it,  
> I've added 3 records, but then deleted 2 of those
> which puts the  
> actual record count at 901 but my auto increment
> field starts at 904  
> on the next insert.
> 
> Is there away with PHP that I can pragmatically
> change that value to  
> the total records in the database more so then a
> representation of  
> the actual record number?

Some database concepts:

The autoincrement feature is to provide a unique "key"
for the record. It does not provide an "order". Many
tables have more than one "order".

Usually a different field or field determines the
order(s). It usually has an index.

To provide a row number, based on some order, you need
a field for this. Whenever a field is deleted, you
would need to repopulate the fields in each record
after the deleted record in the database.

I saw a nested SQL query that did this once, but my
SQL is not good enough to try to illustrate.

Stephen

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



Re: [PHP] Round

2007-08-29 Thread Jim Lucas

PHP-Gen wrote:

I believe there is some confusion on what ABS actually does.  Ignoring all
the rounding that you are trying to do ABS is a very simple function.

ABS definition: Returns the absolute value of number.

What that means is.

Abs(1) = 1
Abs(2) = 2
Abs(3) = 3
Abs(0) = 0
Abs(-1) = 1
Abs(-2) = 2
Abs(-3) = 3

Simply put, returns the positive value of the number given.  Thus if you put
it on a negative number it will always return positive.

This most likely doesn't help what your trying to do, but I wanted to
clarify this as you keep stating you are expecting a -1 when you use the ABS
function.  Unless someone has some trick that I don't know about, ABS will
NEVER return a negative number.


Well, just to clarify, it was not I who suggested abs() as the fix.  You can look back to see who 
first suggested it your self.


First off, I completely understand what abs() does, I did passed my "basic 
math" class...

Secondly, I have been the one trying to point out how this is the wrong 
approach.

Finally, from what I can tell, the OP wasn't looking for a solution.  He was looking for an answer 
as to why it returned -0 and not 0.


--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] Round

2007-08-29 Thread Richard Lynch
On Wed, August 29, 2007 11:38 am, Zoltán Németh wrote:
> 2007. 08. 29, szerda keltezéssel 09.29-kor Jim Lucas ezt írta:
>> Daniel Brown wrote:
>> > On 8/29/07, Richard Heyes <[EMAIL PROTECTED]> wrote:
>> >> Koen van den Boogaart wrote:
>> >>> No, I want it to go to float(0), so minus the minus. "-0"
>> doesn't exist in
>> >>> math, as far as I know. Probably a precision thing.

I missed the start of this thread...

Technically, -0 exists and is a tautology to +0.

That said, PHP should not be outputting -0 for a round() operation,
nor abs() for that matter.

Check http://bugs.php.net with your PHP version for a similar problem.

-- 
Please vote for this great band:
http://acl.mp3.com/feature/soundandjury/?band=COMPANY-OF-THIEVES

Requires email confirmation.
One vote per day per email limit.
Obvious ballot-stuffing will be revoked.

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



Re: [PHP] Pragmatically changing a "Record Number"

2007-08-29 Thread brian

Jason Pruim wrote:

Hi Everyone,

I think after I get this question answered, I can stop asking for  
awhile since my project will be done, at least until the users say  
"What happened to XYZ" then I'll ask again :)


I asked on a MySQL list about "Resetting a auto increment filed" so  
that there arn't any gaps in the record number.


So to say it another way, I have a table that has 900 records in it,  
I've added 3 records, but then deleted 2 of those which puts the  actual 
record count at 901 but my auto increment field starts at 904  on the 
next insert.


Is there away with PHP that I can pragmatically change that value to  
the total records in the database more so then a representation of  the 
actual record number?




Do you mean *programmatically*? As the others have pointed out, what 
you're suggesting would not be very pragmatic at all.


In any case, if what you're after is an accurate method to get the 
number of records you have, do not rely on max(your_auto_inc_field). 
Instead, use count(your_primary_key) or mysql_num_rows($result) or 
$result->numRows() or whatever suits the method you're using to access 
the DB.


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



Re: [PHP] Pragmatically changing a "Record Number"

2007-08-29 Thread James Ausmus
On 8/29/07, Stephen <[EMAIL PROTECTED]> wrote:
> --- Jason Pruim <[EMAIL PROTECTED]> wrote:
>
> > So to say it another way, I have a table that has
> > 900 records in it,
> > I've added 3 records, but then deleted 2 of those
> > which puts the
> > actual record count at 901 but my auto increment
> > field starts at 904
> > on the next insert.
> >
> > Is there away with PHP that I can pragmatically
> > change that value to
> > the total records in the database more so then a
> > representation of
> > the actual record number?
>
> Some database concepts:
>
> The autoincrement feature is to provide a unique "key"
> for the record. It does not provide an "order". Many
> tables have more than one "order".
>
> Usually a different field or field determines the
> order(s). It usually has an index.
>
> To provide a row number, based on some order, you need
> a field for this. Whenever a field is deleted, you
> would need to repopulate the fields in each record
> after the deleted record in the database.
>
> I saw a nested SQL query that did this once, but my
> SQL is not good enough to try to illustrate.

Fairly easy - depending on your version of MySQL - if you are 5.0+,
then the following will do it:

SELECT @rownum:[EMAIL PROTECTED] rownum, t.* FROM (SELECT @rownum:=0) r, 
myTable t;

(Quoted from a post by Mark Malakanov on April 30 2006 1:42pm at
http://dev.mysql.com/doc/refman/5.0/en/user-variables.html)

-James


>
> Stephen
>
> --
> 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] Internet Explorer Caching

2007-08-29 Thread Richard Lynch
On Wed, August 29, 2007 10:43 am, Charlene wrote:
> I've been having problems with Internet Explorer caching php programs.
> I'm using the following code:
>
> header("Cache-Control: no-cache, must-revalidate"); //
> HTTP/1.1
> header("Pragma", "no-cache");
> header("Expires", "-1");
>
> And it used to work, but now, according to Windows Explorer its giving
> it 3 hours to expire.

The second argument to header() function will allow you to send
"duplicate" headers for the same header-name.

header("Pragma: no-cache");
header("Pragma: must-revalidate");

This is usually NOT what you want for headers, as MOST of them allow
only ONE instance.

So header("Pragma", "no-cache");
is sending a SECOND "Pragma" header.

Actually, as you have no ":" in there, it probably is sending it with
no ":", so it's really the first completely bogus "Pragma" header
which is doing absolutely nothing, and isn't a "Pragma:" header at
all.

I guess technically it's maybe not bogus...  You're allowed to extend
the HTTP protocol and send "extra" headers, but they're supposed to
start by "X-" by convention...

//legit
header("X-my-custom-header: 42");

//certainly not convention; probably not legit
header("My-custom-header: 42");

But it's sure not the "Pragma: no-cache" header you MEANT to send.

Ditto for Expires.

And double-ditto for the -1 value for "Expires", which I do not think
is a valid value.

Now IE may have decided to stop doing an interpretive dance around the
bogus headers you have been sending, and has decided it's time to make
you send the REAL headers.  Personally, I think it should never have
let you get away with it in the first place, but that's IE for ya.

ULTIMATELY, however, if you really really really want MS IE nor any
intermediary servers to cache something, your best bet is to add some
random bit to the URL:


can't cache
this

There is no combination of headers for no-cache that will actually
WORK for *ALL* legacy browsers.

Please Note: When I say *ALL* legacy browsers, I'm including
everything back to NCSA Mosiac and corporate re-branded IE with their
own nifty logo in place of the IE logo.

AT&T, for example, does/did this for their employees -- and the
version number may match exactly with the publicly-available IE, but
they don't behave the same, in my experience. :-(

Given that it's a heck of a lot easier to generate a random URL than
fiddle with so-called "no-cache" headers every time a bug report from
some browser you never even heard of rolls in, I strongly recommend
using a random URL.

YMMV

-- 
Please vote for this great band:
http://acl.mp3.com/feature/soundandjury/?band=COMPANY-OF-THIEVES

Requires email confirmation.
One vote per day per email limit.
Obvious ballot-stuffing will be revoked.

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



Re: [PHP] Internet Explorer Caching

2007-08-29 Thread Charlene
Yes, I'm sure.  Changes I make to a database are reflected in the 
database but not on the form.  It's only IE.  It works fine in FireFox 
or SeaMonkey.


Charlene

Richard Heyes wrote:

Charlene wrote:
I've been having problems with Internet Explorer caching php 
programs.  I'm using the following code:


   header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
   header("Pragma", "no-cache");
   header("Expires", "-1");

And it used to work, but now, according to Windows Explorer its 
giving it 3 hours to expire.


Are you sure? By default PHP pages/scripts don't send any caching 
headers and hence don't get cached. You can check this using: 
http://www.fiddlertool.com




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



[PHP] Perhaps an incomplete $_POST

2007-08-29 Thread Jay Blanchard
I just noticed something a little odd, and maybe there is a simple
solution. Given a form;



The attributes, especially the name "foo", never appear in any variables
array. I am thinking that this might be handy to have for several
reasons when processing the form. I have several reasons for needing the
information, does anyone know how to get this in the processing script
without having to add hidden fields or do some Ajax magic?

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



Re: [PHP] Pragmatically changing a "Record Number"

2007-08-29 Thread Richard Lynch
On Wed, August 29, 2007 12:49 pm, Jason Pruim wrote:
> I think after I get this question answered, I can stop asking for
> awhile since my project will be done, at least until the users say
> "What happened to XYZ" then I'll ask again :)
>
> I asked on a MySQL list about "Resetting a auto increment filed" so
> that there arn't any gaps in the record number.
>
> So to say it another way, I have a table that has 900 records in it,
> I've added 3 records, but then deleted 2 of those which puts the
> actual record count at 901 but my auto increment field starts at 904
> on the next insert.
>
> Is there away with PHP that I can pragmatically change that value to
> the total records in the database more so then a representation of
> the actual record number?

Can you do this?

Sure.

update whatever set ID_field = 901 where ID_field = 904

Of course, if that 904 is in some OTHER table, then you MUST update
that other table at the same time, in an ACID transation, to be sure
you don't get your relationships all kerflummoxed.

SHOULD you do this?

NOO!!!

The ID key field of a record should not have any explicit meaning.

If you try to re-number your records so it does, it will just cause
you grief and give you nothing useful in return.

If you actualy have a table where there *IS* an ordering of the
records which is meaningful, and it really SHOULD be 1 to N, then add
another field "rank" (or somesuch) and manipulate that independent of
the ID field, which you should never care about its actual number.

To explain WHY this is, would be way bigger than an email that's
already off-topic for PHP, but they should have told you on the MySQL
list.

Or not, as it's probably in their FAQ which you should have read.

If nothing else, the hassle of keeping all those IDs sorted out is a
TON of extra code that serves little purpose, and a single tiny
mistake can make a pig's breakfast of your entire database.  Bad Idea.

-- 
Please vote for this great band:
http://acl.mp3.com/feature/soundandjury/?band=COMPANY-OF-THIEVES

Requires email confirmation.
One vote per day per email limit.
Obvious ballot-stuffing will be revoked.

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



[PHP] PhP / MySQL problem

2007-08-29 Thread debussy007

Hi,

I created a form asking username, password, country, etc.
On the submit of this form I make a sql connection and update the database,
add the user.

The problem is that whenever the field 'password' is filled in,
"it" (I don't know what) is asking to confirm the change of the password.

I made a printscreen to clarify :

http://matthew16.free.fr/sql.jpg

This is what I get when I try to submit the form and I filled in field
password.
The users displayed in the pop-up are the MySQL users.

The php/sql code is the following :

mysql_select_db("mydb", $link) or die(mysql_error());
$query =
  "INSERT INTO members (username,password,date_of_birth,e_mail,country)
VALUES ('".
  $_POST['username']."','".
  $_POST['password']."','".
  $_POST['dateofbirth']."','".
  $_POST['email']."','".
  $_POST['country']."')";
$result = mysql_query($query, $link) or die($query . " - " . mysql_error());


Thank you for any help !
-- 
View this message in context: 
http://www.nabble.com/PhP---MySQL-problem-tf4349742.html#a12393567
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



[PHP] CAN'T GET OUT OF THIS LIST

2007-08-29 Thread Dave Howard Schiff

Please someone remove me! I can't get out!





___ 
Yahoo! Mail - Sempre a melhor opção para você! 
Experimente já e veja as novidades. 
http://br.yahoo.com/mailbeta/tudonovo/



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



Re: [PHP] Heredocs

2007-08-29 Thread Richard Lynch
I don't think you can have a space between the <<< and the 'END' bit...

On Wed, August 29, 2007 6:00 am, RodgerW wrote:
> Are heredocs supported by PP 5.2.3 running in WinXP/Apache2.2.4 ?
> I prrint via heredocs and its not working. Print with single quotes
> and
> double quotes work.
>
>   
>   string init method 3: heredocs
>  print <<< END
>   Test
>   END;
>   ?>
>   
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Please vote for this great band:
http://acl.mp3.com/feature/soundandjury/?band=COMPANY-OF-THIEVES

Requires email confirmation.
One vote per day per email limit.
Obvious ballot-stuffing will be revoked.

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



Re: [PHP] How to run and terminate C++ program(*.exe) with PHP?

2007-08-29 Thread Richard Lynch
On Wed, August 29, 2007 4:05 am, Aram Shatakhtsyan wrote:
> How to run C++ program(*.exe) with PHP, and then terminate it.

http://php.net/exec

-- 
Please vote for this great band:
http://acl.mp3.com/feature/soundandjury/?band=COMPANY-OF-THIEVES

Requires email confirmation.
One vote per day per email limit.
Obvious ballot-stuffing will be revoked.

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



Re: [PHP] Socket takes a long time to 'finish'

2007-08-29 Thread Richard Lynch
Try just leaving out the fclose($socket) and let PHP close it at the
end for you...

It's probably not IDEAL, but it may at least get you moving forward
with other bigger issues.

Check the http://bugs.php.net/ bugs as well -- Might be something in
there of use.  There will be a few zillion bogus ones for sockets
though... :-(

On Wed, August 29, 2007 3:40 am, Alvar Saenz-Otero wrote:
> Hello,
>
> I have a small but somewhat annoying issue.
>
> Whenever I open a socket to another server, the file is read very
> quickly, but it takes the up to 30 seconds or so to close the
> connection...
>
> Here is what I do:
>$sever = "server.mit.edu";
>$url = "/link";
>$port = 80;
>$user_agent = $_SERVER['HTTP_USER_AGENT'];
>$server_protocol = $_SERVER['SERVER_PROTOCOL'];
>
>$valsencoded = "";
>while (list($key,$value) = each ($content))
>   $valsencoded .= urlencode($key) . "=" . urlencode($value) ."&";
>$valsencoded = substr($urlencoded,0,-1);
>
>$content_length = strlen($valsencoded);
>
>$headers = "POST $url $server_protocol
> Content-Type: application/x-www-form-urlencoded
> Host: $server
> Content-Length: $content_length
>
> ";
>
>// open socket
>$socket = fsockopen($server, $port, $errno, $errstr, 60.0);
>if (!$socket) {
>  $error = "ERROR: cannot contact Mailman server";
>  return array(false,$error,$error); }
>
>if ($errstr) {
>  $error = "ERROR: fSockOpen Error ($errno): $errstr";
>  return array(false,$error,$error); }
>
>fputs($socket, $headers);  // send headers
>fputs($socket, $urlencoded);  // send post data
>
>// "tried stream_set_timeout($socket,3)" here
>
>// get the returned page
>while (!feof($socket))
>{
>  $buf = @fgets($socket, 2048);
>  $htmlreturned .= $buf;
>}
>fclose($socket);
>
> If I put a debug 'echo "BUF: $buf\n" inside the while loop, I see the
> returned html from the post show up pretty much immediately, within
> about a second, maybe less.
>
> However, the process 'stalls' after that for between 15-30 seconds,
> and
> then ends correctly.
>
> I have tried to use timeouts, but they did not have any effects (did
> not
> really expect them to, but just in case).
>
> My setup is Debian 4.0, php 5.2.0-8+etch7. Unfortunately I don't know
> the other server OS's/applications.
>
> I found similar questions in posts from 2002 and 2003, but there were
> no
> replies (2002-04-30 guido.d.berger and 2003-11-25 thomas weber).
>
> Any ideas greatly appreciated,
>
> Alvar
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Please vote for this great band:
http://acl.mp3.com/feature/soundandjury/?band=COMPANY-OF-THIEVES

Requires email confirmation.
One vote per day per email limit.
Obvious ballot-stuffing will be revoked.

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



Re: [PHP] Pragmatically changing a "Record Number"

2007-08-29 Thread Jason Pruim


On Aug 29, 2007, at 3:02 PM, Richard Lynch wrote:


On Wed, August 29, 2007 12:49 pm, Jason Pruim wrote:

I think after I get this question answered, I can stop asking for
awhile since my project will be done, at least until the users say
"What happened to XYZ" then I'll ask again :)

I asked on a MySQL list about "Resetting a auto increment filed" so
that there arn't any gaps in the record number.

So to say it another way, I have a table that has 900 records in it,
I've added 3 records, but then deleted 2 of those which puts the
actual record count at 901 but my auto increment field starts at 904
on the next insert.

Is there away with PHP that I can pragmatically change that value to
the total records in the database more so then a representation of
the actual record number?


Can you do this?

Sure.

update whatever set ID_field = 901 where ID_field = 904

Of course, if that 904 is in some OTHER table, then you MUST update
that other table at the same time, in an ACID transation, to be sure
you don't get your relationships all kerflummoxed.


Currently there is only the 1 table and it is going to stay that way...


SHOULD you do this?

NOO!!!

The ID key field of a record should not have any explicit meaning.

If you try to re-number your records so it does, it will just cause
you grief and give you nothing useful in return.

If you actualy have a table where there *IS* an ordering of the
records which is meaningful, and it really SHOULD be 1 to N, then add
another field "rank" (or somesuch) and manipulate that independent of
the ID field, which you should never care about its actual number.


Which is what I have figured out from the people on this list, I have  
decided to not play with the auto increment field, but the need I'm  
looking for hasn't changed, just the method.


in excel this would be the same as clearing the info in a row and  
then sorting it to take out the blank lines to get an accurate count  
of the total records.




To explain WHY this is, would be way bigger than an email that's
already off-topic for PHP, but they should have told you on the MySQL
list.

Or not, as it's probably in their FAQ which you should have read.

If nothing else, the hassle of keeping all those IDs sorted out is a
TON of extra code that serves little purpose, and a single tiny
mistake can make a pig's breakfast of your entire database.  Bad Idea.


No one has but it that plainly to me yet, and they are just  
suggesting ways to do it more then a don't do it type approach :)



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

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



Re: [PHP] Pragmatically changing a "Record Number"

2007-08-29 Thread Jason Pruim


On Aug 29, 2007, at 2:41 PM, Stephen wrote:


--- Jason Pruim <[EMAIL PROTECTED]> wrote:


So to say it another way, I have a table that has
900 records in it,
I've added 3 records, but then deleted 2 of those
which puts the
actual record count at 901 but my auto increment
field starts at 904
on the next insert.

Is there away with PHP that I can pragmatically
change that value to
the total records in the database more so then a
representation of
the actual record number?


Some database concepts:

The autoincrement feature is to provide a unique "key"
for the record. It does not provide an "order". Many
tables have more than one "order".

Usually a different field or field determines the
order(s). It usually has an index.

To provide a row number, based on some order, you need
a field for this. Whenever a field is deleted, you
would need to repopulate the fields in each record
after the deleted record in the database.


Which is exactly what I am trying to figure out :) in excel this  
would be the same as clearing the info in a row and then sorting it  
to take out the blank lines :)




I saw a nested SQL query that did this once, but my
SQL is not good enough to try to illustrate.


I'll keep looking, I'm sure there is away to do it, but playing with  
the auto incrementing column may not be the best idea...


Stephen

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




--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

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



Re: [PHP] Pragmatically changing a "Record Number"

2007-08-29 Thread Jason Pruim


On Aug 29, 2007, at 2:27 PM, Jim Lucas wrote:


Jason Pruim wrote:

3. Ask yourself, "Is it important to keep the auto-increment field
contiguous?"
The main reason for changing it is I do currently have an option  
to sort by record number, although, if I add a Record number in  
php, but still have it sort based off of the record number stored  
in the database, it would still sort right, but also look right...


Are you thinking mysql reuses auto-increment number?  If so, your  
mistaken.


No, I am aware that it doesn't reuse the auto increment numbers.


MySQL will not reuse an auto-increment unique value.

say you have an empty table with an auto-increment column.

You add 5 row

your next id to be used is 6.

if you delete id # 2 and 3

the next id to be used will still be 6 not 2


And what I'm looking for is away to take rows 4 and 5 and move them  
to rows 2 and 3 so the next record inserted would be row 4 :)




it does not go back and fill in the holes/gaps

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare




--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

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



Re: [PHP] Internet Explorer Caching

2007-08-29 Thread Charlene
I forgot to mention in my question that only IE appears to cache.  And 
with the way my PHP program goes, I'm constantly changing the URL as I 
go through the application to modify data and status message.  But 
whenever I return the the edit page, the old data is showing up.


Charlene

Richard Lynch wrote:

On Wed, August 29, 2007 10:43 am, Charlene wrote:
  

I've been having problems with Internet Explorer caching php programs.
I'm using the following code:

header("Cache-Control: no-cache, must-revalidate"); //
HTTP/1.1
header("Pragma", "no-cache");
header("Expires", "-1");

And it used to work, but now, according to Windows Explorer its giving
it 3 hours to expire.



The second argument to header() function will allow you to send
"duplicate" headers for the same header-name.

header("Pragma: no-cache");
header("Pragma: must-revalidate");

This is usually NOT what you want for headers, as MOST of them allow
only ONE instance.

So header("Pragma", "no-cache");
is sending a SECOND "Pragma" header.

Actually, as you have no ":" in there, it probably is sending it with
no ":", so it's really the first completely bogus "Pragma" header
which is doing absolutely nothing, and isn't a "Pragma:" header at
all.

I guess technically it's maybe not bogus...  You're allowed to extend
the HTTP protocol and send "extra" headers, but they're supposed to
start by "X-" by convention...

//legit
header("X-my-custom-header: 42");

//certainly not convention; probably not legit
header("My-custom-header: 42");

But it's sure not the "Pragma: no-cache" header you MEANT to send.

Ditto for Expires.

And double-ditto for the -1 value for "Expires", which I do not think
is a valid value.

Now IE may have decided to stop doing an interpretive dance around the
bogus headers you have been sending, and has decided it's time to make
you send the REAL headers.  Personally, I think it should never have
let you get away with it in the first place, but that's IE for ya.

ULTIMATELY, however, if you really really really want MS IE nor any
intermediary servers to cache something, your best bet is to add some
random bit to the URL:


can't cache
this

There is no combination of headers for no-cache that will actually
WORK for *ALL* legacy browsers.

Please Note: When I say *ALL* legacy browsers, I'm including
everything back to NCSA Mosiac and corporate re-branded IE with their
own nifty logo in place of the IE logo.

AT&T, for example, does/did this for their employees -- and the
version number may match exactly with the publicly-available IE, but
they don't behave the same, in my experience. :-(

Given that it's a heck of a lot easier to generate a random URL than
fiddle with so-called "no-cache" headers every time a bug report from
some browser you never even heard of rolls in, I strongly recommend
using a random URL.

YMMV

  


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



Re: [PHP] How to show proper time to users from around the world

2007-08-29 Thread Richard Lynch
On Wed, August 29, 2007 2:24 am, Hemanth wrote:
> Is there a solution to showing the proper time and date at user
> browsers
> and also recording proper USER times in the database operations in
> mysql

Not really.

You can use Javascript to get what the user's clock SAYS is the
date/time, but WAY too many users have their clocks set wrong, and
you'll never fix that.

You can ask them where they live, or ask them to input their own
time-zone.

Traveling users may prefer to use UTC or something as well, rather
than try to figure out what time-zone they are in this minute (cough
Indiana cough).

-- 
Please vote for this great band:
http://acl.mp3.com/feature/soundandjury/?band=COMPANY-OF-THIEVES

Requires email confirmation.
One vote per day per email limit.
Obvious ballot-stuffing will be revoked.

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



Re: [PHP] Re: Problems with matrix

2007-08-29 Thread Richard Lynch
Do you REALLY need all the values in one giant matrix at once?

You might be MUCH better off to read a single line, process it,
discard it, and move on to the next one.

Your webhost is probably wrong and you probably ARE running out of RAM
and/or running afoul of PHP's time_limit in php.ini

set_time_limit(60) inside the loop would fix the time limit thing.

Nothing you can do about the RAM thing, I don't think.

On Tue, August 28, 2007 10:58 pm, Felipe Alcacibar wrote:
> Andres Rojas wrote:
>> Hi all,
>>
>> I'm new in PHP programming and I have a problem with this script. I
>> need
>> to read a large file around 2Mb and several lines (28000). All start
>> Ok,
>> but suddenly the script stop without message error.
>>
>> >  $fichero="62007lg.txt";
>> $buffer = file($fichero);
>> $lineas = count($buffer);
>>
>>foreach($buffer as $linea){
>>
>> list($day, $month, $year, $hour, $min, $temp, $hum, $dew, $baro,
>> $wind, $gust, $wdir, $rlastm, $rdai, $rmon, $ryear,
>> $heat)=sscanf($linea,"%d %d %d %d %d %f %d %f %f %d %d %d %f %f %f
>> %f %f \n");
>>
>>  $mday[]=$day;
>>  $mmonth[]=$month;
>>  $myear[]=$year;
>>  $mhour[]=$hour;
>>  $mmin[]=$min;
>>  $mtemp[]=$temp;
>>  $mhum[]=$hum;
>>  $mdew[]=$dew;
>>  $mbaro[]=$baro;
>>  $mwind[]=$wind;
>>  $mgust[]=$gust;
>>  $mwdir[]=$wdir;
>>  $mrlastm[]=$rlastm;
>>  $mdai[]=$rdai;
>>  $mrmon[]=$rmon;
>>  $mryear[]=$ryear;
>>  $mheat[]=$heat;
>>  echo"$day $month $year $hour $min $temp $hum $dew $baro $wind $gust
>> $wdir $rlastm $rdai $rmon $ryear $heat ";
>>  }
>>
>>  ?>
>>
>> If only I print the variable $buffer all it's ok, but when I try to
>> fill
>> all the matrix the script doesn't work. If I reduce the number of
>> matrix
>> only a 3 o 4 it's Ok, but If I increase number of this matrix the
>> script
>> crash again.
>>
>> Perhaps it's a problem of memory of server, but my  service provider
>> say
>> me that this is not the problem.
>>
>>
>> Thank you very much
>
> Andres:
>
>  The info is too poor to see what is wrong, maybe you need to
> review
> a error_reporting() php function, o error_reporting php.ini variable i
> send you some code:
>
>  error_reporting(E_ALL);
>
>  $fichero="62007lg.txt";
>  $buffer = file($fichero);
>  $lineas = count($buffer);
>
> foreach($buffer as $linea){
>
>   $data = preg_split("/\s+/", trim($linea));
>   // trim removes all white spaces at the end and the beginning of
> the string.
>   $k = 0;
>   foreach(array(
>   'mday', 'mmonth',
>   'myear', 'mhour',
>   'mtemp',  'mhum',
>   'mdew', 'mbaro',
>   'mwind', 'mgust',
>   'mwdir',  'mrlastm',
>   'mrdai', 'mrmon',
>   'mryear', 'mheat' ) as $var )
>   {
>   if(!isset($$var)) $$var = array();
>  array_push($$var, $data[$k]);
>  echo $var." => ".$data[$k];
>   $k++;
>   }
>
> }
> ?>
>
> cheers!!
>
> Felipe Alcacibar
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Please vote for this great band:
http://acl.mp3.com/feature/soundandjury/?band=COMPANY-OF-THIEVES

Requires email confirmation.
One vote per day per email limit.
Obvious ballot-stuffing will be revoked.

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



Re: [PHP] Internet Explorer Caching

2007-08-29 Thread Charlene
I had used something similar in another iteration of trying to fix the 
caching problem in IE.  I tried these lines again, and they don't work.  
It is only IE that is caching.


Charlene

Satyam wrote:

I'm sending these headers:

  header('Cache-Control: no-cache, must-revalidate'); // HTTP/1.1
  header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the 
past


I don't remember where I took them from, but they are working fine for 
me.


Satyam


- Original Message - From: "Richard Heyes" <[EMAIL PROTECTED]>
To: "Charlene" <[EMAIL PROTECTED]>
Cc: 
Sent: Wednesday, August 29, 2007 5:50 PM
Subject: Re: [PHP] Internet Explorer Caching



Charlene wrote:
I've been having problems with Internet Explorer caching php 
programs. I'm using the following code:


   header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
   header("Pragma", "no-cache");
   header("Expires", "-1");

And it used to work, but now, according to Windows Explorer its 
giving it 3 hours to expire.


Are you sure? By default PHP pages/scripts don't send any caching 
headers and hence don't get cached. You can check this using: 
http://www.fiddlertool.com


--
Richard Heyes
+44 (0)844 801 1072
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support

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



--
No virus found in this incoming message.
Checked by AVG Free Edition. Version: 7.5.484 / Virus Database: 
269.12.10/977 - Release Date: 28/08/2007 16:29








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



Re: [PHP] Perhaps an incomplete $_POST

2007-08-29 Thread Kirk Friggstad
To the best of my knowledge, the "name" attribute of the FORM tag is
never submitted with the request, whether it be GET or POST. It's
there for client-side scripting (JavaScript, etc.) only.

One trick that might help you - if your form action is POST, add a
querystring to the action, something like "foo.php?formname=foo", then
check $_GET['formname']. Of course, it might be just as easy to drop
in a hidden input instead.

Hope this helps.

On 8/29/07, Jay Blanchard <[EMAIL PROTECTED]> wrote:
> I just noticed something a little odd, and maybe there is a simple
> solution. Given a form;
>
> 
>
> The attributes, especially the name "foo", never appear in any variables
> array. I am thinking that this might be handy to have for several
> reasons when processing the form. I have several reasons for needing the
> information, does anyone know how to get this in the processing script
> without having to add hidden fields or do some Ajax magic?

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



Re: [PHP] Re: Disadvantages of output buffering

2007-08-29 Thread Richard Lynch
On Tue, August 28, 2007 6:40 pm, Felipe Alcacibar wrote:
> Emil Edeholt wrote:
>> Hi!
>>
>> My php project would get a much cleaner code if I could set cookies
>> anywhere in the code. So I thought of output buffering. But I can't
>> find
>> any articles on the cons of output buffering. I mean it most be a
>> reason
>> for it being off by default?
>>
>> Kind Regards Emil Edeholt
>
>
> The output buffering maybe would be unstable your php application  in
> some cases. May be it so slowly in some versions of php and depend of
> the web server that you have mounted your php. And it uses memory this
> point is so clearly.
>
> If you want to create cookies server/client "on the fly" you may need
> ajax, with this asynchronus requests you put headers and cookies
> instead, and use it on the fly in the browser if the http request is
> ok.
>
> Are you know the session variables, maybe you need that.
>
> Well, the desicion is yours. tell us what you want to do.

It's probably off by default for a couple reasons:

#1. It didn't used to exist, so to be backwards-compatible, it's off.

#2. It does chew up a lot of RAM for a large HTML file, which if you
don't need it, is Bad.

#3. Your page can seem to be "slow" if it's fairly large, and laid out
to not require the whole page to render the first portion of the page.
(No tables, and probably no CSS, just old-school simple HTML).

Note, however, that if you have a lot of little echo statements,
output buffering can actually improve overall performance, since it
doesn't dink around with sending a few bytes at a time and switching
back and forth from output to calculations.  Depends on your
application and a whole host of other variables.

-- 
Please vote for this great band:
http://acl.mp3.com/feature/soundandjury/?band=COMPANY-OF-THIEVES

Requires email confirmation.
One vote per day per email limit.
Obvious ballot-stuffing will be revoked.

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



RE: [PHP] Regular expression - URL validator

2007-08-29 Thread Richard Lynch
Yes, make sure you have http:// on the front.

http://$link";;
?>

On Tue, August 28, 2007 3:22 pm, Wagner Garcia Campagner wrote:
> Thanks Jim,
>
> Your sugestion worked perfect for me!!
>
> I have another question:
>
> After i validate this URL i want to put a link with this URL in my
> page.
>
> The problem is that if the URL is like (www.aol.com), when i create
> the
> link, this URL is appended with the URL of my site. The result is a
> link
> pointing to: http:///www.aol.com
>
> But if the URL is like (http://aol.com), then the link is created
> correct.
>
> Is there a way to avoid the first situation... so the link is created
> correct?
>
> Thanks again,
> Wagner.
>
>
>
> -Original Message-
> From: Jim Lucas [mailto:[EMAIL PROTECTED]
> Sent: segunda-feira, 27 de agosto de 2007 17:36
> To: PHP General; [EMAIL PROTECTED]
> Subject: Re: [PHP] Regular expression - URL validator
>
>
> Wagner Garcia Campagner wrote:
>  > Hello,
>  >
>  > I found this regular expression on a web site.
>  > It is basicaly an URL validator.
>  >
>  > I'm trying to implement this in my web site, but i receive errors.
>  >
>  > I think this is a PERL REGEX so what should i do to make it work in
> php?
>  >
>  >
>  > $valid =
>  >
> (preg_match('^H|h)(T|t)|(F|f))(T|t)(P|p)((S|s)?))\://)?(www.|[a-zA-Z0-9]
>  >
> .)[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,6}(\:[0-9]{1,5})*(/($|[a-zA-Z0-9\.\,\;\?\'\\\
>  > +&%\$#\=~_\-]+))*$', $_POST['website']));
>
> This should be preg_match('/.../i', $_POST['website'])
>
> your regex should look something like this.
>
> ^((ftp|(http(s)?))://)?(\.?([a-z0-9-]+))+\.[a-z]{2,6}(:[0-9]{1,5})?(/[a-zA-Z
> 0-9.,;\?|\'+&%\$#=~_-]+)*$
>
> So, put it all together and it should look like this.
>
> 
> $url = "...PUT YOUR TEST URL HERE...";
>
> if (
> preg_match('!^((ftp|(http(s)?))://)?(\.?([a-z0-9-]+))+\.[a-z]{2,6}(:[0-9]{1,
> 5})?(/[a-zA-Z0-9.,;\?|\'+&%\$#=~_-]+)*$!i',
> $url) ) {
>   echo "Matched";
> } else {
>   echo "Did not match";
> }
>
>
>
>
>  >
>  > if ($valido == 0) {
>  > something here;
>  > }
>  > else {
>  > something else here;
>  > }
>  >
>  >
>  > Thanks a lot in advance,
>  > Wagner.
>  >
>
>
>
> --
> Jim Lucas
>
> "Some men are born to greatness, some achieve greatness,
> and some have greatness thrust upon them."
>
> Twelfth Night, Act II, Scene V
>  by William Shakespeare
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Please vote for this great band:
http://acl.mp3.com/feature/soundandjury/?band=COMPANY-OF-THIEVES

Requires email confirmation.
One vote per day per email limit.
Obvious ballot-stuffing will be revoked.

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



Re: [PHP] sybase installation error

2007-08-29 Thread Richard Lynch
It's not finding your Sybase client libraries.

Why, how, or where, I dunno...

Check config.log and see what it says about Sybase.

Also make sure that the Sybase .so library file thingies are where PHP
thinks they will be.

If they are not, you can sometimes just put a symlink from where PHP
is looking to where they really are, and that will fix it.

On Tue, August 28, 2007 9:53 am, Melanie Pfefer wrote:
> hi,
>
> I am getting an error when I issue 'make' command:
>
> ../configure --with-apxs2=/usr/local/apache/bin/apxs
> --with-sybase-ct=/opt/sybase/OCS-12_5
>
> it finishes with:
>
> ld: fatal: library -lsybtcl: not found
> ld: fatal: File processing errors. No output written
> to .libs/libphp5.so
> collect2: ld returned 1 exit status
> *** Error code 1
> make: Fatal error: Command failed for target `libphp5.la'
>
>
>   ___
> Yahoo! Answers - Got a question? Someone out there knows the answer.
> Try it
> now.
> http://uk.answers.yahoo.com/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Please vote for this great band:
http://acl.mp3.com/feature/soundandjury/?band=COMPANY-OF-THIEVES

Requires email confirmation.
One vote per day per email limit.
Obvious ballot-stuffing will be revoked.

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



Re: [PHP] Heredocs

2007-08-29 Thread Daniel Brown
On 8/29/07, Richard Lynch <[EMAIL PROTECTED]> wrote:
> I don't think you can have a space between the <<< and the 'END' bit...
>
> On Wed, August 29, 2007 6:00 am, RodgerW wrote:
> > Are heredocs supported by PP 5.2.3 running in WinXP/Apache2.2.4 ?
> > I prrint via heredocs and its not working. Print with single quotes
> > and
> > double quotes work.
> >
> >   
> >   string init method 3: heredocs
> >>   print <<< END
> >   Test
> >   END;
> >   ?>
> >   
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
> --
> Please vote for this great band:
> http://acl.mp3.com/feature/soundandjury/?band=COMPANY-OF-THIEVES
>
> Requires email confirmation.
> One vote per day per email limit.
> Obvious ballot-stuffing will be revoked.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Additionally, I don't believe that the END; used to terminate the
HEREDOC block in this code should be indented.  To my understanding,
the terminator must begin the line, regardless of the position of the
initiator, like so:



-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Hey, PHP-General list
50% off for life on web hosting plans $10/mo. or more at
http://www.pilotpig.net/.
Use the coupon code phpgeneralaug07
Register domains for about $0.01 more than what it costs me at
http://domains.pilotpig.net/.

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



Re: [PHP] CAN'T GET OUT OF THIS LIST

2007-08-29 Thread Jim Lucas

Dave Howard Schiff wrote:

Please someone remove me! I can't get out!




   
___ Yahoo! Mail - 
Sempre a melhor opção para você! Experimente já e veja as novidades. 
http://br.yahoo.com/mailbeta/tudonovo/



dud, check out this link

http://www.php.net/unsub.php

check the archives for similar problems.

Most common:
make sure you are using the correct email address to unsubscribe with.
make sure that you didn't signup with a different email address and
have it redirected to a different email address/account.
make sure you are responding to and or confirming the request in the 
email account.

Last ditch effort, close this email account for about a week, once a few messages bounce, the system 
will send you a notice that it needs to confirm you are still there.


If that fails, or no response is received within a few days, the system will 
take your
email address out of the list.

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] PhP / MySQL problem

2007-08-29 Thread Ludovic André



Hi,

I created a form asking username, password, country, etc.
On the submit of this form I make a sql connection and update the database,
add the user.

The problem is that whenever the field 'password' is filled in,
"it" (I don't know what) is asking to confirm the change of the password.

I made a printscreen to clarify :

http://matthew16.free.fr/sql.jpg

This is what I get when I try to submit the form and I filled in field
password.
The users displayed in the pop-up are the MySQL users.
This has nothing to do with your PHP/MySQL, but it's a feature of your 
browser (you're using Firefox, aren't you?)
Did you use the functionnality "remember the password" ? If so, then the 
users listed here are the ones for whom you wanted to remember the 
password. Firefox tries to be smart in this case: if you're updating the 
password, it asks you which user has changed...


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



Re: [PHP] PhP / MySQL problem

2007-08-29 Thread Richard Lynch
On Wed, August 29, 2007 2:03 pm, debussy007 wrote:
> I created a form asking username, password, country, etc.
> On the submit of this form I make a sql connection and update the
> database,
> add the user.
>
> The problem is that whenever the field 'password' is filled in,
> "it" (I don't know what) is asking to confirm the change of the
> password.
>
> I made a printscreen to clarify :
>
> http://matthew16.free.fr/sql.jpg
>
> This is what I get when I try to submit the form and I filled in field
> password.
> The users displayed in the pop-up are the MySQL users.
>
> The php/sql code is the following :
>
> mysql_select_db("mydb", $link) or die(mysql_error());
> $query =
>   "INSERT INTO members
> (username,password,date_of_birth,e_mail,country)
> VALUES ('".
>   $_POST['username']."','".
>   $_POST['password']."','".
>   $_POST['dateofbirth']."','".
>   $_POST['email']."','".
>   $_POST['country']."')";
> $result = mysql_query($query, $link) or die($query . " - " .
> mysql_error());

I believe that browser is configured to "remember" passwords (BAD
IDEA!!!) and is asking you to confirm the change for its local memory.

I am 100% certain that whatever it is, it ain't PHP doing it. :-)

-- 
Please vote for this great band:
http://acl.mp3.com/feature/soundandjury/?band=COMPANY-OF-THIEVES

Requires email confirmation.
One vote per day per email limit.
Obvious ballot-stuffing will be revoked.

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



Re: [PHP] Round

2007-08-29 Thread Koen van den Boogaart
Some information from Wikipedia: http://en.wikipedia.org/wiki/Negative_zero. 
Says in math a negative zero doesn't exist, in computing it does. Strange 
thing is that PHP4 and 5 until at least 5.1.6 (see Jim Lucas) round() gives 
a float(0) and then 5.2.3 gives float(-0). I'll report a bug.

""Richard Lynch"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On Wed, August 29, 2007 11:38 am, Zoltán Németh wrote:
>> 2007. 08. 29, szerda keltezéssel 09.29-kor Jim Lucas ezt írta:
>>> Daniel Brown wrote:
>>> > On 8/29/07, Richard Heyes <[EMAIL PROTECTED]> wrote:
>>> >> Koen van den Boogaart wrote:
>>> >>> No, I want it to go to float(0), so minus the minus. "-0"
>>> doesn't exist in
>>> >>> math, as far as I know. Probably a precision thing.
>
> I missed the start of this thread...
>
> Technically, -0 exists and is a tautology to +0.
>
> That said, PHP should not be outputting -0 for a round() operation,
> nor abs() for that matter.
>
> Check http://bugs.php.net with your PHP version for a similar problem.
>
> -- 
> Please vote for this great band:
> http://acl.mp3.com/feature/soundandjury/?band=COMPANY-OF-THIEVES
>
> Requires email confirmation.
> One vote per day per email limit.
> Obvious ballot-stuffing will be revoked. 

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



Re: [PHP] Internet Explorer Caching

2007-08-29 Thread Richard Lynch
On Wed, August 29, 2007 2:10 pm, Charlene wrote:
> I forgot to mention in my question that only IE appears to cache.  And
> with the way my PHP program goes, I'm constantly changing the URL as I
> go through the application to modify data and status message.  But
> whenever I return the the edit page, the old data is showing up.

Ah!

"old data" as in "This is what you typed into the form last time you
were here, so this is what you must want in the form this time, no
matter what is in the HTML for the default value, because we are
Microsoft, and our users are stupid and this is what they want"?

You're pretty much dealing with a browser behaviour, I think, and
people dumb enough to use IE actually expect it to work that way, and
trying to fix it is probably a mistake.

-- 
Please vote for this great band:
http://acl.mp3.com/feature/soundandjury/?band=COMPANY-OF-THIEVES

Requires email confirmation.
One vote per day per email limit.
Obvious ballot-stuffing will be revoked.

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



Re: [PHP] Perhaps an incomplete $_POST

2007-08-29 Thread Richard Lynch
On Wed, August 29, 2007 2:01 pm, Jay Blanchard wrote:
> I just noticed something a little odd, and maybe there is a simple
> solution. Given a form;
>
> 
>
> The attributes, especially the name "foo", never appear in any
> variables
> array. I am thinking that this might be handy to have for several
> reasons when processing the form. I have several reasons for needing
> the
> information, does anyone know how to get this in the processing script
> without having to add hidden fields or do some Ajax magic?

No.

The FORM name attribute is simply not sent as part of the HTTP protocol.

Maybe they shoulda thought of that in the beginning and done it, but
doesn't happen and won't change soon.

Add a hidden input or don't Design you application to know which form
name it was.

-- 
Please vote for this great band:
http://acl.mp3.com/feature/soundandjury/?band=COMPANY-OF-THIEVES

Requires email confirmation.
One vote per day per email limit.
Obvious ballot-stuffing will be revoked.

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



Re: [PHP] PhP / MySQL problem

2007-08-29 Thread debussy007

I'm using FF.
But it asks to confirm the change of password of my MySQL users.
If I comment the php/mysql lines in the .php files,
I do not have such a pop-up.



Ludovic André wrote:
> 
> 
>> Hi,
>>
>> I created a form asking username, password, country, etc.
>> On the submit of this form I make a sql connection and update the
>> database,
>> add the user.
>>
>> The problem is that whenever the field 'password' is filled in,
>> "it" (I don't know what) is asking to confirm the change of the password.
>>
>> I made a printscreen to clarify :
>>
>> http://matthew16.free.fr/sql.jpg
>>
>> This is what I get when I try to submit the form and I filled in field
>> password.
>> The users displayed in the pop-up are the MySQL users.
> This has nothing to do with your PHP/MySQL, but it's a feature of your 
> browser (you're using Firefox, aren't you?)
> Did you use the functionnality "remember the password" ? If so, then the 
> users listed here are the ones for whom you wanted to remember the 
> password. Firefox tries to be smart in this case: if you're updating the 
> password, it asks you which user has changed...
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/PhP---MySQL-problem-tf4349742.html#a12394801
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] Perhaps an incomplete $_POST

2007-08-29 Thread Ludovic André
Yep, the form name is never submitted with the form info.  However, the 
submit button will be submitted along.
So, as an alternative, you could name the submit button in a way to 
recognize the submitted form:


...



Ludo

To the best of my knowledge, the "name" attribute of the FORM tag is
never submitted with the request, whether it be GET or POST. It's
there for client-side scripting (JavaScript, etc.) only.

One trick that might help you - if your form action is POST, add a
querystring to the action, something like "foo.php?formname=foo", then
check $_GET['formname']. Of course, it might be just as easy to drop
in a hidden input instead.

Hope this helps.

On 8/29/07, Jay Blanchard <[EMAIL PROTECTED]> wrote:
  

I just noticed something a little odd, and maybe there is a simple
solution. Given a form;



The attributes, especially the name "foo", never appear in any variables
array. I am thinking that this might be handy to have for several
reasons when processing the form. I have several reasons for needing the
information, does anyone know how to get this in the processing script
without having to add hidden fields or do some Ajax magic?



  


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



[PHP] Re: Heredocs

2007-08-29 Thread zerof

RodgerW escreveu:

Are heredocs supported by PHP 5.2.3 running in WinXP/Apache2.2.4 ?
I prrint via heredocs and its not working. Print with single quotes and 
double quotes work.



string init method 3: heredocs
END;   
?>



-
An example:

Cupidatat non proident,
  velit esse cillum dolore ut labore et dolore magna
  aliqua.Lorem ipsum dolor sit amet, mollit anim id
  est laborum.Ut enim ad minim veniam, excepteur sint
  occaecat sed do eiusmod tempor incididunt.
  "Lorem Ipsum"
IDF;

echo $est01;

?>
--
zerof
http://www.educar.pro.br/
Apache - PHP - MySQL - Boolean Logics - Project Management
--
Você deve, sempre, consultar uma segunda opinião!
--
Deixe todos saberem se esta informação foi-lhe útil.
--  
You must hear, always, one second opinion! In all cases.
--
Let the people know if this info was useful for you!
--

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



RE: [PHP] Pragmatically changing a "Record Number"

2007-08-29 Thread Bastien Koert

Please don't do that...autonumber should not be relied for anything other than 
a unique row identifier. It should NOT matter to the application what that 
value is as long as it unique. If you need a count of the number of records, do 
a query (select count(*) from table...)
 
bastien> To: php-general@lists.php.net> From: [EMAIL PROTECTED]> Date: Wed, 29 
Aug 2007 13:49:02 -0400> Subject: [PHP] Pragmatically changing a "Record 
Number"> > Hi Everyone,> > I think after I get this question answered, I can 
stop asking for > awhile since my project will be done, at least until the 
users say > "What happened to XYZ" then I'll ask again :)> > I asked on a 
MySQL list about "Resetting a auto increment filed" so > that there arn't any 
gaps in the record number.> > So to say it another way, I have a table that has 
900 records in it, > I've added 3 records, but then deleted 2 of those which 
puts the > actual record count at 901 but my auto increment field starts at 904 
> on the next insert.> > Is there away with PHP that I can pragmatically change 
that value to > the total records in the database more so then a representation 
of > the actual record number?> > > --> > Jason Pruim> Raoset Inc.> Technology 
Manager> MQC Specialist> 3251 132nd ave> Holland, MI, 49424> www.raoset.com> 
[EMAIL PROTECTED]> > 
_
Explore the seven wonders of the world
http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE

[PHP] date formatting

2007-08-29 Thread Mike Ryan
I would like to have my users input the date formate as mm-dd- mysql
wants the data to come down as -mm-dd.

The question I have is how do I convert from the mm-dd- to -mm-dd so
that I can write it out to the database?

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



[PHP] Re: About Session And Cookies

2007-08-29 Thread tedd

At 10:52 PM +0200 8/18/07, Michelle Konzack wrote:

Am 2007-08-17 22:07:47, schrieb Bastien Koert:


 If cookies are not available, you can either

 hide the id in the hidden form field element
 or
 enable trans_sid to automatically pass the session id in the url


This will be a security risk since Session-Hijacker can grap the URL

Greetings
Michelle Konzack
Systemadministrator
Tamay Dogan Network
Debian GNU/Linux Consultant


When the user first generates a session id, grab the user's ip and 
store both in mysql.


In the code, always check the session id against the user's ip before 
doing anything. If they don't match with what you started with, then 
stop. That should stop most Session-Hijackers, don't you think?


Cheers,

tedd

PS; Back from vacation, and all ready to be retrained.
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] date formatting

2007-08-29 Thread Wolf
Just have your input form get it in sections, then piece it all together when 
dumping it to MySQL

This way you can transparent the code on the front to users, but have it in the 
right format in the backend.

 Mike Ryan <[EMAIL PROTECTED]> wrote: 
> I would like to have my users input the date formate as mm-dd- mysql
> wants the data to come down as -mm-dd.
> 
> The question I have is how do I convert from the mm-dd- to -mm-dd so
> that I can write it out to the database?
> 
> -- 
> 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



[PHP] Re: [WD]: PHP Question - any help is appreciated

2007-08-29 Thread brian

Dylan Barber wrote:

I am needing to provide back a fixed length file out of a shopping
cart system - I can create the file but does anybody have a simple
function to pad or truncate a string to a certain length?



Use sprintf() to format your string.

$len = 20 //the length you want
$str = 'abcde';

The following says to pad the string with the character x to a final 
length of $len characters or to trim the string to $len characters. The 
% is simply there to show that the argument is a formatting instruction. 
The "'x" says to use an x as the padding character (default is a space). 
The s informs that we're performing this on a string, as opposed to a 
number.


echo sprintf("%'x${len}.${len}s", $str);
xxxabcde


This one will add the padding to the end (note the minus sign):

echo sprintf("%-'x${len}.${len}s", $str);
abcdexxx


If you want the default space, use:

echo sprintf("%${len}.${len}s", $str);
   abcde


Truncate:

$str = 'abcdefghijklmnopqrstuvwxyz';
echo sprintf("%'x${len}.${len}s", $str);
abcdefghijklmnopqrst


You probably want to assign this to a variable so, instead of using 
echo, do:


$padded = sprintf("%'x${len}.${len}s", $str);

HTH
brian

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



Re: [PHP] Re: About Session And Cookies

2007-08-29 Thread Kirk Friggstad
On 8/29/07, tedd <[EMAIL PROTECTED]> wrote:
> When the user first generates a session id, grab the user's ip and
> store both in mysql.
>
> In the code, always check the session id against the user's ip before
> doing anything. If they don't match with what you started with, then
> stop. That should stop most Session-Hijackers, don't you think?

I can't comment on session hijacking, but you might be breaking
sessions for some users by this. AOL, for example, uses multiple proxy
servers for all their users' traffic
(http://webmaster.info.aol.com/proxyinfo.html), so it is quite
possible that requests from one user with the same session token
(cookie, hidden form field, etc.) could come from multiple IP
addresses. I suspect you'd see something similar for Tor users
(http://tor.eff.org/).

According to Wikipedia (http://en.wikipedia.org/wiki/WP:AOLA), AOL
includes an X-Forwarded-For header in any proxy requests that includes
the actual client's IP address - if you really want to tie a session
token to a particular IP address, you could check for this header as
well. X-Forwarded-For won't help with Tor users, of course, but I
don't know how large of a section of your user base that would
affect...

Kirk

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



Re: [PHP] Re: About Session And Cookies

2007-08-29 Thread Richard Lynch
On Wed, August 29, 2007 4:33 pm, tedd wrote:
> At 10:52 PM +0200 8/18/07, Michelle Konzack wrote:
>>Am 2007-08-17 22:07:47, schrieb Bastien Koert:
>>>
>>>  If cookies are not available, you can either
>>>
>>>  hide the id in the hidden form field element
>>>  or
>>>  enable trans_sid to automatically pass the session id in the url
>>
>>This will be a security risk since Session-Hijacker can grap the URL
>>
>>Greetings
>> Michelle Konzack
>> Systemadministrator
>> Tamay Dogan Network
>> Debian GNU/Linux Consultant
>
> When the user first generates a session id, grab the user's ip and
> store both in mysql.
>
> In the code, always check the session id against the user's ip before
> doing anything. If they don't match with what you started with, then
> stop. That should stop most Session-Hijackers, don't you think?
>
> Cheers,
>
> tedd
>
> PS; Back from vacation, and all ready to be retrained.

You have just booted all AOL users from your website.

They change IP address every request sometimes.

IP is absolutely useless for identification.

-- 
Please vote for this great band:
http://acl.mp3.com/feature/soundandjury/?band=COMPANY-OF-THIEVES

Requires email confirmation.
One vote per day per email limit.
Obvious ballot-stuffing will be revoked.

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



Re: [PHP] date formatting

2007-08-29 Thread Richard Lynch


On Wed, August 29, 2007 4:12 pm, Mike Ryan wrote:
> I would like to have my users input the date formate as mm-dd-
> mysql
> wants the data to come down as -mm-dd.
>
> The question I have is how do I convert from the mm-dd- to
> -mm-dd so
> that I can write it out to the database?

You could tell MySQL to use the mm-dd- input format I think.  Ask
on a mysql list.

In PHP:



die() is probably a bit extreme for this, but it's a start.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Please vote for this great band:
http://acl.mp3.com/feature/soundandjury/?band=COMPANY-OF-THIEVES

Requires email confirmation.
One vote per day per email limit.
Obvious ballot-stuffing will be revoked.

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



[PHP] Re: Heredocs

2007-08-29 Thread Al

Suggestion

Write your code like this and you'll be less likely to err and your code will be 
more readable. You can even put variables inside the heredoc.



string init method 3: heredocs
Your test text

txt;

print $str;
?>




RodgerW wrote:

Are heredocs supported by PP 5.2.3 running in WinXP/Apache2.2.4 ?
I prrint via heredocs and its not working. Print with single quotes and 
double quotes work.



string init method 3: heredocs
END;   
?>




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



Re: [PHP] Internet Explorer Caching

2007-08-29 Thread Charlene
Unfortunately I don't have a choice.  I have to be able to handle IE. 

And IE is caching the page.  I can see it in my Temporary Internet Files 
folder.  And the Expiration Date is 3 hours after the file is created.  
If I delete the file, a new one is created and the Expiration Date is 3 
hours after the new file is created.


Charlene

Richard Lynch wrote:

On Wed, August 29, 2007 2:10 pm, Charlene wrote:
  

I forgot to mention in my question that only IE appears to cache.  And
with the way my PHP program goes, I'm constantly changing the URL as I
go through the application to modify data and status message.  But
whenever I return the the edit page, the old data is showing up.



Ah!

"old data" as in "This is what you typed into the form last time you
were here, so this is what you must want in the form this time, no
matter what is in the HTML for the default value, because we are
Microsoft, and our users are stupid and this is what they want"?

You're pretty much dealing with a browser behaviour, I think, and
people dumb enough to use IE actually expect it to work that way, and
trying to fix it is probably a mistake.

  


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



Re: [PHP] Internet Explorer Caching

2007-08-29 Thread Charlene
Unfortunately I don't have a choice.  I have to be able to handle IE. 

And IE is caching the page.  I can see it in my Temporary Internet Files 
folder.  And the Expiration Date is 3 hours after the file is created.  
If I delete the file, a new one is created and the Expiration Date is 3 
hours after the new file is created.


Charlene

Richard Lynch wrote:

On Wed, August 29, 2007 2:10 pm, Charlene wrote:
  

I forgot to mention in my question that only IE appears to cache.  And
with the way my PHP program goes, I'm constantly changing the URL as I
go through the application to modify data and status message.  But
whenever I return the the edit page, the old data is showing up.



Ah!

"old data" as in "This is what you typed into the form last time you
were here, so this is what you must want in the form this time, no
matter what is in the HTML for the default value, because we are
Microsoft, and our users are stupid and this is what they want"?

You're pretty much dealing with a browser behaviour, I think, and
people dumb enough to use IE actually expect it to work that way, and
trying to fix it is probably a mistake.

  


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



Re: [PHP] Internet Explorer Caching

2007-08-29 Thread Jim Lucas

Charlene wrote:

Unfortunately I don't have a choice.  I have to be able to handle IE.
And IE is caching the page.  I can see it in my Temporary Internet Files 
folder.  And the Expiration Date is 3 hours after the file is created.  
If I delete the file, a new one is created and the Expiration Date is 3 
hours after the new file is created.


Charlene

Richard Lynch wrote:

On Wed, August 29, 2007 2:10 pm, Charlene wrote:
 

I forgot to mention in my question that only IE appears to cache.  And
with the way my PHP program goes, I'm constantly changing the URL as I
go through the application to modify data and status message.  But
whenever I return the the edit page, the old data is showing up.



Ah!

"old data" as in "This is what you typed into the form last time you
were here, so this is what you must want in the form this time, no
matter what is in the HTML for the default value, because we are
Microsoft, and our users are stupid and this is what they want"?

You're pretty much dealing with a browser behavior, I think, and
people dumb enough to use IE actually expect it to work that way, and
trying to fix it is probably a mistake.

  




It could be that your browser is overriding the cache settings.

In IE go to
Tools -> Internet Options -> General -> (history)Settings

make sure it is set to either Automatically or "Every visit to the page"

if it is form data that keeps returning, go to

Tools -> Internet Options -> Content -> AutoComplete

And make sure that Forms is not checked in the list of items

Hope this helps

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