php-general Digest 2 Aug 2003 23:40:47 -0000 Issue 2213

Topics (messages 158040 through 158060):

Re: LDAP_connect()
        158040 by: Bogdan Stancescu
        158045 by: Craig Roberts

connecting access (*.mdb) database with PHP
        158041 by: pehepe php
        158042 by: skate
        158044 by: Craig Roberts
        158046 by: David Nicholson

Re: Pushing array onto array
        158043 by: Andrew Brampton
        158053 by: Curt Zirzow

subtracting dates...
        158047 by: John Ryan
        158048 by: Craig Roberts
        158049 by: John Ryan
        158050 by: Craig Roberts
        158051 by: Paul Chvostek
        158057 by: Curt Zirzow

Re: Multiple targets with fscanf
        158052 by: Denis 'Alpheus' Cahuk
        158056 by: Dan Anderson

Re: [PHP-DB] subtracting dates...
        158054 by: Ryan Marks

Re: Opinions on Micro$oft .NET
        158055 by: Burhan Khalid

Trouble with Session var
        158058 by: James Johnson
        158059 by: James Johnson

preg_match
        158060 by: Michael Temeschinko

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message --- http://ro.php.net/manual/en/ref.ldap.php#ldap.requirements

Ron Allen wrote:
Everytime I try to run this function it says that it is an undefined
function LDAP_connection




--- End Message ---
--- Begin Message ---
Have you enabled the module in php.ini?

Uncomment the line

extension=php_ldap.dll

in php.ini (windows..) I think LDAP support needs to be complied in on Linux
but I've never used it so cant say.

Craig Roberts

"Ron Allen" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Everytime I try to run this function it says that it is an undefined
> function LDAP_connection
>
>



--- End Message ---
--- Begin Message --- how can I connect access database(*.mdb) with php? what is the code? I will be happy if you write php code.


Thank you!


_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail



--- End Message ---
--- Begin Message ---

> how can I connect access database(*.mdb) with php?  what is the code?   I
> will be happy if you write php code.
>
>


damn, i'd be happy if other would write my code too...

check out the COM connections in the manual. best place for you to start,
should be able to connect to most ms applications. i'm not sure about
connecting directly to an mdb file tho...




--- End Message ---
--- Begin Message ---
Have a look for MyODBC. I've got Access talking to SQL easily, dont know if
it can be done the other way round.

Craig Roberts

"Skate" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
>
> > how can I connect access database(*.mdb) with php?  what is the code?
I
> > will be happy if you write php code.
> >
> >
>
>
> damn, i'd be happy if other would write my code too...
>
> check out the COM connections in the manual. best place for you to start,
> should be able to connect to most ms applications. i'm not sure about
> connecting directly to an mdb file tho...
>
>
>



--- End Message ---
--- Begin Message ---
Hello,

This is a reply to an e-mail that you wrote on Sat, 2 Aug 2003 at
15:31, lines prefixed by '>' were originally written by you.
> how can I connect access database(*.mdb) with php?  what is the
code?
>  I
> will be happy if you write php code.

Windows Control Panel > Administrative Tools > Data Sources (or
something like that!)

This window will let you setup an ODBC DSN for any mdb file.  You
should then be able to use PHPs ODBC functions to run queries on it
<http://uk.php.net/odbc>.

I have never tried this though, so apoligies if it does not work.

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

          Professional Web Development by David Nicholson
                    http://www.djnicholson.com/

    QuizSender.com - How well do your friends actually know you?
                     http://www.quizsender.com/
                    (developed entirely in PHP)

--- End Message ---
--- Begin Message ---
Well I just coded up a very small example, and it pushing 1 array into the
other...

Check out: http://81.102.229.151/push.php and
http://81.102.229.151/push.phps

It works exactly how it should... However really the array isn't a 2
dimensional one, since PHP doesn't have them, its rather a array of arrays
which is roughly the same thing (and something not to worry about)...

If you need more help just email me
Andrew
----- Original Message -----
From: "Hank TT" <[EMAIL PROTECTED]>
To: "php-general" <[EMAIL PROTECTED]>
Sent: Saturday, August 02, 2003 7:58 AM
Subject: [PHP] Pushing array onto array


> In comparing Perl's push to array_push in "PHP Developer's Cookbook" (2/e,
> p. 76), the authors note that pushing an array onto another produces a
> two-dimensional array.  However, I have not been able to reproduce their
> example result, and php.net/array_push does not document this behavior.
>
> Just curious.
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--- End Message ---
--- Begin Message ---
* Thus wrote Andrew Brampton ([EMAIL PROTECTED]):
> Well I just coded up a very small example, and it pushing 1 array into the
> other...
> 
> Check out: http://81.102.229.151/push.php and
> http://81.102.229.151/push.phps
> 
> It works exactly how it should... However really the array isn't a 2
> dimensional one, since PHP doesn't have them, its rather a array of arrays
> which is roughly the same thing (and something not to worry about)...

A 2 demensional array is an array of arrays.

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
Hi,

In mySQL, I store dates as YYYY-MM-DD, a standard DATE type. It stores users
date of births. I need to calculate in a PHP script, the users age from this
DOB. I get a PHP date in the same format as the mySQL and subtract, which
returns the year rounded off. ie, it doesnt matter if your birthdays in june
of 1983 and the date is januray 2003, your age is still returned as 20, when
it should be 19.

Does anyone know how can i get the right age?



--- End Message ---
--- Begin Message ---
Try something along the lines of

if($current_MM < $MM) {
    $age = $calculatedage - 1;
}

you'll also need to do something like this with the day of the month if the
user's bday is in the current month.
at least... i think that works out :$
Craig Roberts


"John Ryan" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi,
>
> In mySQL, I store dates as YYYY-MM-DD, a standard DATE type. It stores
users
> date of births. I need to calculate in a PHP script, the users age from
this
> DOB. I get a PHP date in the same format as the mySQL and subtract, which
> returns the year rounded off. ie, it doesnt matter if your birthdays in
june
> of 1983 and the date is januray 2003, your age is still returned as 20,
when
> it should be 19.
>
> Does anyone know how can i get the right age?
>
>



--- End Message ---
--- Begin Message ---
yeah, i was thinking that before i decided to post to the newsgroup. i
thought there was some simple way of doing it and id be wasting my time.
obviosuly not


"Craig Roberts" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Try something along the lines of
>
> if($current_MM < $MM) {
>     $age = $calculatedage - 1;
> }
>
> you'll also need to do something like this with the day of the month if
the
> user's bday is in the current month.
> at least... i think that works out :$
> Craig Roberts
>
>
> "John Ryan" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Hi,
> >
> > In mySQL, I store dates as YYYY-MM-DD, a standard DATE type. It stores
> users
> > date of births. I need to calculate in a PHP script, the users age from
> this
> > DOB. I get a PHP date in the same format as the mySQL and subtract,
which
> > returns the year rounded off. ie, it doesnt matter if your birthdays in
> june
> > of 1983 and the date is januray 2003, your age is still returned as 20,
> when
> > it should be 19.
> >
> > Does anyone know how can i get the right age?
> >
> >
>
>



--- End Message ---
--- Begin Message ---
Another idea (slightly simpler)...

how about using mktime(); to create a timestamp from your date info, and
subtract that from the current timestamp - leaving (i think) the person's
age in seconds...

Then just do some math...

hmm... is that really simpler? well it seemed it when i started typing

craig :)
"John Ryan" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> yeah, i was thinking that before i decided to post to the newsgroup. i
> thought there was some simple way of doing it and id be wasting my time.
> obviosuly not
>
>
> "Craig Roberts" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Try something along the lines of
> >
> > if($current_MM < $MM) {
> >     $age = $calculatedage - 1;
> > }
> >
> > you'll also need to do something like this with the day of the month if
> the
> > user's bday is in the current month.
> > at least... i think that works out :$
> > Craig Roberts
> >
> >
> > "John Ryan" <[EMAIL PROTECTED]> wrote in message
> > news:[EMAIL PROTECTED]
> > > Hi,
> > >
> > > In mySQL, I store dates as YYYY-MM-DD, a standard DATE type. It stores
> > users
> > > date of births. I need to calculate in a PHP script, the users age
from
> > this
> > > DOB. I get a PHP date in the same format as the mySQL and subtract,
> which
> > > returns the year rounded off. ie, it doesnt matter if your birthdays
in
> > june
> > > of 1983 and the date is januray 2003, your age is still returned as
20,
> > when
> > > it should be 19.
> > >
> > > Does anyone know how can i get the right age?
> > >
> > >
> >
> >
>
>



--- End Message ---
--- Begin Message ---
On Sat, Aug 02, 2003 at 08:30:34PM +0100, John Ryan wrote:
>
> In mySQL, I store dates as YYYY-MM-DD, a standard DATE type. It stores users
> date of births. I need to calculate in a PHP script, the users age from this
> DOB. I get a PHP date in the same format as the mySQL and subtract, which
> returns the year rounded off. ie, it doesnt matter if your birthdays in june
> of 1983 and the date is januray 2003, your age is still returned as 20, when
> it should be 19.

The function you're probably looking for is floor().

> Does anyone know how can i get the right age?

One quick way would be simple subtraction:

  $old = "1973-06-02";
  $new = "2003-08-02";
  $year = 60*60*24*365.25; // seconds in a year
  $age = strtotime($new) - strtotime($old);
  print "Age in years: " . floor($age / $year) . "\n";

But you'll run into infrequent problems surrounding leap years.  I'm
sure there's a more accurate way to do this, perhaps even using MySQL's
somewhat more advanced (and less timestamp-centric) date calculation
functions, but this is what I can come up with on short notice.

Note that strtotime will give NEGATIVE TIMESTAMPS for dates earlier than
Jan 1st 1970 at midnight GMT, so this still works for folks over 33.  ;)

-- 
  Paul Chvostek                                             <[EMAIL PROTECTED]>
  it.canada                                            http://www.it.ca/
  Free PHP web hosting!                            http://www.it.ca/web/


--- End Message ---
--- Begin Message ---
* Thus wrote John Ryan ([EMAIL PROTECTED]):
> Hi,
> 
hello ryan,

> In mySQL, I store dates as YYYY-MM-DD, a standard DATE type. It stores users
> date of births. I need to calculate in a PHP script, the users age from this
> DOB. I get a PHP date in the same format as the mySQL and subtract, which
> returns the year rounded off. ie, it doesnt matter if your birthdays in june
> of 1983 and the date is januray 2003, your age is still returned as 20, when
> it should be 19.
> 
> Does anyone know how can i get the right age?

To get a real age of someone you would use seconds, but since the actual
count of seconds get messed up on leap years (through the convertion
from seconds to years),  I approached it with the method most people
calculate ages.

Most people first look at the year and find the differnce, then if
the month/day hasn't come around you subtract one; alas the common
calculation for age.

Here is the code to demonstrate that logic:


$dob = split('-', '1980-12-1');
$now = split('-', date('Y-m-d'));

// we are either this age or one less
$age = $now[0] - $dob[0];

// have we gotten to the month of in dob?
if ($now[1] < $dob[1]) {

   // no, so we are technically a year less.
   $age--;

// If we're in the month,  has the day come yet?
} elseif ($now[1] = $dob[1] && $now[2] < $now[3]) {

   // no, still a few more days.
   $age--;
}

// your age is proper, in day to day usage.

/*
  Note:
  
  instead of the if () elseif() you can use
  if (mktime(0,0,0,$now[1],$now[2]) < mktime(0,0,0,$dob[1],$dob[2])) {
    $age--;
  }

*/


HTH, 

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message --- Dan Anderson wrote:

Thanks a lot.



hehe no thanks needed. Just remember to read up on the functions so you'll know how they work. ;-)

-Dan




I've found some bugs there too, so dont worry. Like the ...($li_tag_start_position + 4), ($li_tag_end_position + 4)...
It actually has to be (4 + $li_tag_start_position), ($li_tag_end_position - $li_tag_start_position - 4)


But thanks anyway :D



--- End Message ---
--- Begin Message ---
> I've found some bugs there too, so dont worry. Like the 

lol...sorry but it was a quick reply...

-dan


--- End Message ---
--- Begin Message ---
I found this code at Google's cached version of the manual for the
date() function:
http://216.239.37.104/search?q=cache:kq0aNfZeEp8J:www.php.net/date+diffe
rence+two+date+site:www.php.net&hl=en&ie=UTF-8

This code only returned the number of hours, minutes, and seconds
between the two points in time.  Now it returns years and days as well
as the left over time.  The script also used the mod operator (%) to
find the remaining days after determining the year and it would not
calculate correctly.  For example, if I compared yesterday, three years
ago(08-01-00) and today (08-02-03) at noon for both days, I would get a
difference of 3 years.  No I am using while loops subtracting whole
years to find the number of days that remain.  The same is true for
subtracting days, hours and minutes.

CODE:
<?php

$diff = dateDiff("12-21-1983 10:20:00", "08-02-2003 16:42:01");
echo "$diff\r\n";

function unixTm($strDT)
{
        $arrDT = explode(" ", $strDT);
        $arrD = explode("-", $arrDT[0]);
        $arrT = explode(":", $arrDT[1]);
        return mktime($arrT[0], $arrT[1], $arrT[2], $arrD[0], $arrD[1],
$arrD[2]);
}

function dateDiff($date1,$date2)
//       dateDiff(date_in_the_past, date_in_the_future)
{
        $dt2=unixTm($date2) ;
        $dt1=unixTm($date1) ;
        $r =  $dt2 - $dt1;
        
        $yy=floor($r / 31536000);
        while ($r > 31536000){
                $r -= 31536000;
        }
        $dd=floor($r / 86400);
        while ($r > 86400){
                $r -= 86400;
        }
        $hh=floor($r/3600);
        if ($hh<=9) $hh="0".$hh;  //adds a leading 0 if less than 10
        while ($r > 3600){
                $r -= 3600;
        }
        $mm=floor($r/60);
        if ($mm<=9) $mm="0".$mm; //adds a leading 0 if less than 10
        while ($r > 60){
                $r -= 60;
        }
        $ss=$r ;
        if ($ss<=9) $ss="0".$ss; //adds a leading 0 if less than 10
        $retval="$yy year(s), $dd day(s) $hh:$mm:$ss";
        return $retval;
}

?>


OUTPUT:
19 year(s), 229 day(s) 05:22:01

Hope this helps,
Ryan Marks

-----Original Message-----
From: John Ryan [mailto:[EMAIL PROTECTED] 
Sent: Saturday, August 02, 2003 2:31 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: [PHP-DB] subtracting dates...


Hi,

In mySQL, I store dates as YYYY-MM-DD, a standard DATE type. It stores
users date of births. I need to calculate in a PHP script, the users age
from this DOB. I get a PHP date in the same format as the mySQL and
subtract, which returns the year rounded off. ie, it doesnt matter if
your birthdays in june of 1983 and the date is januray 2003, your age is
still returned as 20, when it should be 19.

Does anyone know how can i get the right age?



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


--- End Message ---
--- Begin Message ---
On Thursday, July 31, 2003, 9:13:03 PM, John wrote:

JWH> Jay Paulson wrote:
>> The company I work for just got bought out by a larger company.  The larger company 
>> uses .NET from Micro$oft. I of course use all open source stuff for our web sites 
>> and now the new company wants
>> to come in and pretty much blow away everything I have done and use their .NET 
>> setup.


JWH> First I'd quit referring to it as Micro$oft if you want to be taken 
JWH> seriously. You should be professional about this. If the new company 
JWH> wants to use a .NET solution, then you should begin learning a .NET 
JWH> language.

I agree completely with the good captain here. Its very unprofessional
to use Micro$oft. You might has well start saying you are "1337"
(don't ask me how long it took me to figure that one out).

Personally, I find that people that tend to hang on to one particular
toolset ... two things happen to them. Either they become extremely
proficient and extremely valuable, or they are yesterday's news. This
is true for just about any computer related language/platform etc.
that I can think of.

I am currently in a situation where I have been hired to develop a few
webservices for a client. At first, I looked at PHP and XML-RPC, since
PHP was what I was programming in currently and it was the freshest
thing in my mind. After reasearching the topic, I found out that _for
my client_ it was better to go with .NET.  After considerable reading
at the local technicaly library, a few hundred in books, and a lot of
googling and asking around, I found out the exact pros and cons of
using .NET, and I presented these to my client (during the prelim
stages).

The bottom line is, unless you start thinking in terms of your client
(in this case, your new company) and start to figure out how you can
become a more important asset to them, you will quickly find yourself
(depending on your company), either denied promotions, projects, etc.
... or in this day and age, you might just get the boot.

As for myself, I am well on my way to learning .NET's webservice
particulars, and finding that C# can be a "Good Thing". I cannot
attest to any performance claims, since my personal projects have been
on the "hello world"-type scale, but alot of reports floating around
on the net suggest that -- with the proper hardware configuration --
.NET-based platforms are quite reliable and speedy.

Just my $0.02 or whatever $0.02 is in euros.

-- 
Regards,
Burhan Khalid
phplist[at]meidomus[dot]com
http://www.meidomus.com


--- End Message ---
--- Begin Message ---
Hello,

This one has me stumped.

I'm setting a session var to a value returned from a query, then redirecting
to another page. I get the following error on the second page:

Notice: Undefined index: sv_adCatText 

On the page that sets the session var, I can do an echo of
$HTTP_SESSION_VARS['sv_adCatText'] and it prints the var fine. If I do a
var_dump($HTTP_SESSION_VARS); I can see all of the session vars, except this
one.

Is there a limit or something to the number of Session vars that can be
used? I've even tried setting a Session var called "foo" and that doesn't
work.

Thanks,
James

Here's the code:

First Page:
<?php session_start();?>
<?php 
if(isset($_POST['selCat'])){
        $as_adCat =
addslashes($_POST['selCat']);$HTTP_SESSION_VARS['sv_adCat'] =
trim($as_adCat);
        $id = $_POST['selCat'];
        mysql_select_db($database_CCB, $CCB);
        $query_GetCatText = "SELECT category FROM categories WHERE
category_id = '$id' ORDER BY category ASC";
        $GetCatText = mysql_query($query_GetCatText, $CCB) or
die(mysql_error());
        $row_GetCatText= mysql_fetch_assoc($GetCatText);
        $HTTP_SESSION_VARS['sv_adCatText'] = $row_GetCatText['category'];
        if($HTTP_SESSION_VARS['sv_adCatText'] == "Books"){
                header("Location: " . "CreateAdBook.php");
                exit;
        }else{
                header("Location: " . "CreateAdNonBook.php");
                exit;
        }
}
?>

Second Page:
<?php session_start();?>
<td><?php echo $HTTP_SESSION_VARS['sv_adCatText']; ?></td>


--- End Message ---
--- Begin Message ---
DOH! Nevermind, I mis-spelled session_start().

:(
-----Original Message-----
From: James Johnson [mailto:[EMAIL PROTECTED] 
Sent: Saturday, August 02, 2003 4:19 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Trouble with Session var


Hello,

This one has me stumped.

I'm setting a session var to a value returned from a query, then redirecting
to another page. I get the following error on the second page:

Notice: Undefined index: sv_adCatText 

On the page that sets the session var, I can do an echo of
$HTTP_SESSION_VARS['sv_adCatText'] and it prints the var fine. If I do a
var_dump($HTTP_SESSION_VARS); I can see all of the session vars, except this
one.

Is there a limit or something to the number of Session vars that can be
used? I've even tried setting a Session var called "foo" and that doesn't
work.

Thanks,
James

Here's the code:

First Page:
<?php session_start();?>
<?php 
if(isset($_POST['selCat'])){
        $as_adCat =
addslashes($_POST['selCat']);$HTTP_SESSION_VARS['sv_adCat'] =
trim($as_adCat);
        $id = $_POST['selCat'];
        mysql_select_db($database_CCB, $CCB);
        $query_GetCatText = "SELECT category FROM categories WHERE
category_id = '$id' ORDER BY category ASC";
        $GetCatText = mysql_query($query_GetCatText, $CCB) or
die(mysql_error());
        $row_GetCatText= mysql_fetch_assoc($GetCatText);
        $HTTP_SESSION_VARS['sv_adCatText'] = $row_GetCatText['category'];
        if($HTTP_SESSION_VARS['sv_adCatText'] == "Books"){
                header("Location: " . "CreateAdBook.php");
                exit;
        }else{
                header("Location: " . "CreateAdNonBook.php");
                exit;
        }
}
?>

Second Page:
<?php session_start();?>
<td><?php echo $HTTP_SESSION_VARS['sv_adCatText']; ?></td>


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



--- End Message ---
--- Begin Message --- Hello,

I would like to split a String containing ingredience with additional assigned footnotes...

my problem I only get the first ingredience ($zutat at line 32 has only one times the awaited value) but the print on line 29 shows me that the value of $zutat is right at this point.

what's wrong ????

1 <?php
2
3 $products_ingredience = 'Gersten-Grütze²*, Gerstenmehl²*, Haferflocken*, Gemüse 12 % (Lauch*, Möhren*, Zwiebeln*), Haferkleie*, Steinsalz, Petersilie*, Kartoffelstärke*, Hefeextrakt, Sellerieblatt*, Kurkuma*, Muskatnuß*, Pfeffer*, Liebstöckl*';
4
5 ArtikelZutaten ($products_ingredience);
6
7
8 function ArtikelZutaten($products_ingredience) {
9
10
11 print "\n\n\n$products_ingredience)";
12 $Zutaten = explode(",", $products_ingredience);
13
14 foreach ($Zutaten as $zutat) {
15 if (preg_match("/\²/", $zutat))
16 $FussnoteID = 2;
17 else
18 $FussnoteID = '';
19
20 if (preg_match("/¹/", $zutat))
21 $FussnoteID = 1;
22
23 if (preg_match("/\*/", $zutat))
24 $kbA = 1;
25 else
26 $kbA = 0;
27
28 preg_match("/\b.*\b/", $zutat, $matches);
29 print "\n-->>$zutat";
30 $zutat = $matches[0];
31
32 print "\nZutat $zutat FussnotenID $FussnoteID kbA $kbA";
33
34 }
35
36 }
37
38 ?>




mfg - micha


--- End Message ---

Reply via email to