|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general Digest 8 Jul 2005 03:17:40 -0000 Issue 3555
php-general-digest-help
lists.php.net
Date: Thu Jul 07 2005 - 22:17:40 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 8 Jul 2005 03:17:40 -0000 Issue 3555
Topics (messages 218293 through 218329):
Question to eregi Syntax
218293 by: janbro
218295 by: M. Sokolewicz
218296 by: janbro
218301 by: Philip Hallstrom
218302 by: M. Sokolewicz
218303 by: M. Sokolewicz
218307 by: david forums
218308 by: Shaw, Chris - Accenture
Re: Display picture from MySQL
218294 by: Miles Thompson
218312 by: Bagus Nugroho
218316 by: Richard Lynch
Re: date() problem
218297 by: Kristen G. Thorson
218298 by: Ryan A
PEAR and stored procedures
218299 by: Chris Boget
218305 by: Nathan Tobik
Re: Formating
218300 by: Bruno B B Magalhães
Re: alternative to empty
218304 by: xfedex
How to read a cookie when path variable is different(Not default)
218306 by: Lenka, Bibhu Kalyan
218317 by: Richard Lynch
TimeStamp BEFORE 1970
218309 by: Bruno B B Magalhães
218310 by: Richard Davey
218323 by: Bruno B B Magalhães
218325 by: Bruno B B Magalhães
218328 by: Edward Vermillion
218329 by: Bruno B B Magalhães
Problem serializing a mysqli_result object.
218311 by: Bjarke Freund-Hansen
218314 by: Bjarke Freund-Hansen
218315 by: Richard Lynch
iPowerWeb ISP Are they good?
218313 by: Jason Manaigre
Re: Problems with the ZLIB
218318 by: Richard Lynch
Re: Strange Problem: session_set_save_handler
218319 by: Richard Lynch
Re: Apache htpasswd
218320 by: Richard Lynch
218322 by: Javier
msdos date/time encoding in php?
218321 by: Andy Pieters
from tree/hirarki format to table format
218324 by: Feriyanto
url reload
218326 by: timothy johnson
Screen Scraping with php
218327 by: Graham Anderson
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
Hi List,
my research hasn't turned anything useful up.
Probably 'cause I don't have enough info.
I've been playing around with the ereg function.
What I was wondering is what is the ^ for like
in the below example?
ereg('[^[:space:]a-zA-Z0-9_.-]{1,}', $name)
thx
janbro
attached mail follows:
janbro wrote:
> Hi List,
> my research hasn't turned anything useful up.
> Probably 'cause I don't have enough info.
> I've been playing around with the ereg function.
> What I was wondering is what is the ^ for like
> in the below example?
> ereg('[^[:space:]a-zA-Z0-9_.-]{1,}', $name)
>
> thx
> janbro
it denotes the "start of the string"
This might help (although it's for PCRE syntax, the POSIX (ereg(i))
syntax is very similair):
http://www.php.net/manual/en/reference.pcre.pattern.syntax.php
This is the manpage for the POSIX syntax: (might be a bit harder to read
if you're just starting)
http://www.tin.org/bin/man.cgi?section=7&topic=regex
attached mail follows:
thx, that's what I've figured. but looking for ^ with any
search engine won't give you anything useful.
thx
JaNbro
M. Sokolewicz schrieb:
> janbro wrote:
>
>> Hi List,
>> my research hasn't turned anything useful up.
>> Probably 'cause I don't have enough info.
>> I've been playing around with the ereg function.
>> What I was wondering is what is the ^ for like
>> in the below example?
>> ereg('[^[:space:]a-zA-Z0-9_.-]{1,}', $name)
>>
>> thx
>> janbro
>
> it denotes the "start of the string"
> This might help (although it's for PCRE syntax, the POSIX (ereg(i))
> syntax is very similair):
> http://www.php.net/manual/en/reference.pcre.pattern.syntax.php
>
> This is the manpage for the POSIX syntax: (might be a bit harder to read
> if you're just starting)
> http://www.tin.org/bin/man.cgi?section=7&topic=regex
attached mail follows:
> janbro wrote:
>> Hi List,
>> my research hasn't turned anything useful up.
>> Probably 'cause I don't have enough info.
>> I've been playing around with the ereg function.
>> What I was wondering is what is the ^ for like
>> in the below example?
>> ereg('[^[:space:]a-zA-Z0-9_.-]{1,}', $name)
>>
>> thx
>> janbro
> it denotes the "start of the string"
Actually, in the above case it doesn't... from the URL referenced...
For example, the character class [aeiou] matches any lower case vowel,
while [^aeiou] matches any character that is not a lower case vowel.
If the ^ is outside of the []'s then it matches the start of the string...
-philip
attached mail follows:
Philip Hallstrom wrote:
>> janbro wrote:
>>
>>> Hi List,
>>> my research hasn't turned anything useful up.
>>> Probably 'cause I don't have enough info.
>>> I've been playing around with the ereg function.
>>> What I was wondering is what is the ^ for like
>>> in the below example?
>>> ereg('[^[:space:]a-zA-Z0-9_.-]{1,}', $name)
>>>
>>> thx
>>> janbro
>>
>> it denotes the "start of the string"
>
>
> Actually, in the above case it doesn't... from the URL referenced...
>
> For example, the character class [aeiou] matches any lower case vowel,
> while [^aeiou] matches any character that is not a lower case vowel.
>
> If the ^ is outside of the []'s then it matches the start of the string...
>
> -philip
hey,
you're right ;) must've missed the opening [ there.
Well spotted!
attached mail follows:
Philip Hallstrom wrote:
>> janbro wrote:
>>
>>> Hi List,
>>> my research hasn't turned anything useful up.
>>> Probably 'cause I don't have enough info.
>>> I've been playing around with the ereg function.
>>> What I was wondering is what is the ^ for like
>>> in the below example?
>>> ereg('[^[:space:]a-zA-Z0-9_.-]{1,}', $name)
>>>
>>> thx
>>> janbro
>>
>> it denotes the "start of the string"
>
>
> Actually, in the above case it doesn't... from the URL referenced...
>
> For example, the character class [aeiou] matches any lower case vowel,
> while [^aeiou] matches any character that is not a lower case vowel.
>
> If the ^ is outside of the []'s then it matches the start of the string...
>
> -philip
hey,
you're right ;) must've missed the opening [ there.
Well spotted!
attached mail follows:
Just for information preg_match is 4-5 times more faster.
regards
david
Le Thu, 07 Jul 2005 19:26:32 +0200, M. Sokolewicz <tularis
php.net> a
écrit:
> Philip Hallstrom wrote:
>
>>> janbro wrote:
>>>
>>>> Hi List,
>>>> my research hasn't turned anything useful up.
>>>> Probably 'cause I don't have enough info.
>>>> I've been playing around with the ereg function.
>>>> What I was wondering is what is the ^ for like
>>>> in the below example?
>>>> ereg('[^[:space:]a-zA-Z0-9_.-]{1,}', $name)
>>>>
>>>> thx
>>>> janbro
>>>
>>> it denotes the "start of the string"
>> Actually, in the above case it doesn't... from the URL referenced...
>> For example, the character class [aeiou] matches any lower case
>> vowel,
>> while [^aeiou] matches any character that is not a lower case vowel.
>> If the ^ is outside of the []'s then it matches the start of the
>> string...
>> -philip
>
> hey,
> you're right ;) must've missed the opening [ there.
> Well spotted!
>
attached mail follows:
Do a search on the php website or the php offline manual for "Pattern Syntax"
-----Original Message-----
From: janbro [mailto:janbro
web.de]
Sent: 07 July 2005 15:30
To: php-general
lists.php.net
Subject: [PHP] Question to eregi Syntax
*************************************
This e-mail has been received by the Revenue Internet e-mail service.
*************************************
Hi List,
my research hasn't turned anything useful up.
Probably 'cause I don't have enough info.
I've been playing around with the ereg function.
What I was wondering is what is the ^ for like
in the below example?
ereg('[^[:space:]a-zA-Z0-9_.-]{1,}', $name)
thx
janbro
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
************************
This message has been delivered to the Internet by the Revenue Internet e-mail service
*************************
attached mail follows:
See the >>>>>>> below.
You can't send ANYTHING before header()
Miles
At 10:09 AM 7/7/2005, Bagus Nugroho wrote:
>Hi,
>Firstly, thanks for your advise.
>But, it doesn't work if combine with text or if we need display more than
>one record.
>Here's my code :
>
><?php
> mysql_connect("localhost","root","password") or Die ("Failed to
> connect");
> mysql_select_db("intdata") or Die ("Failed to select databse");
> $res=mysql_query("SELECT * FROM main") or die("error again");
>
> while ($line = mysql_fetch_array($res)){
> >>>>>>>>>>>>>>>>> echo "Lot Info : $line[lotID]"; <<<<<<<<<< Comment
> this out and try it <<<<<<<<<<<<<<<<<<
> /*Send headers*/
> header("content-type: image/gif");
> echo $line[picture];
> echo "\n";
> }
>?>
>
>It was displayed several record from $line[lotID], the followed
>information like this :
>Cannot modify header information - headers already sent by
>and a picture if opened with notepad.
>
>What's wrong
>
>Agian, thanks in advance
>
>
attached mail follows:
How about, if we need several pictures from several record?
-----Original Message-----
From: replies-lists-php
listmail.innovate.net
[mailto:replies-lists-php
listmail.innovate.net]
Sent: Thursday, July 07, 2005 8:19 PM
To: Bagus Nugroho
Subject: Re: [PHP] RE: Display picture from MySQL
you're trying to set your content-type header every time you loop
through your result set -- so if you have more than one result you'll
try to set your headers multiple times. you can't do that -- that's
what's causing the "cannot modify header information" message.
you need to change your code so that you only send the headers once.
e.g., test that you have items in your result set, if so, set the
content-type header (for image/gif), otherwise don't (so that you can
send a text message).
------------ Original Message ------------
> Date: Thursday, July 07, 2005 08:09:38 PM +0700
> From: Bagus Nugroho <bnugroho
aitemail.com>
> To: php-general
lists.php.net
> Subject: [PHP] RE: Display picture from MySQL
>
> Hi,
> Firstly, thanks for your advise.
> But, it doesn't work if combine with text or if we need display more
> than one record. Here's my code :
>
> <?php
> mysql_connect("localhost","root","password") or Die ("Failed to
> connect"); mysql_select_db("intdata") or Die ("Failed to select
> databse"); $res=mysql_query("SELECT * FROM main") or die("error
> again");
>
> while ($line = mysql_fetch_array($res)){
> echo "Lot Info : $line[lotID]";
> /*Send headers*/
> header("content-type: image/gif");
> echo $line[picture];
> echo "\n";
> }
> ?>
>
> It was displayed several record from $line[lotID], the followed
> information like this : Cannot modify header information - headers
> already sent by
> and a picture if opened with notepad.
>
> What's wrong
>
> Agian, thanks in advance
>
>
---------- End Original Message ----------
attached mail follows:
On Thu, July 7, 2005 12:32 pm, Bagus Nugroho said:
> How about, if we need several pictures from several record?
You can create a page of HTML that has IMG tags, and each IMG tag can call
ANOTHER php script that sends out one, and only one, image.
You'll never ever get two images crammed into a single HTTP request/response.
You also cannot smush the HTML and the IMG itself all into one file/script.
HTML with IMG tag is one script.
Actual image output (JPEG, GIF, etc) is another.
* Actually, they can be the same "script" if enough code is shared, but
it's got to have an "if" in there and only output the HTML for the .htm
request, and only output the JPEG for the .jpg request, but that's for
another day, after you get it working in separate scripts.
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
Philip Hallstrom wrote:
>> of leap years between the two dates. Leap years occur every 4 years,
>> and 17 / 4 = 4.25, so there were 4 leap years between 7/6/88 and
>> 7/6/05 and
>
>
> Just to nitpick... :-)
>
> http://en.wikipedia.org/wiki/Leap_year
>
> The Gregorian calendar adds an extra day to February, making it 29
> days long, in years where the quotient has no remainder when divided
> by 4, excluding years where the quotient has no remainder when divided
> by 100, but including years where the quotient has no remainder when
> divided by 400. So 1996, 2000, and 2400 are leap years but 1800, 1899,
> 1900 and 2100 are not.
>
Touche!
One more reason not to use the OP's method but rather the one posted by
Richard Lynch.
kgt
attached mail follows:
Hey Richard,
Thanks, you've pulled my butt outa the fire again :-)
Cheers,
Ryan
On 7/6/2005 10:59:36 PM, Richard Lynch (ceo
l-i-e.com) wrote:
> On Wed, July 6, 2005 12:07 pm, Ryan A said:
> >
> I'm confused, this should give me the age as 17 instead of 16...but it
> > does
> > not...any ideas why?
> >
> > <?php print date("Y:m:d");
> > $age="1988-07-06";
> >
> > $day1=strtotime($age);
> > $day2 = strtotime(date("Y-m-d"));
> > $dif_s = ($day2-$day1);
> > $dif_d = ($dif_s/60/60/24);
> > $age = floor(($dif_d/365.24));
> >
> > echo $age;
> > ?>
>
> 365.24 is an appoximation.
>
> Sooner or later, it's
> gonna bit you in the butt.
>
> If you want somebody's age accurately, you're probably going to have to
> do
> it the hard way.
>
> Something like this might work:
>
> <?php
> $DOB = "1988-07-06";
> $now = date('Y-m-d');
> list($by, $bm, $bd) = explode('-', $DOB);
> list($ny, $nm, $nd) = explode('-', $now);
> $age = $ny - $by;
> if ($age){
> if ($bm < $nm){
> // do nothing, they were born before this month
> // so subtracting the years is correct
> }
> elseif ($nm < $bm){
> $age--; //They were born in a later month, so not quite a year yet
> }
> else{
> //They were born this month. Count the days.
> if ($bd < $nd){
> //Do nothing. They were born before this date.
}
elseif ($nd < $bd){
$age--; //They were born later this month, so not quite a year yet
}
else{
//It's their birthday! Go ahead and count it as a year,
//unless you want to futz with the hour of their birth...
}
}
}
if (!$age){
//Do whatever you want with children less than 1 year old...
//return it as "X months" or just call it "infant" or pretend they're 1
//or whatever.
//Maybe even just use $age (which is 0) and call it done.
}
?>
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
I've tried google and also the PEAR documentation but I can't
figure out how to run a stored procedure that uses an OUTPUT
parameter. I keep getting an error saying that the variable used
as the OUTPUT parameter must be declared. But how can I
declare it using PEAR?
Has anyone run across this? If so, what was your solution?
thnx,
Chris
attached mail follows:
We stopped using OUTPUT parameters with PEAR because of this limitation.
I could never figure out how to get it to work. We use SQL Server, and
the OUTPUT parameters do infact work with the generic mssql functions in
PHP. Best of luck.
Nate Tobik
(412)661-5700 x206
VigilantMinds
-----Original Message-----
From: Chris Boget [mailto:chris.boget
wild.net]
Sent: Thursday, July 07, 2005 12:26 PM
To: PHP General
Subject: [PHP] PEAR and stored procedures
I've tried google and also the PEAR documentation but I can't
figure out how to run a stored procedure that uses an OUTPUT
parameter. I keep getting an error saying that the variable used
as the OUTPUT parameter must be declared. But how can I
declare it using PEAR?
Has anyone run across this? If so, what was your solution?
thnx,
Chris
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
attached mail follows:
Hi Richard,
On Jul 5, 2005, at 6:20 PM, Richard Lynch wrote:
> On Mon, July 4, 2005 6:48 pm, Bruno B B Magalhães said:
>> For example I have a brazilian zipcode witch is stored in database as
> Is she a Good Witch, or a Bad Witch? :-)
Ups, hehehehe!
>> 22252970 and must be formatted as NNNNN-NNN, where N is a number.
>> Also I have a tax id with is also stored as numeric value only, for
>> example 05117635472 and outputted as NNN.NNN.NNN-NN... Is that any
>> way that I can do it generic, storing the formatting strings ('NNNNN-
>> NNN') with languages strings, so it is localised and this would be
>> parsed as: string::format($string, $format);
>
> //Untested code:
> function format($string, $format){
> $slen = strlen($string);
> $flen = strlen($format);
> $result = '';
> for ($f = 0, $s = 0; $f <= $flen && $s <= $slen; $f++){
> $fc = $format[$f];
> $sc = $string[$s];
> switch($fc){
> case 'N':
> if (!strstr('0123456789', $sc)){
> //Suitable error for mal-formed data here.
> //$fc should be a digit, but it's not.
> }
> $result .= $sc;
> $s++;
> break;
> //Assume you need 'C'haracter data at some point in the future:
> case 'C':
> if (!stristr('abcdefghijklmnopqrstuvwxyz', $fc)){
> //more error-code (see above)
> }
> $result .= $sc;
> $s++;
> break;
> default:
> $result .= $fc;
> break;
> }
> }
> return $result;
> }
>
> I also don't think you want to tie it into "Locale" unless the data
> itself
> is tagged with Locale, rather than the viewer's Locale.
>
> A US zip code is NNNNN[-NNNN] no matter what language you are
> viewing it in.
I was thinking about that, but for example the dates and times
current are formatted language specific..
I was thinking about applying this internationalisation also to those
strings and number, but probably as you said that's not a good idea
after all.
But, either way, MANY thanks for your wonderful help.
Regards,
Bruno B B Magalhaes
attached mail follows:
Hi,
On 7/6/05, Ross <ross
aztechost.com> wrote:
> I have been using empty in forms for some time now. but have just discovered
> that
>
> PHP 4 As of PHP 4, The string value "0" is considered empty.
>
>
>
>
> Is there an alternative that will just check for empty strings. I suppose I
> could just use eregi and check for numbers but thought there may be a
> function that would work in a similar way.
>
>
> R.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
http://www.php.net/manual/en/types.comparisons.php
Very usefull !! I'll suggest you to print this out for quick reference.
Salud!
pancarne.
attached mail follows:
Hi, I am new to forum ,It may look as a simple problem, but I am not
able to solve this.
In following code , I have hard coded the path while setting cookie, now
how I read it through PHP ?
echo("cookie value name is : $name"); // this do not return anything.
Thanks,
Bibhu
<HTML>
<HEAD>
<TITLE>IWIN Search</TITLE>
<script>
function setCookie()
{
var expire = new Date();
expire.setTime(expire.getTime() + 2592000000);
document.cookie= "name= test; expires=" + expire.toGMTString() +
";domain=.schwab.com;path=/iwin2005";
}
</script>
<body onLoad='setCookie()'>
<?php
echo("cookie value name is : $name");
?>
</body>
attached mail follows:
On Thu, July 7, 2005 10:34 am, Lenka, Bibhu Kalyan said:
> Hi, I am new to forum ,It may look as a simple problem, but I am not
> able to solve this.
> In following code , I have hard coded the path while setting cookie, now
> how I read it through PHP ?
>
> echo("cookie value name is : $name"); // this do not return anything.
I dunno why you'd want to use flaky, unreliable, complicated JavaScript to
set the cookie instead of http://php.net/setcookie but if the JavaScript
worked in the first place, you'd have your cookie in:
$_COOKIE['name']
> Thanks,
> Bibhu
>
>
> <HTML>
> <HEAD>
> <TITLE>IWIN Search</TITLE>
> <script>
> function setCookie()
> {
>
> var expire = new Date();
> expire.setTime(expire.getTime() + 2592000000);
>
> document.cookie= "name= test; expires=" + expire.toGMTString() +
> ";domain=.schwab.com;path=/iwin2005";
> }
> </script>
> <body onLoad='setCookie()'>
> <?php
> echo("cookie value name is : $name");
> ?>
> </body>
>
>
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
Well,
I've read the manual, and the ADOdb Date package functions, and I am
not using this because I want to keep my framework simple, flexible,
and fast.
Well, I just want a simple way to translate dates (I know what is the
input format) to unix timestamp, with ability to do this with dates
before 1970, and after 2023, is there any way?
My current system the PHP's microtime it's Ok, but one of ours test
servers is running windows, and also some clients, so I rrealy need a
overall solution.
Here is my datetime class.
<?php
/
************************************************************************
***
*
name Date and Time Class (./framework/libraries/datetime.class.php)
*
version 1.0.0
*
dependencies None
************************************************************************
****
*
package B3M Platform™ 1.5.0
*
author B3M Development Team <development
bbbm.com.br>
*
copyright 2004 by Bruno B B Magalhaes
*
copyright 2005 by B3M Development Team
*
link http://www.bbbm.com.br/platform/
************************************************************************
***/
class datetime
{
/
*********************************************************************
* Get microtime
*********************************************************************/
function timestamp($input = null)
{
if(is_null($input))
{
return (float)array_sum(explode(' ', (microtime() +
datetime::server_timezone_offset())));
}
else
{
return (float)array_sum(explode(' ', strtotime($input)));
}
}
/
*********************************************************************
* Format a microtime
*********************************************************************/
function format($timestamp = 0, $format = 'm/d/Y H:m:s')
{
return date($format, $timestamp);
}
/
*********************************************************************
* Get server's time-zone offset in seconds
*********************************************************************/
function server_timezone_offset()
{
if(!defined('_SERVER_TIMEZONE_OFFSET'))
{
return (float)date('Z');
}
else
{
return (float)_SERVER_TIMEZONE_OFFSET;
}
}
}
?>
Thanks everybody!
Best Regards,
Bruno B B Magalhaes
attached mail follows:
Hello Bruno,
Thursday, July 7, 2005, 7:04:44 PM, you wrote:
BBBM> I've read the manual, and the ADOdb Date package functions, and
BBBM> I am not using this because I want to keep my framework simple,
BBBM> flexible, and fast.
BBBM> Well, I just want a simple way to translate dates (I know what
BBBM> is the input format) to unix timestamp, with ability to do this
BBBM> with dates before 1970, and after 2023, is there any way?
Personally I'd use the Pear Date package. It's stable, well formed and
will do exactly what you require: http://pear.php.net/package/Date
Even if you don't like the thought of using it - you can always pour
over the source code to look at their methods and see how they handle
it.
Best regards,
Richard Davey
--
http://www.launchcode.co.uk - PHP Development Services
"I do not fear computers. I fear the lack of them." - Isaac Asimov
attached mail follows:
Hi Richard,
Well, I took a look at, and I think it is TOO complex to handler a
simple thing..
Well, that's my little contribution:
function str2time($input = '12/31/1969')
{
$year = substr($input, -4);
$input = substr_replace($input, 1976 , -4);
return floor(strtotime($input) + (($year - 1976) *
(31557376.189582)));
}
It work with ONLY a few hours more or less compared to my MacOS
strtotime function, now I don't know which one is more accurate..
Well, why did you choose the year 1976, because it's an bisixth(?)
year. So it was a matter of simple math.
I would appreciate any help from everybody to:
As I suppose that the last 4 digits are the year, I would like a
pattern that could match a four digits number inside a string.
Any body know how many seconds and microseconds have a year, I found
a round number (31557376.189582).
Well, any help is appreciate.
At least now I can work on a windows box.
Best Regards,
Bruno B B Magalhaes
On Jul 7, 2005, at 3:42 PM, Richard Davey wrote:
> Hello Bruno,
>
> Thursday, July 7, 2005, 7:04:44 PM, you wrote:
>
> BBBM> I've read the manual, and the ADOdb Date package functions, and
> BBBM> I am not using this because I want to keep my framework simple,
> BBBM> flexible, and fast.
>
> BBBM> Well, I just want a simple way to translate dates (I know what
> BBBM> is the input format) to unix timestamp, with ability to do this
> BBBM> with dates before 1970, and after 2023, is there any way?
>
> Personally I'd use the Pear Date package. It's stable, well formed and
> will do exactly what you require: http://pear.php.net/package/Date
>
> Even if you don't like the thought of using it - you can always pour
> over the source code to look at their methods and see how they handle
> it.
>
> Best regards,
>
> Richard Davey
attached mail follows:
Hi Folks,
Well I think I got it, at least it's working more or less to me now...
I really would appreciate any comments or suggestions.
function str2time($input = '12/31/1969')
{
if(($output = strtotime($input)) !== -1)
{
return $output;
}
else
{
preg_match('([0-2][0-9][0-9][0-9])', $input, $year);
preg_replace('([0-2][0-9][0-9][0-9])', '1976', $input);
return floor(strtotime($input) + (($year[0] - 1976) *
(31557376.189582)));
}
}
Thanks a lot!
Best Regards,
Bruno B B Magalhaes
attached mail follows:
On Jul 7, 2005, at 7:54 PM, Bruno B B Magalhães wrote:
> Hi Folks,
>
> Well I think I got it, at least it's working more or less to me now...
> I really would appreciate any comments or suggestions.
>
> function str2time($input = '12/31/1969')
> {
> if(($output = strtotime($input)) !== -1)
> {
> return $output;
> }
> else
> {
> preg_match('([0-2][0-9][0-9][0-9])', $input, $year);
> preg_replace('([0-2][0-9][0-9][0-9])', '1976', $input);
> return floor(strtotime($input) + (($year[0] - 1976) *
> (31557376.189582)));
> }
> }
>
> Thanks a lot!
>
> Best Regards,
> Bruno B B Magalhaes
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
One problem is that there's no accounting for leap years, but I don't
know if that's gonna cause you any problems or not.
The other thing I noticed is that the 'match' bit you have in there as
"year[0]" should be "$year[1]". $year[0] will return the
whole string that was matched, not just the actual match part between
the parenthesis. Although I think you would get the
same thing with your set up. And you will need to put a delimiter in
the regex part, right now it looks like it's going to treat
the parenthesis as the delimiter which will make the return for the
match not work. ie:
" preg_match('([0-2][0-9][0-9][0-9])', $input, $year); " -- $year will
be empty...
should be " preg_match('/([0-2][0-9][0-9][0-9])/', $input, $year); "
or " preg_match('/([0-1][0-9][0-7][0-9])/', $input, $year); " -- to
restrict it to 1970 or before....
but it could also be " preg_match('/([\d]{4})/', $input, $year); " --
if you don't really need to validate the the year
There's other problems that I can see with the math logic in the
return, like why 1976?, why would you want to generate
a positive number that will conflict with dates before 1970? but it
could just be that I'm not thinking the math all the way
through, and what you eventually want to do with the dates once you
store them.
Edward Vermillion
evermillion
doggydoo.net
attached mail follows:
Hi Edward,
thanks for replying!
On Jul 7, 2005, at 10:44 PM, Edward Vermillion wrote:
> One problem is that there's no accounting for leap years, but I
> don't know if that's gonna cause you any problems or not.
Course it have, when we multiply the year offset by 31557376.189582
we are using the total seconds of an year, we normally don't use
cause from 4 to 4 years we add a day (Pope Gregory XIII, Bregorian
Calendar decreted in 1 March of 1582). So using the extra seconds we
are, in theory adding that one more day.
> The other thing I noticed is that the 'match' bit you have in there
> as "year[0]" should be "$year[1]". $year[0] will return the
> whole string that was matched, not just the actual match part
> between the parenthesis. Although I think you would get the
> same thing with your set up. And you will need to put a delimiter
> in the regex part, right now it looks like it's going to treat
> the parenthesis as the delimiter which will make the return for the
> match not work. ie:
>
> " preg_match('([0-2][0-9][0-9][0-9])', $input, $year); " -- $year
> will be empty...
>
> should be " preg_match('/([0-2][0-9][0-9][0-9])/', $input, $year); "
>
> or " preg_match('/([0-1][0-9][0-7][0-9])/', $input, $year); " -- to
> restrict it to 1970 or before....
>
> but it could also be " preg_match('/([\d]{4})/', $input, $year); "
> -- if you don't really need to validate the the year
>
> There's other problems that I can see with the math logic in the
> return, like why 1976?, why would you want to generate
> a positive number that will conflict with dates before 1970? but it
> could just be that I'm not thinking the math all the way
> through, and what you eventually want to do with the dates once you
> store them.
Why 1976, because it's a leap year and is between valid range for
windows systems.
Let me try to explain the rest.
First I get the input year... which by the way is working fine here...
preg_match('([0-2][0-9][0-9][0-9])', $input, $year);
Second I replace by a valid year between 1970 and 2025....
preg_replace('([0-2][0-9][0-9][0-9])', '1976', $input);
After calculate the date difference from 1976 to given date... let's
say 01/01/1936.....
So we have... -40... and now multiply by number of seconds in a year
(31557376.189582) before Gregorian Calendar, and we will get:
-1262295047.583
Now we calculate the timestamp from 01/01/1976: 189313200
Now we have the final equation: 189313200 + (-1262295047.583).
The result is a negative timestamp: -1072981847.583 Which if we put
in a date function, we would get: 01/01/1936.
Magic! We have negative timestamp in windows!
Was it clear, or I am dreaming awake? hehehehhe
Best Regards,
Bruno B B Magalhaes
attached mail follows:
Hi.
I'm having a problem serializing a mysqli_result object, the serialized
string contains only an empty object.
The code is as following:
$sql = new Mysqli("localhost", "user", "pass", "database");
$res = $sql->query("SELECT * FROM xxx WHERE `id` = 1");
print_r($res->fetch_assoc());
echo "\n" . serialize($res);
Which outputs:
Array
(
[id] => 1
[dbname] => xyzxyzxyz
[firstname] => xyz
[lastname] => zyx
[company] => N/A
[address] => xyz
[zip] => 8500
[city] => Xyz
[country] => ZZyyxx
[language] => 1
[comments] => zyx_
_)
O:13:"mysqli_result":0:{}
As you can see, the serialized string doesn't contain any of the data.
And surely enough the unserialized object doesn't contain anything. I'm
using PHP 5.0.3
I've been googleing for a couple of hours now, and I can't find anything
about serializing a mysqli_result object.
What is going on? How can I do this? Can I do it another way? Or am I
just doing something wrong?
Thanks
--
Bjarke Freund-Hansen <bjarke
rocekiller.dk>
attached mail follows:
Hi
Evert|Collab wrote:
>You can't serialize resource objects. Try:
>
>serialize($res->fetch_assoc());
>
>
I know I can serialize the array fetch_assoc returns, but I really need to serialize a mysqli_result, so I can feed it to any function expecting a mysqli_result.
Are there any alternative way to do it? Manually?
Can I create a mysqli_result object and feed it the data myself? I can't seem to find any description for a constructor for the mysqli_result class in the function reference.
--
Bjarke Freund-Hansen <bjarke
rocekiller.dk>
attached mail follows:
On Thu, July 7, 2005 12:53 pm, Bjarke Freund-Hansen said:
>>You can't serialize resource objects. Try:
>>
>>serialize($res->fetch_assoc());
>>
>>
> I know I can serialize the array fetch_assoc returns, but I really need to
> serialize a mysqli_result, so I can feed it to any function expecting a
> mysqli_result.
The connection simply WILL NOT survive the ending of a PHP script.
Period.
If you want to hack the PHP source to try to change that, go for it...
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
Hi everyone, currently I have a site hosted with Powweb and suffice it
to say, it's not good, so I wanted to get everyone's opinion here on
iPowerWeb? Or can you recommend another ISP that you swear by which has
similar features http://www.ipowerweb.com/products/webhosting/index.html
Thanks people.
attached mail follows:
On Thu, July 7, 2005 7:13 am, Murilo Opsfelder Araújo said:
> Hi all,
>
> I'm trying compile the PHP for work with Oracle Server.
> When I try the comand:
>
> # rpm -ba php.spec
>
> I get the following error message:
>
> checking if the location of ZLIB install directory is defined... no
> configure: error: Cannot find libz
>
> Have anyone any suggestions?
Try to install zlib first?...
Or is that too obvious and you already tried that?
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
On Thu, July 7, 2005 4:14 am, Thorsten Friedrich said:
> because of the fact that i´ll never see if the write-session-function is
>
> called i´ve placed a write-a-log-to-disk function in all session-function
> to
>
> see if they are called.
What are these write-a-log-to-disk functions outputting?
Can you beef them up, particularly with error-checking on the result of
you mysql_query() calls?
If your queries are failing for some reason, and you're not logging it,
and you're used to seeing them in your browser or Apache log, you'll never
know unless you log them from here and check that other log.
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
On Thu, July 7, 2005 2:50 am, Javier said:
> On 05/07/2005 at 14:04 sylikc wrote:
>>
>>For MD5 passwords though, it's a little different and not documented
>>as thoroughly...
>>3) Extract crypt salt from the $crypthash ....
>>$cryptsalt = '$'.substr($crypthash,4,11);
>
> Thanks for your help.
>
> I checked my PHP support CRYPT_MD5, then I did the following:
>
> I've generated a user javier with password javier in my htpasswd file and
> got this:
>
> Automatically using MD5 format.
> javier:$apr1$nO/.....$x0j4FfqCIQqgtqPckVUkO1
>
> Then I did the following code:
>
> ---------------------
> <?php
>
> print "password: ".$password = "javier"."\n";
>
> $crypthash = '$apr1$nO/.....$x0j4FfqCIQqgtqPckVUkO1';
> $cryptsalt = '$'.substr($crypthash,4,11);
>
> print "cryptsalt: ".$cryptsalt."\n";
> print "crypthash: ".$crypthash."\n";
>
> print "crypted by me: ".'$apr'.crypt($password, $cryptsalt)."\n";
>
> ?>
> ----------------------
>
> And the output was:
>
> password: javier
> cryptsalt: $1$nO/.....$
> crypthash: $apr1$nO/.....$x0j4FfqCIQqgtqPckVUkO1
> crypted by me: $apr$1$nO/.....$0cKBXpoO.Q/jpA6sUUafq0
Aha!
Since your output has an extra '$' after the $apr and before the
1$n0/..... I'm gonna go out on a limb and suggest you probably shouldn't
add the '$' to the front of your salt.
You're adding it, and crypt() is adding it, and you've got too much money
in your salt. :-)
Change step 3 to:
$cryptsalt = substr($crypthash,4,11);
Basically, do whatever it takes to get the front half of the crypted
outputs to match up, and I suspect that the random parts at the end will
magically sort themselves out. :-)
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
On 07/07/2005 at 14:23 Richard Lynch wrote:
>
>Aha!
>
>Since your output has an extra '$' after the $apr and before the
>1$n0/..... I'm gonna go out on a limb and suggest you probably shouldn't
>add the '$' to the front of your salt.
>
>You're adding it, and crypt() is adding it, and you've got too much money
>in your salt. :-)
>
>Change step 3 to:
>$cryptsalt = substr($crypthash,4,11);
>
>Basically, do whatever it takes to get the front half of the crypted
>outputs to match up, and I suspect that the random parts at the end will
>magically sort themselves out. :-)
As far as I've read, crypt needs $1 as the satart of salt to know that it
should be crypted with md5.
Then the code it's ok in that way.
Nevertheless, I've tried what you said but it didn't work because crypt
made an encryption with something that is not md5 and the result is:
$apr1$LsJY6m0XL/I
Any idea ?
Thanks in advance
J
attached mail follows:
Hi all
I am trying to set the last modified date/time of individual files in a zip
file.
According to the specification (http://www.pkware.com/appnote.txt), date/time
are two bytes each, and use standard msdos date/time encoding.
Does anybody have a clue to this?
With kind regards
Andy
--
Registered Linux User Number 379093
-- --BEGIN GEEK CODE BLOCK-----
Version: 3.1
GAT/O/>E$ d-(---)>+ s:(+)>: a--(-)>? C++++$(+++) UL++++>++++$ P-(+)>++
L+++>++++$ E---(-)
W+++>+++$ !N
o? !K? W--(---) !O !M- V-- PS++(+++)
PE--(-) Y+ PGP++(+++) t+(++) 5-- X++ R*(+)
!tv b-() DI(+) D+(+++) G(+)
e>++++$
h++(*) r-->++ y--()>++++
-- ---END GEEK CODE BLOCK------
--
Check out these few php utilities that I released
under the GPL2 and that are meant for use with a
php cli binary:
http://www.vlaamse-kern.com/sas/
--
--
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQBCzatW2GLGPJ3Q07wRAneGAJ992kUjwUgAoj7yK5Cnracx3e1b/gCfYvu7
AnQ0L5i8HD0zb2BTBmM8ejk=
=HJgF
-----END PGP SIGNATURE-----
attached mail follows:
affid upline sponsor
1 0 0
2 1 1
3 1 1
4 2 1
5 2 2
6 3 1
7 3 1
8 4 1
9 4 1
10 5 1
i have table with field and data like above in my database mysql,
and i only can preview that data in tree format
Level 1 : affid 2
........Level 2 : affid 4
........Level 2 : affid 5
Level 1 : affid 3
........Level 2 : affid 6
........Level 2 : affid 7
now i want to preview that data in table, like this
level1 (in table)
level2
level3
can someone help me ???
it affiliate view downline but in table format not in hirarki/tree format
where affid is have upline and sponsor.
attached mail follows:
This should be pretty simple but I cant find any info on it at the
site. I am writing a function that will create a anchor, but I want it
to call the same page it is on. Is there a way to get the current php
page I am on so that when I output my anchor for that correct page.
so if I call it from index.php the link will say:
index.php?var=data
but if I can the same function from say photos.php then the link would be:
photos.php?var=data......
thanks
attached mail follows:
I am trying to use php to pull an url out of an html page....
If I have an html page that is being 'fread' and the html source
contains the below....
and, I want to get the image:
http://image.com.com/gamespot/images/2005/132/
914653_20050513_screen006.jpg
<!--************ END SCREENSHOT NAVIGATION ************--><span
class="spacer6"> </span><br><div class="scaption"><img
src="http://image.com.com/gamespot/images/2005/132/
914653_20050513_screen006.jpg" border="0"
How would I parse the html page and get the image url ?
Is this an eregi kind of thing or is there some easier way ?
this is the sample page I want to parse:
http://www.gamespot.com/pc/rpg/guildwars/screens.html?page=264
would I search for the string ,<!--************ END SCREENSHOT
NAVIGATION ************-->, and then search for the first occurence of
<img src = ?
any help is appreciated :)
g
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]