Re: [PHP] Newbie question about good coding practice [isset]

2004-06-05 Thread Curt Zirzow
* Thus wrote K.Bogac Bokeer ([EMAIL PROTECTED]):
> When $var is 0?
> 
>$var = 0;

or
  $var = '';
  $var = array();
  $var = false;

> 
>   // Output: $var: $var not exists
>   if ( $var )
> echo '$var: $var exists';
>   else



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

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



Re: [PHP] Newbie question about good coding practice [isset]

2004-06-05 Thread K.Bogac Bokeer
When $var is 0?

  // Output: $var: $var not exists
  if ( $var )
echo '$var: $var exists';
  else
echo '$var: $var not exists';
  // Output: isset(): var exists
  if ( isset($var) )
echo 'isset(): $var exists';
  else
echo 'isset(): $var not exists';
?>
Larry E . Ullman wrote:
if($var) do something;
verses
if(isset($var)) do something;
The simple form if($var) seems to work fine and I see it in code often.
Is there a good reason for using isset?

Yes, if you don't use isset(), you may see notices (errors) if the 
variable is not set. This depends upon the error reporting settings of 
the server. However, if you use isset() you won't see notices regardless.

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


Re: [PHP] Newbie question about good coding practice [isset]

2004-06-05 Thread Larry E . Ullman
if($var) do something;
verses
if(isset($var)) do something;
The simple form if($var) seems to work fine and I see it in code often.
Is there a good reason for using isset?
Yes, if you don't use isset(), you may see notices (errors) if the 
variable is not set. This depends upon the error reporting settings of 
the server. However, if you use isset() you won't see notices 
regardless.

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


RE: [PHP] Newbie Question: Variables on the fly

2004-05-28 Thread Tim Winters
Steve!!!
This is great!
I had no idea you could use arrays in url variables.  That makes everything 
much easier.

Thanks very much
Tim
At 06:26 AM 28/05/2004, Steve Edberg wrote:
At 2:01 AM -0300 5/28/04, [EMAIL PROTECTED] wrote:
Thanks for the reply Denis,
Let me elaborate a bit.
I have a php page which I want to pass a series of variables via a url 
string.

eg
myPage.php?dataPoint1=10&dataPoint2=20&dataPoint3=30
The thing is I won;t know until runtime how many dataPoints there will be 
so I have also included 1 additional url variable

eg
myPage.php?totalDataPoints=3&dataPoint1=10&dataPoint2=20&dataPoint3=30
From there I want to take those data points and do several things
with each of them.  The keep things simple lets say I want to multiply 
each by 3 and then divide it by 2 and put it into a new variable (under 
the same naming system).

eg
$xtemp=$HTTP_GET_VARS[totalDataPoints];
do {
A line here which will take each dataPoint and multiply by 3 and 
divide by 2 and assign it to a new variable with the same numbering 
system (eg $myNewVar1=$HTTP_GET_VARS[dataPoint1]*3/2;
$xtemp--;
} while ($xtemp>0);

Make any more sense?
Thanks.

Strictly speaking, your original question referred to what PHP calls 
'variable variables':

http://us3.php.net/manual/en/language.variables.variable.php
However, most of what you can do with them can be done more simply with 
arrays. In your example above, use

myPage.php?dataPoint[]=10&dataPoint[]=20&dataPoint[]=30
and you get an array
$dataPoint[0]=10
$dataPoint[1]=20
$dataPoint[2]=30
The number of data points is count($dataPoint). See
http://us3.php.net/manual/en/language.variables.external.php
for more info on this technique.
steve edberg


At 01:24 AM 28/05/2004, Dennis Seavers <[EMAIL PROTECTED]> wrote:
Maybe others will catch on to your intention, but I think you need to
provide a bit more information.  For example, what variables do you want to
create (drawn from a file source, or create on the fly)?  Where will they
come from (a database, perhaps)?  You could create a script that creates
variables from scratch, following a (hopefully) finite mathematical
formula.  Or you could manipulate data that already exists, turning this
data into some kind of variables.
Ultimately, you'll have to give a better of sense of the end result you'd
like.
Dennis Seavers

 [Original Message]
 From: <[EMAIL PROTECTED]>
 To: PHP List <[EMAIL PROTECTED]>
 Date: 05/27/2004 9:17:11 PM
 > Subject: [PHP] Newbie Question: Variables on the fly
 Hello,
 I'm sure this is a newbie question but I don't know the syntax.
 I want to create a series of variables within a php script at runtime
with
 a for loop.
 eg
 myVar1
 myVar2
 myVar3
 etc
 What is the proper syntax to do this?
 Thanks,
 > Tim

--
+--- my people are the people of the dessert, ---+
| Steve Edberg  [EMAIL PROTECTED] |
| University of California, Davis  (530)754-9127 |
| Programming/Database/SysAdmin   http://pgfsun.ucdavis.edu/ |
+ said t e lawrence, picking up his fork +
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Newbie Question: Variables on the fly

2004-05-28 Thread Curt Zirzow
* Thus wrote Steve Edberg ([EMAIL PROTECTED]):
> At 2:01 AM -0300 5/28/04, [EMAIL PROTECTED] wrote:
> 
> However, most of what you can do with them can be done more simply 
> with arrays. In your example above, use
> 
>   myPage.php?dataPoint[]=10&dataPoint[]=20&dataPoint[]=30
> 

I'd also suggest to add the index in the dataPoints, so you're not
relying on the browser or php to determain what order the array
will be built.

myPage.php?dataPoint[1]=10&dataPoint[3]=20&dataPoint[1]=30


Go Aggies!

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

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



RE: [PHP] Newbie Question: Variables on the fly

2004-05-28 Thread Steve Edberg
At 2:01 AM -0300 5/28/04, [EMAIL PROTECTED] wrote:
Thanks for the reply Denis,
Let me elaborate a bit.
I have a php page which I want to pass a series of variables via a url string.
eg
myPage.php?dataPoint1=10&dataPoint2=20&dataPoint3=30
The thing is I won;t know until runtime how many dataPoints there 
will be so I have also included 1 additional url variable

eg
myPage.php?totalDataPoints=3&dataPoint1=10&dataPoint2=20&dataPoint3=30
From there I want to take those data points and do several things 
with each of them.  The keep things simple lets say I want to 
multiply each by 3 and then divide it by 2 and put it into a new 
variable (under the same naming system).

eg
$xtemp=$HTTP_GET_VARS[totalDataPoints];
do {
A line here which will take each dataPoint and multiply by 3 
and divide by 2 and assign it to a new variable with the same 
numbering system (eg $myNewVar1=$HTTP_GET_VARS[dataPoint1]*3/2;
$xtemp--;
} while ($xtemp>0);

Make any more sense?
Thanks.

Strictly speaking, your original question referred to what PHP calls 
'variable variables':

http://us3.php.net/manual/en/language.variables.variable.php
However, most of what you can do with them can be done more simply 
with arrays. In your example above, use

myPage.php?dataPoint[]=10&dataPoint[]=20&dataPoint[]=30
and you get an array
$dataPoint[0]=10
$dataPoint[1]=20
$dataPoint[2]=30
The number of data points is count($dataPoint). See
http://us3.php.net/manual/en/language.variables.external.php
for more info on this technique.
steve edberg


At 01:24 AM 28/05/2004, Dennis Seavers <[EMAIL PROTECTED]> wrote:
Maybe others will catch on to your intention, but I think you need to
provide a bit more information.  For example, what variables do you want to
create (drawn from a file source, or create on the fly)?  Where will they
come from (a database, perhaps)?  You could create a script that creates
variables from scratch, following a (hopefully) finite mathematical
formula.  Or you could manipulate data that already exists, turning this
data into some kind of variables.
Ultimately, you'll have to give a better of sense of the end result you'd
like.
Dennis Seavers

 [Original Message]
 From: <[EMAIL PROTECTED]>
 To: PHP List <[EMAIL PROTECTED]>
 Date: 05/27/2004 9:17:11 PM
 > Subject: [PHP] Newbie Question: Variables on the fly
 Hello,
 I'm sure this is a newbie question but I don't know the syntax.
 I want to create a series of variables within a php script at runtime
with
 a for loop.
 eg
 myVar1
 myVar2
 myVar3
 etc
 What is the proper syntax to do this?
 Thanks,
 > Tim


--
+--- my people are the people of the dessert, ---+
| Steve Edberg  [EMAIL PROTECTED] |
| University of California, Davis  (530)754-9127 |
| Programming/Database/SysAdmin   http://pgfsun.ucdavis.edu/ |
+ said t e lawrence, picking up his fork +
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Newbie Question: Variables on the fly

2004-05-28 Thread PHP4web
ok let say that you have 2 or more variables with same name but there are
difference in numbering And Values like this :

$var1 = 1 ;
$var2 =  12 ;
// etc ..

now you must now how much of number of this varibles before you deal with it
or you must store it on array to know how to count it in the fly like this :

$var[var1] = 1;
$var[var2] = 12;
// etc ..
$var_count  = count($var); // give you the count

now you can deal with vars like this :

$i = 1;
do {
$NewVar["NewVar".$i] = $var["var".$i] * $WhatEver ;
$i++;
}
while ($i <= $var_count );

And finally you can extract vars by extract() to make them in normal shape
if you get my point

- Original Message - 
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, May 28, 2004 8:01 AM
Subject: RE: [PHP] Newbie Question: Variables on the fly


> Thanks for the reply Denis,
>
> Let me elaborate a bit.
>
> I have a php page which I want to pass a series of variables via a url
string.
>
> eg
>
> myPage.php?dataPoint1=10&dataPoint2=20&dataPoint3=30
>
> The thing is I won;t know until runtime how many dataPoints there will be
> so I have also included 1 additional url variable
>
> eg
>
> myPage.php?totalDataPoints=3&dataPoint1=10&dataPoint2=20&dataPoint3=30
>
>  From there I want to take those data points and do several things with
> each of them.  The keep things simple lets say I want to multiply each by
3
> and then divide it by 2 and put it into a new variable (under the same
> naming system).
>
> eg
>
> $xtemp=$HTTP_GET_VARS[totalDataPoints];
>
> do {
>  A line here which will take each dataPoint and multiply by 3 and
> divide by 2 and assign it to a new variable with the same numbering system
> (eg $myNewVar1=$HTTP_GET_VARS[dataPoint1]*3/2;
>  $xtemp--;
> } while ($xtemp>0);
>
> Make any more sense?
>
> Thanks.
>
>
> At 01:24 AM 28/05/2004, Dennis Seavers wrote:
> >Maybe others will catch on to your intention, but I think you need to
> >provide a bit more information.  For example, what variables do you want
to
> >create (drawn from a file source, or create on the fly)?  Where will they
> >come from (a database, perhaps)?  You could create a script that creates
> >variables from scratch, following a (hopefully) finite mathematical
> >formula.  Or you could manipulate data that already exists, turning this
> >data into some kind of variables.
> >
> >Ultimately, you'll have to give a better of sense of the end result you'd
> >like.
> >
> >Dennis Seavers
> >
> >
> > > [Original Message]
> > > From: <[EMAIL PROTECTED]>
> > > To: PHP List <[EMAIL PROTECTED]>
> > > Date: 05/27/2004 9:17:11 PM
> > > Subject: [PHP] Newbie Question: Variables on the fly
> > >
> > > Hello,
> > >
> > > I'm sure this is a newbie question but I don't know the syntax.
> > >
> > > I want to create a series of variables within a php script at runtime
> >with
> > > a for loop.
> > >
> > > eg
> > >
> > > myVar1
> > > myVar2
> > > myVar3
> > > etc
> > >
> > > What is the proper syntax to do this?
> > >
> > > Thanks,
> > >
> > > Tim
> > >
> > > --
> > > 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 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] Newbie Question: Variables on the fly

2004-05-27 Thread csnm
Thanks for the reply Denis,
Let me elaborate a bit.
I have a php page which I want to pass a series of variables via a url string.
eg
myPage.php?dataPoint1=10&dataPoint2=20&dataPoint3=30
The thing is I won;t know until runtime how many dataPoints there will be 
so I have also included 1 additional url variable

eg
myPage.php?totalDataPoints=3&dataPoint1=10&dataPoint2=20&dataPoint3=30
From there I want to take those data points and do several things with 
each of them.  The keep things simple lets say I want to multiply each by 3 
and then divide it by 2 and put it into a new variable (under the same 
naming system).

eg
$xtemp=$HTTP_GET_VARS[totalDataPoints];
do {
A line here which will take each dataPoint and multiply by 3 and 
divide by 2 and assign it to a new variable with the same numbering system 
(eg $myNewVar1=$HTTP_GET_VARS[dataPoint1]*3/2;
$xtemp--;
} while ($xtemp>0);

Make any more sense?
Thanks.
At 01:24 AM 28/05/2004, Dennis Seavers wrote:
Maybe others will catch on to your intention, but I think you need to
provide a bit more information.  For example, what variables do you want to
create (drawn from a file source, or create on the fly)?  Where will they
come from (a database, perhaps)?  You could create a script that creates
variables from scratch, following a (hopefully) finite mathematical
formula.  Or you could manipulate data that already exists, turning this
data into some kind of variables.
Ultimately, you'll have to give a better of sense of the end result you'd
like.
Dennis Seavers
> [Original Message]
> From: <[EMAIL PROTECTED]>
> To: PHP List <[EMAIL PROTECTED]>
> Date: 05/27/2004 9:17:11 PM
> Subject: [PHP] Newbie Question: Variables on the fly
>
> Hello,
>
> I'm sure this is a newbie question but I don't know the syntax.
>
> I want to create a series of variables within a php script at runtime
with
> a for loop.
>
> eg
>
> myVar1
> myVar2
> myVar3
> etc
>
> What is the proper syntax to do this?
>
> Thanks,
>
> Tim
>
> --
> 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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Newbie Question: Variables on the fly

2004-05-27 Thread Dennis Seavers
Yikes!!

List members, I apologize for sending a reply-requested e-mail over this
list.  Feel free to punish me by responding.  What's worse: I took another
list member to task for the same thing!

"Ego deflation commences in 5 ... 4 ... 3 ... "

Dennis JackArse (the "JackArse" is silent)


> [Original Message]
> From: Dennis Seavers <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Date: 05/27/2004 9:30:19 PM
> Subject: RE: [PHP] Newbie Question: Variables on the fly
>
> Maybe others will catch on to your intention, but I think you need to
> provide a bit more information.  For example, what variables do you want
to
> create (drawn from a file source, or create on the fly)?  Where will they
> come from (a database, perhaps)?  You could create a script that creates
> variables from scratch, following a (hopefully) finite mathematical
> formula.  Or you could manipulate data that already exists, turning this
> data into some kind of variables.
>
> Ultimately, you'll have to give a better of sense of the end result you'd
> like.
>
> Dennis Seavers
>
>
> > [Original Message]
> > From: <[EMAIL PROTECTED]>
> > To: PHP List <[EMAIL PROTECTED]>
> > Date: 05/27/2004 9:17:11 PM
> > Subject: [PHP] Newbie Question: Variables on the fly
> >
> > Hello,
> >
> > I'm sure this is a newbie question but I don't know the syntax.
> >
> > I want to create a series of variables within a php script at runtime
> with 
> > a for loop.
> >
> > eg
> >
> > myVar1
> > myVar2
> > myVar3
> > etc
> >
> > What is the proper syntax to do this?
> >
> > Thanks,
> >
> > Tim
> >
> > -- 
> > 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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Newbie Question: Variables on the fly

2004-05-27 Thread Dennis Seavers
Maybe others will catch on to your intention, but I think you need to
provide a bit more information.  For example, what variables do you want to
create (drawn from a file source, or create on the fly)?  Where will they
come from (a database, perhaps)?  You could create a script that creates
variables from scratch, following a (hopefully) finite mathematical
formula.  Or you could manipulate data that already exists, turning this
data into some kind of variables.

Ultimately, you'll have to give a better of sense of the end result you'd
like.

Dennis Seavers


> [Original Message]
> From: <[EMAIL PROTECTED]>
> To: PHP List <[EMAIL PROTECTED]>
> Date: 05/27/2004 9:17:11 PM
> Subject: [PHP] Newbie Question: Variables on the fly
>
> Hello,
>
> I'm sure this is a newbie question but I don't know the syntax.
>
> I want to create a series of variables within a php script at runtime
with 
> a for loop.
>
> eg
>
> myVar1
> myVar2
> myVar3
> etc
>
> What is the proper syntax to do this?
>
> Thanks,
>
> Tim
>
> -- 
> 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] newbie question about preg_match

2004-05-20 Thread Chris W. Parker
Al 
on Thursday, May 20, 2004 12:51 PM said:

> If I have multiple instances that match the pattern, but only want the
> first one, which is the best way to handle it?

reread the last sentence in John's post.

> John W. Holmes wrote:
> 
>> From: "Al" <[EMAIL PROTECTED]>

[snip]

>> Note that this will only return one match when there could be more,
>> depending upon your string. If you want all of them, use
>> preg_match_all(). 



hth,
chris.

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



Re: [PHP] newbie question about preg_match

2004-05-20 Thread Al
If I have multiple instances that match the pattern, but only want the 
first one, which is the best way to handle it?

Putting the "U" flag seems to work, but I don't understand the full 
implications of using it here. 

preg_match("|$start(.*?)$end |Ui", $contents, $text);
Alternatively, I could use preg_match_all and use $text [1]. 

Thanks
John W. Holmes wrote:
From: "Al" <[EMAIL PROTECTED]>
 

I'm trying to compose a general purpose text snip expression to extract
a text segment from a string.
Should this work for all reasonable cases?  It seems to work for several
test strings.
$start= "str1";
$end= "str2";
preg_match ("|$start (.*) ? $end |i", $contents, $text);
$segment= $text[1];
   

Looks like you have some extra spaces in there that'll mess it up. The '?'
for example, is only applying to the space before it.
You want
preg_match("|$start(.*?)$end |i", $contents, $text);
Note that this will only return one match when there could be more,
depending upon your string. If you want all of them, use preg_match_all().
---John Holmes...
 

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


Re: [PHP] newbie question about preg_match

2004-05-20 Thread John W. Holmes
From: "Al" <[EMAIL PROTECTED]>

> I'm trying to compose a general purpose text snip expression to extract
> a text segment from a string.
>
> Should this work for all reasonable cases?  It seems to work for several
> test strings.
>
> $start= "str1";
>
> $end= "str2";
>
> preg_match ("|$start (.*) ? $end |i", $contents, $text);
>
> $segment= $text[1];

Looks like you have some extra spaces in there that'll mess it up. The '?'
for example, is only applying to the space before it.

You want

preg_match("|$start(.*?)$end |i", $contents, $text);

Note that this will only return one match when there could be more,
depending upon your string. If you want all of them, use preg_match_all().

---John Holmes...

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



Re: [PHP] Newbie question about operators

2004-04-07 Thread Red Wingate
arrays :-)

you are defining arrays like:

$x = array ( 'a' => 'Apple' , 'b' => 'Banana' , ... );

 -- red

Gabe wrote:

Thanks for the page.  That was helpful.  Just to make sure, is that
operator only typically used then with foreach loops and arrays?
"Matt Matijevich" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
[snip]
foreach ($some_array as $name=>$value)
{
... some code ...
}
[/snip]
http://www.php.net/foreach

will give you a good explanation.


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


Re: [PHP] Newbie question about operators

2004-04-07 Thread Gabe
Thanks for the page.  That was helpful.  Just to make sure, is that
operator only typically used then with foreach loops and arrays?


"Matt Matijevich" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> [snip]
> foreach ($some_array as $name=>$value)
> {
>  ... some code ...
> }
> [/snip]
>
> http://www.php.net/foreach
>
> will give you a good explanation.

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



Re: [PHP] Newbie question about operators

2004-04-07 Thread Matt Matijevich
[snip]
foreach ($some_array as $name=>$value)
{
 ... some code ...
}
[/snip]

http://www.php.net/foreach 

will give you a good explanation.

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



Re: [PHP] Newbie question on Array

2004-03-28 Thread Jason Wong
On Monday 29 March 2004 03:27, [EMAIL PROTECTED] wrote:

> I am trying to construct an array with key-value from a resultSet which
> will be used often within the page or between pages.
>
> Which looks like this:
>
>  $optionBox="select used_1, rub from rub_table order by rub asc";
>   $rs_box=mysql_query($optionBox,$con);
>   $arr=Array(
>   while($row=mysql_fetch_array($rs_box))
>   {
>'$row["used_1"]' => '$row["rub"]'  ,
>   });
>
>  ,---> This does not need to appear in the last loop.
>
> Is this possible?

No. Try:

  $optionBox="select used_1, rub from rub_table order by rub asc";
  $rs_box=mysql_query($optionBox,$con);
  while($row=mysql_fetch_array($rs_box)) {
$my_array[$row['used_1']] => $row['rub'];
  }
  print_r($my_array);


-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
It is impossible for an optimist to be pleasantly surprised.
*/

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



Re: [PHP] newbie question

2004-02-24 Thread Chris Hayes
could it be that this is an old script that requires register_globals to be 
turned ON or so?
if you can read Dutch, read http://www.phpfreakz.nl/artikelen.php?aid=88

At 12:25 24-2-04, you wrote:
hi -

i don't know much about php, but somehow i managed to install a simple 
php-guestbook on my website:
http://www.maanzand.be/guestbookk/readbook.php

unfortunately, i cannot get it to work
everything seems fine, but i can't manage to write to the guestbook.txt file
(permissions are read&write, so i don't think that is causing the problem)
readbook.php & addbook.php seem to work fine, but when i fill in a message 
and hit the submit-button, nothing happens...

if anyone of you php-breathing maestro's could take a look at the 
guestbook and check if there's sth out of the ordinary, i would be 
eternally grateful...

maybe there are some features on the side of the server that i need to 
activate or something, so i've put the info.php file on the site too, if 
that helps you any further...
http://www.maanzand.be/info.php

thanx a billion,
wannes -
-
Just because I have a short attention span doesn't mean that I...
http://www.maanzand.be - under constant construction

[EMAIL PROTECTED]
016 28 48 42 - 0486 21 32 92
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Newbie question... date.

2004-01-13 Thread Ray
On Tuesday 13 January 2004 13:57, DL wrote:
> Hi all,
>
> I was wondering how you get the year, month, and day from a
> timestamp. (mySQL timestamp, Eg: 20040113130137)  What PHP
> function(s) do I use?  An example would be great
>
> Cheers,
> David

http://www.php.net/manual/en/function.strtotime.php
copied from the comments (formatting may be lost)

scott at pigandcow dot com
29-Dec-2003 09:54
Unfortunately, strtotime() can't convert mysql timestamps of the form 
MMDDhhmmss (the default 14 character timestamp).  Here's a 
function to do it for you:

function convert_timestamp ($timestamp, $adjust="") {
   $timestring = substr($timestamp,0,8)." ".
 substr($timestamp,8,2).":".
 substr($timestamp,10,2).":".
 substr($timestamp,12,2);
   return strtotime($timestring." $adjust");
}

Remember that the $adjust string needs to be properly spaced- "+ 30 
days", not "+30days"!

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



Re: [PHP] Newbie question... date.

2004-01-13 Thread Chris Boget
> I was wondering how you get the year, month, and day from a timestamp.
> (mySQL timestamp, Eg: 20040113130137)  What PHP function(s) do I use?  An
> example would be great

I *believe* you can use strtotime();

Chris

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



RE: [PHP] Newbie question

2004-01-13 Thread Sam Masiello

It appears as if you don't have MySQL support compiled in with your PHP
build.  If you installed it from source you will want to recompile PHP
with the --with-mysql option.  I have never installed PHP from RPM
though so if you installed it that way, perhaps someone else in the
group can provide some guidance on how to do that.

HTH!

--Sam



James Marcinek wrote:
> Hello Everyone,
> 
> I'm new to this so forgive my ignorance. I'm trying to use php with
> MySQL as a database. I'm using apache 2.0 in addition to Mysql 4.1. 
> 
> I created a simple page (using book to learn) and when I try to go to
> a simple  php script I recieve the following error: 
> 
> Call to undefined function:  mysql_connect()
> 
> I've followed the instructions and the mysql_connect() function has
> the correct arguments supplied ("host", "user", "passwd"); 
> 
> Can anyone shed any light on this? I've looked at the php.ini file
> and it looks ok. the apache has the php.conf file in the conf.d
> directory.  
> 
> The book I'm learning from had some simple examples pages that I
> created early on and they work; however this is the first attempt at
> trying to use php to connect.  
> 
> Any help would be appreciated.
> 
> Thanks,
> 
> James

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



Re: [PHP] Newbie question

2004-01-13 Thread Richard Davey
Hello James,

Tuesday, January 13, 2004, 3:37:17 PM, you wrote:

JM> The book I'm learning from had some simple examples pages that I created
JM> early on and they work; however this is the first attempt at trying to use
JM> php to connect.

Post your code (if it's from a book I'm guessing it isn't very long),
will be able to pinpoint cause of the error then.

-- 
Best regards,
 Richardmailto:[EMAIL PROTECTED]

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



Re: [PHP] newbie question about header()

2003-12-21 Thread Justin French
On Monday, December 22, 2003, at 01:13  PM, Website Managers.net wrote:

Unless you're using an 'if' statement, the header redirect must be the 
first line of the page, above any HTML markup.
That's not entirely accurate.

---Quoted from http://php.net/header ---
Remember that header() must be called before any actual output is sent, 
either by normal HTML tags, blank lines in a file, or from PHP. It is a 
very common error to read code with include(), or require(), functions, 
or another file access function, and have spaces or empty lines that 
are output before header() is called. The same problem exists when 
using a single PHP/HTML file.


header() doesn't need to be 'the first line of the page', but it does 
need to be placed above/before any output gets sent to the browser.

bad:


bad:

good:

if there's any code following the redirect (which you don't want to 
execute), I'd also strongly recommend having an exit; after the 
header():


Justin French

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


Re: [PHP] newbie question about header()

2003-12-21 Thread John W. Holmes
Scott Taylor wrote:



I am simply trying to redirect users from one page to another.  Yet when 
I use this code I get the following error:

*Warning*: Cannot add header information - headers already sent by 
(output started at 
/usr/local/psa/home/vhosts/miningstocks.com/httpdocs/etc/php/login/admin/test.php:8) 
in 
*/usr/local/psa/home/vhosts/miningstocks.com/httpdocs/etc/php/login/admin/test.php* 
on line *9*
*
*






http://www.slashdot.org/'); /* Redirect browser */
/* Make sure that code below does not get executed when we redirect. */
exit;
?>
You can't have any output before trying to use header(). , etc, 
are considered output. So, the very first line in your file must be 


--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

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


Re: [PHP] newbie question about header()

2003-12-21 Thread Website Managers.net
Unless you're using an 'if' statement, the header redirect must be the first line of 
the page, above any HTML markup.

Jim
www.websitemanagers.net

- Original Message - 
From: "Scott Taylor" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, December 21, 2003 8:04 PM
Subject: [PHP] newbie question about header()


| 
| 
| I am simply trying to redirect users from one page to another.  Yet when 
| I use this code I get the following error:
| 
| *Warning*: Cannot add header information - headers already sent by 
| (output started at 
| /usr/local/psa/home/vhosts/miningstocks.com/httpdocs/etc/php/login/admin/test.php:8) 
| in 
| */usr/local/psa/home/vhosts/miningstocks.com/httpdocs/etc/php/login/admin/test.php* 
| on line *9*
| *
| *
| 
| 
| 
| 
| 
| 
| 
| http://www.slashdot.org/'); /* Redirect browser */
| 
| /* Make sure that code below does not get executed when we redirect. */
| exit;
| ?>
| 
| 
| 
| 
| 
| 
| I know the workaround with the meta tag (http://www.slashdot.org/";>, but I just don't understand 
| what I am doing wrong here.  I'm sure someone here knows
| 
| Thank you in advance,
| 
| Scott Taylor
| [EMAIL PROTECTED]
| 
| -- 
| 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] newbie question about scope

2003-11-12 Thread Jay Blanchard
[snip]
Unless I'm misunderstanding something, PHP does not implement
scoping (at least in the sense that many other programming languages
do) prior to PHP5.  
[/snip]

Actually it does implement scoping, see
http://us2.php.net/language.variables.scope

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



Re: [PHP] newbie question about scope

2003-11-12 Thread news.comcast.giganews.com

"Derek Ford" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> news.comcast.giganews.com wrote:
>
> >I am an experienced web developer who is just getting into php.  I have
had
> >a php project fall into my lap and wanted a little advice.  Here is the
> >scoop:
> >
> >A client moved their site from a server (unknown details) to a
hosting
> >facility (php 4.3.2).  Now none of the scripts work.  I have guessed that
> >they are coming from an earlier version of apache/php.  Anyway it appears
> >that whoever created the site in the first place did not believe in
scoping
> >variables.  Now any variable that is not properly scoped will not be read
by
> >the server.  I know I can simply scope all of the variables, but I was
> >hoping there may be an easier way.  Also, how bad is the _REQUEST scope I
> >read that "it could not be trusted", however the previous developer
created
> >the app in such a way that several places a variable could be _GET or
_POST.
> >I apologize for the rambling and possible incoherency of this message, I
am
> >a bit tired.
> >
> >Matthew
> >
> >PS. How do you scope queries?
> >
> >
> >
> You're thinking about this in the wrong way, it seems. The server
> probably has register_globals Off, where previously he was programming
> with it being On. or vise-versa. They should be Off, and should be left
> off, but programming with them off needs some adjusting. Variables such
> as post and get data are now 'superglobals', and must use the
> appropriate arrays; $_GET[], and $_POST[]. There are things like
> extract(), but using them is not advised. as per your question about
> "scope queries", be more concrete :)

I agree that is the way it should be, but my client is looking for a quick
fix, not a good one.  In the end it is fortunate for my client that the
quick fix is not a viable one.  I agree that all variables should be scoped,
it is the right way to do things.  I think I have my query question figured
out.

Thanks

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



RE: [PHP] newbie question about scope

2003-11-12 Thread Jay Blanchard
[snip]
A client moved their site from a server (unknown details) to a
hosting
facility (php 4.3.2).  Now none of the scripts work.  I have guessed
that
they are coming from an earlier version of apache/php.
[/snip]

It is likely then that register_globals is set to OFF in the php.ini. In
earlier versions this directive was set to ON. It was a "security issue"
that was more about bad coding than a PHP vulnerability. If you passed a
form field with the name of userName it could be accessed by PHP in the
$userName variable, with RG off you would have to access it via
$_GET['userName'] or $_POST['userName'] dependent upon the processing
method of the form.

[snip]
Also, how bad is the _REQUEST scope I read that "it could not be
trusted"
[/snip]

Again, bad coding would present a danger here.

[snip]
PS. How do you scope queries?
[/snip]

I am not sure what you are asking here. Do you mean making a query
public or private?

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



Re: [PHP] newbie question about scope

2003-11-12 Thread Derek Ford
news.comcast.giganews.com wrote:

I am an experienced web developer who is just getting into php.  I have had
a php project fall into my lap and wanted a little advice.  Here is the
scoop:
   A client moved their site from a server (unknown details) to a hosting
facility (php 4.3.2).  Now none of the scripts work.  I have guessed that
they are coming from an earlier version of apache/php.  Anyway it appears
that whoever created the site in the first place did not believe in scoping
variables.  Now any variable that is not properly scoped will not be read by
the server.  I know I can simply scope all of the variables, but I was
hoping there may be an easier way.  Also, how bad is the _REQUEST scope I
read that "it could not be trusted", however the previous developer created
the app in such a way that several places a variable could be _GET or _POST.
I apologize for the rambling and possible incoherency of this message, I am
a bit tired.
Matthew

PS. How do you scope queries?

 

You're thinking about this in the wrong way, it seems. The server 
probably has register_globals Off, where previously he was programming 
with it being On. or vise-versa. They should be Off, and should be left 
off, but programming with them off needs some adjusting. Variables such 
as post and get data are now 'superglobals', and must use the 
appropriate arrays; $_GET[], and $_POST[]. There are things like 
extract(), but using them is not advised. as per your question about 
"scope queries", be more concrete :)

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


Re: [PHP] Newbie question about Class

2003-10-17 Thread Rory McKinley
Hi Al

Sessions and objects are quite easy to use in the latest version of PHP, and
would be my personal recommendation. I have a coupleof test scripts that I
regularly
"mangle" when trying to see if something is doable...if you like, you can
contact me offlist and I will mail these to you and you can try it out for
yourself.

Regards

Rory McKinley
Nebula Solutions
+27 82 857 2391
[EMAIL PROTECTED]
"There are 10 kinds of people in this world,
those who understand binary and those who don't" (Unknown)
- Original Message - 
From: "Al" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, October 15, 2003 8:15 PM
Subject: Re: [PHP] Newbie question about Class


> I was afraid that was the case.
>
> Tom Rogers wrote:
>
> >Hi,
> >
> >Thursday, October 16, 2003, 3:35:56 AM, you wrote:
> >A> My question seems fundamental.  I want to set a variable in one
function
> >A> in a class and then want to use the value in a second function.
> >A> However, the functions are called a html page with two passes.  Submit
> >A> reloads the page and an if(...) calls the second function in the
class.
> >
> >A> If I declare on the first run:
> >A> $get_data = new edit_tag_file();
> >A> $edit_args= $get_data-> edit_prep();
> >
> >A> The on the second pass, I'm stuck.  I can't declare a new instance of
> >A> "edit_tag_data".
> >A> And, it appears the object is gone after I leave the page.
> >
> >A> Will the class structure do this for me or must I save the values in
> >A> $GLOBAL or something?
> >
> >A> Thanks
> >
> >
> >You need to pass the values to the next page or save them in a session
> >
> >
> >
>
> -- 
> 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] Newbie question about Class

2003-10-17 Thread Becoming Digital
> I was afraid that was the case. 

You've nothing to fear but fear itself.  Sessions are your friend.

Edward Dudlik
"Those who say it cannot be done
should not interrupt the person doing it."

wishy washy | www.amazon.com/o/registry/EGDXEBBWTYUU



- Original Message - 
From: "Al" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, 15 October, 2003 14:15
Subject: Re: [PHP] Newbie question about Class


I was afraid that was the case. 

Tom Rogers wrote:

>Hi,
>
>Thursday, October 16, 2003, 3:35:56 AM, you wrote:
>A> My question seems fundamental.  I want to set a variable in one function 
>A> in a class and then want to use the value in a second function.  
>A> However, the functions are called a html page with two passes.  Submit 
>A> reloads the page and an if(...) calls the second function in the class.
>
>A> If I declare on the first run:
>A> $get_data = new edit_tag_file();
>A> $edit_args= $get_data-> edit_prep();
>
>A> The on the second pass, I'm stuck.  I can't declare a new instance of 
>A> "edit_tag_data".
>A> And, it appears the object is gone after I leave the page. 
>
>A> Will the class structure do this for me or must I save the values in 
>A> $GLOBAL or something?
>
>A> Thanks
>
>
>You need to pass the values to the next page or save them in a session
>
>  
>

-- 
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] Newbie question about Class

2003-10-15 Thread Al
I was afraid that was the case. 

Tom Rogers wrote:

Hi,

Thursday, October 16, 2003, 3:35:56 AM, you wrote:
A> My question seems fundamental.  I want to set a variable in one function 
A> in a class and then want to use the value in a second function.  
A> However, the functions are called a html page with two passes.  Submit 
A> reloads the page and an if(...) calls the second function in the class.

A> If I declare on the first run:
A> $get_data = new edit_tag_file();
A> $edit_args= $get_data-> edit_prep();
A> The on the second pass, I'm stuck.  I can't declare a new instance of 
A> "edit_tag_data".
A> And, it appears the object is gone after I leave the page. 

A> Will the class structure do this for me or must I save the values in 
A> $GLOBAL or something?

A> Thanks

You need to pass the values to the next page or save them in a session

 

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


Re: [PHP] Newbie question about Class

2003-10-15 Thread Tom Rogers
Hi,

Thursday, October 16, 2003, 3:35:56 AM, you wrote:
A> My question seems fundamental.  I want to set a variable in one function 
A> in a class and then want to use the value in a second function.  
A> However, the functions are called a html page with two passes.  Submit 
A> reloads the page and an if(...) calls the second function in the class.

A> If I declare on the first run:
A> $get_data = new edit_tag_file();
A> $edit_args= $get_data-> edit_prep();

A> The on the second pass, I'm stuck.  I can't declare a new instance of 
A> "edit_tag_data".
A> And, it appears the object is gone after I leave the page. 

A> Will the class structure do this for me or must I save the values in 
A> $GLOBAL or something?

A> Thanks


You need to pass the values to the next page or save them in a session

-- 
regards,
Tom

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



RE: [PHP] Newbie question about Class

2003-10-15 Thread Chris W. Parker
Al 
on Wednesday, October 15, 2003 10:36 AM said:

> Will the class structure do this for me or must I save the values in
> $GLOBAL or something?

I think you'd have to send the value via $_GET or save it in a session
variable if you want to retrieve it on another page.


Chris.

--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/

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



RE: [PHP] newbie question

2003-10-14 Thread Ford, Mike [LSS]
On 13 October 2003 13:49, 'Eugene Lee' wrote:

> On Mon, Oct 13, 2003 at 10:32:18AM +0100, Ford, Mike
>  [LSS] wrote:
> > 
> > On 12 October 2003 23:36, Eugene Lee wrote:
> > > 
> > > The PHP manual is vague in several sections.  I wonder how bug
> > > reports get submitted for it?
> > 
> > http://bugs.php.net/report.php and select "Documentation problem"
> > from the "Type of bug" drop-down.  (But read the bug-reporting
> > guidelines at http://php.bugs.php.net/ first!)
> 
> Thanks Mike, I'll give it a read when I get free!

Whoops! -- that second URL should, of course, be just http://bugs.php.net/.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



Re: [PHP] newbie question

2003-10-13 Thread 'Eugene Lee'
On Mon, Oct 13, 2003 at 10:32:18AM +0100, Ford, Mike   [LSS] wrote:
: 
: On 12 October 2003 23:36, Eugene Lee wrote:
: > 
: > The PHP manual is vague in several sections.  I wonder how bug
: > reports get submitted for it? 
: 
: http://bugs.php.net/report.php and select "Documentation problem" from
: the "Type of bug" drop-down.  (But read the bug-reporting guidelines
: at http://php.bugs.php.net/ first!)

Thanks Mike, I'll give it a read when I get free!

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



RE: [PHP] newbie question

2003-10-13 Thread Ford, Mike [LSS]
On 12 October 2003 23:36, Eugene Lee wrote:

> On Mon, Oct 13, 2003 at 03:23:53AM +1000, Wang Feng wrote:
> > 
> >  "1. An optional padding specifier that says what character will be
> > used for padding the results to the right string size. This may be
> > a space character or a 0 (zero character). The default is to pad
> > with spaces. An alternate padding character can be specified by
> > prefixing it with a single quote ('). See the examples below." "3.
> > An optional number, a width specifier that says how many characters
> > (minimum) this conversion should result in." 
> > http://au.php.net/manual/en/function.sprintf.php 
> > 
> > Assume that $price=.65; then the "%0.2f" yields 0.65.
> > 
> > If we follow what the manual says, then can you tell me what the 0
> > is used for? Is it a (optional) paddinng spcifier OR is it a
> > (optional) width specifier OR both? And why does it yiled 0.65
> > rather than .65? 
> > 
> > (The manual doesn't explain things clear, man.)
> 
> The PHP manual is vague in several sections.  I wonder how bug
> reports get submitted for it? 

http://bugs.php.net/report.php and select "Documentation problem" from the
"Type of bug" drop-down.  (But read the bug-reporting guidelines at
http://php.bugs.php.net/ first!)

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



Re: [PHP] newbie question

2003-10-12 Thread Eugene Lee
On Mon, Oct 13, 2003 at 03:23:53AM +1000, Wang Feng wrote:
: 
:  "1. An optional padding specifier that says what character will be used for
: padding the results to the right string size. This may be a space character
: or a 0 (zero character). The default is to pad with spaces. An alternate
: padding character can be specified by prefixing it with a single quote (').
: See the examples below."
: "3. An optional number, a width specifier that says how many characters
: (minimum) this conversion should result in."
:  http://au.php.net/manual/en/function.sprintf.php
: 
: Assume that $price=.65; then the "%0.2f" yields 0.65.
: 
: If we follow what the manual says, then can you tell me what the 0 is used
: for? Is it a (optional) paddinng spcifier OR is it a (optional) width
: specifier OR both? And why does it yiled 0.65 rather than .65?
: 
: (The manual doesn't explain things clear, man.)

The PHP manual is vague in several sections.  I wonder how bug reports
get submitted for it?

The optional specifiers to the left of the decimal place have a psuedo
last-to-first precedence.  For example:

$price = .65;

printf("'%8.2f'\n", $price);
-> '   0.65'

This shows that there are 8 characters reserved for the number to the
left of the decimal.  Therefore, '8' is the width specifier.

printf("'%-8.2f'\n", $price);
-> '0.65   '

printf("'%08.2f'\n", $price);
-> '.65'

printf("'%0-8.2f'\n", $price);
-> '0.65000'

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



Re: [PHP] newbie question

2003-10-12 Thread Wang Feng
 "1. An optional padding specifier that says what character will be used for
padding the results to the right string size. This may be a space character
or a 0 (zero character). The default is to pad with spaces. An alternate
padding character can be specified by prefixing it with a single quote (').
See the examples below."
"3. An optional number, a width specifier that says how many characters
(minimum) this conversion should result in."
 http://au.php.net/manual/en/function.sprintf.php



Assume that $price=.65; then the "%0.2f" yields 0.65.

If we follow what the manual says, then can you tell me what the 0 is used
for? Is it a (optional) paddinng spcifier OR is it a (optional) width
specifier OR both? And why does it yiled 0.65 rather than .65?


(The manual doesn't explain things clear, man.)


cheers,

feng


- Original Message -
From: "Robert Cummings" <[EMAIL PROTECTED]>
To: "Wang Feng" <[EMAIL PROTECTED]>
Cc: "Curt Zirzow" <[EMAIL PROTECTED]>; "PHP-General"
<[EMAIL PROTECTED]>
Sent: Monday, October 13, 2003 2:29 AM
Subject: Re: [PHP] newbie question

> I believe the documentation (in at least on of the ?printf() functions
> describes how the implementation follows the C specs. I'm pretty sure
> the ?printf() family of functions were added almost entirely for the
> benefit of C coders :)
>
> Cheers,
> Rob.
>
> >
> >
> > cheers,
> >
> > feng
> >
> >
> >
> > - Original Message -
> > From: "Curt Zirzow" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Monday, October 13, 2003 2:01 AM
> > Subject: Re: [PHP] newbie question
> >
> >
> > > * Thus wrote Eugene Lee ([EMAIL PROTECTED]):
> > > > On Sun, Oct 12, 2003 at 06:57:35PM +1000, Wang Feng wrote:
> > > > :
> > > > : If I get rid of the 0 and tried this:
> > > > :
> > > > : $price=.65;
> > > > : $f_price=sprintf("%1.2f",$price);
> > > > :
> > > > : It displays "0.65" in my Mozilla browser correctly. What do you sa
y
> > then?
> > > >
> > > > I say, "I dunno".  :-)  It seems to follow C's printf(3) conversion
> > > > specification.  If a decimal point is needed for a float, it must
also
> > > > have a digit in front of the decimal point.  This is kind of
annoying if
> > > > I want to print decimal-only values without preceding zeroes.  Maybe
> > > > money_format() is a better solution.
> > >
> > > yep, and even  "%0.2f" yields 0.65
> > >
> > >
> > > Curt
> > > --
> > > "My PHP key is worn out"
> > >
> > >   PHP List stats since 1997:
> > >   http://zirzow.dyndns.org/html/mlists/
> > >
> > > --
> > > 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
> >
> >
> --
> ..
> | InterJinn Application Framework - http://www.interjinn.com |
> ::
> | An application and templating framework for PHP. Boasting  |
> | a powerful, scalable system for accessing system services  |
> | such as forms, properties, sessions, and caches. InterJinn |
> | also provides an extremely flexible architecture for   |
> | creating re-usable components quickly and easily.  |
> `'
>
> --
> 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] newbie question

2003-10-12 Thread Robert Cummings
On Sun, 2003-10-12 at 12:19, Wang Feng wrote:
> I think, without any help, the only way to make it clear is to read the
> source code of that function in php. The manual doesn't explain the function
> well.
> 
> But I'm sure many people here knows the answer well. Come on. Where are you?

I believe the documentation (in at least on of the ?printf() functions
describes how the implementation follows the C specs. I'm pretty sure
the ?printf() family of functions were added almost entirely for the
benefit of C coders :)

Cheers,
Rob.

> 
> 
> cheers,
> 
> feng
> 
> 
> 
> - Original Message -
> From: "Curt Zirzow" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, October 13, 2003 2:01 AM
> Subject: Re: [PHP] newbie question
> 
> 
> > * Thus wrote Eugene Lee ([EMAIL PROTECTED]):
> > > On Sun, Oct 12, 2003 at 06:57:35PM +1000, Wang Feng wrote:
> > > :
> > > : If I get rid of the 0 and tried this:
> > > :
> > > : $price=.65;
> > > : $f_price=sprintf("%1.2f",$price);
> > > :
> > > : It displays "0.65" in my Mozilla browser correctly. What do you say
> then?
> > >
> > > I say, "I dunno".  :-)  It seems to follow C's printf(3) conversion
> > > specification.  If a decimal point is needed for a float, it must also
> > > have a digit in front of the decimal point.  This is kind of annoying if
> > > I want to print decimal-only values without preceding zeroes.  Maybe
> > > money_format() is a better solution.
> >
> > yep, and even  "%0.2f" yields 0.65
> >
> >
> > Curt
> > --
> > "My PHP key is worn out"
> >
> >   PHP List stats since 1997:
> >   http://zirzow.dyndns.org/html/mlists/
> >
> > --
> > 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
> 
> 
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] newbie question

2003-10-12 Thread Wang Feng
I think, without any help, the only way to make it clear is to read the
source code of that function in php. The manual doesn't explain the function
well.

But I'm sure many people here knows the answer well. Come on. Where are you?


cheers,

feng



- Original Message -
From: "Curt Zirzow" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, October 13, 2003 2:01 AM
Subject: Re: [PHP] newbie question


> * Thus wrote Eugene Lee ([EMAIL PROTECTED]):
> > On Sun, Oct 12, 2003 at 06:57:35PM +1000, Wang Feng wrote:
> > :
> > : If I get rid of the 0 and tried this:
> > :
> > : $price=.65;
> > : $f_price=sprintf("%1.2f",$price);
> > :
> > : It displays "0.65" in my Mozilla browser correctly. What do you say
then?
> >
> > I say, "I dunno".  :-)  It seems to follow C's printf(3) conversion
> > specification.  If a decimal point is needed for a float, it must also
> > have a digit in front of the decimal point.  This is kind of annoying if
> > I want to print decimal-only values without preceding zeroes.  Maybe
> > money_format() is a better solution.
>
> yep, and even  "%0.2f" yields 0.65
>
>
> Curt
> --
> "My PHP key is worn out"
>
>   PHP List stats since 1997:
>   http://zirzow.dyndns.org/html/mlists/
>
> --
> 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] newbie question

2003-10-12 Thread Curt Zirzow
* Thus wrote Eugene Lee ([EMAIL PROTECTED]):
> On Sun, Oct 12, 2003 at 06:57:35PM +1000, Wang Feng wrote:
> : 
> : If I get rid of the 0 and tried this:
> : 
> : $price=.65;
> : $f_price=sprintf("%1.2f",$price);
> : 
> : It displays "0.65" in my Mozilla browser correctly. What do you say then?
> 
> I say, "I dunno".  :-)  It seems to follow C's printf(3) conversion
> specification.  If a decimal point is needed for a float, it must also
> have a digit in front of the decimal point.  This is kind of annoying if
> I want to print decimal-only values without preceding zeroes.  Maybe
> money_format() is a better solution.

yep, and even  "%0.2f" yields 0.65


Curt
-- 
"My PHP key is worn out"

  PHP List stats since 1997: 
  http://zirzow.dyndns.org/html/mlists/

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



Re: [PHP] newbie question

2003-10-12 Thread Eugene Lee
On Sun, Oct 12, 2003 at 06:57:35PM +1000, Wang Feng wrote:
: 
: If I get rid of the 0 and tried this:
: 
: $price=.65;
: $f_price=sprintf("%1.2f",$price);
: 
: It displays "0.65" in my Mozilla browser correctly. What do you say then?

I say, "I dunno".  :-)  It seems to follow C's printf(3) conversion
specification.  If a decimal point is needed for a float, it must also
have a digit in front of the decimal point.  This is kind of annoying if
I want to print decimal-only values without preceding zeroes.  Maybe
money_format() is a better solution.

: BTW, what's the 1 used for?

Specifies the minimum character width of the conversion.  See PHP's
sprintf() docs for more details.


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



Re: [PHP] newbie question

2003-10-12 Thread Wang Feng
Hi, Eugene,

If I get rid of the 0 and tried this:

$price=.65;
$f_price=sprintf("%1.2f",$price);

It displays "0.65" in my Mozilla browser correctly. What do you say then?

BTW, what's the 1 used for?

cheers,

feng


- Original Message -
From: "Eugene Lee" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, October 12, 2003 6:49 PM
Subject: Re: [PHP] newbie question


> On Sun, Oct 12, 2003 at 06:09:21PM +1000, Wang Feng wrote:
> :
> : This is the example from the php manual:
> [...]
> : $formatted = sprintf("%01.2f", $money);// my question comes here
> : // echo $formatted will output "123.10"
> [...]
> :
> : I don't understand the meaning of the 01 above, which follows the %
sign. I
> : tried the "%.2f" and "%1.2f", both work fine. So, what's the meaning of
> : 01(especially what the 0 is for)? Seems very much the same as C anyway
:-).
>
> The "01" part guarantees that your money always has a preceding "0" for
> decimal-only amounts.  For example, ".15" should be displayed as "0.15".
>
> --
> 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] newbie question

2003-10-12 Thread Eugene Lee
On Sun, Oct 12, 2003 at 06:09:21PM +1000, Wang Feng wrote:
: 
: This is the example from the php manual:
[...]
: $formatted = sprintf("%01.2f", $money);// my question comes here
: // echo $formatted will output "123.10"
[...]
: 
: I don't understand the meaning of the 01 above, which follows the % sign. I
: tried the "%.2f" and "%1.2f", both work fine. So, what's the meaning of
: 01(especially what the 0 is for)? Seems very much the same as C anyway :-).

The "01" part guarantees that your money always has a preceding "0" for
decimal-only amounts.  For example, ".15" should be displayed as "0.15".

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



Re: [PHP] Newbie Question

2003-08-22 Thread Phil King
Hi Everyone,

Thanks a lot for all your advice, I really appreciate it.

PHP / mysql is new to me so excuse my ignorance of the subject..

I will go get phpMyAdmin and give it a whirl.

Thanks again.

Phil.



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



RE: [PHP] Newbie Question

2003-08-21 Thread Van Andel, Robbert
Whether you write the gui interface or someone else does doens't make a
difference.

Robbert van Andel 



-Original Message-
From: Phil King [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 21, 2003 11:49 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Newbie Question


Hi Robbert,

I beleive my ISP does not allow any GUI interface into mysql databases on
the server.
They have advised me that ALL functions, table creation, modification,
loading data etc has to be done from PHP.

It appears I have to use SQL statements within a PHP page to load the data.

Phil.

"Van Andel" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
m...
> Sorry, I did mean phpMyAdmin (no such thing as phpMySQL).  Brain fart.
> Won't happen again.
>
> Robbert van Andel
>
>
>
> -Original Message-
> From: Dan Van Derveer [mailto:[EMAIL PROTECTED]
> Sent: Thursday, August 21, 2003 9:25 AM
> To: '[EMAIL PROTECTED]'
> Subject: RE: [PHP] Newbie Question
>
>
> On the same note I recommend phpMyAdmin(www.phpmyadmin.net). Its interface
> is quite useful especially when you have multiple DB's to manage on the
same
> server.
>
> Dan
>
> -Original Message-
> From: Van Andel, Robbert [mailto:[EMAIL PROTECTED]
> Sent: Thursday, August 21, 2003 12:24 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [PHP] Newbie Question
>
> You can download PHPMySQL and locate it in a secure portion of your site.
> It's an excellent gui interface into mySQL.  This tool will allow you to
> upload the script file and insert the data.  I'm sorry, but I don't know
the
> URL where to get it.  Check sourceforge.
>
> Robbert van Andel
>
>
> -Original Message-
> From: Phil King [mailto:[EMAIL PROTECTED]
> Sent: Thursday, August 21, 2003 7:40 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Newbie Question
>
>
> Hi,
>
> I 'm in the process of modify one of my sites to use PHP/mysql instead of
> ASP/Ms Access.
>
> The Access database has 200 records in it.
>
> I have PWS, mysql and PHP running on my local PC.
>
> I have used Navicat from mysqlstudio.com to import the access database
into
> mysql and then exported the data back out as an sql script.
> The script consists of multiple sql statements like :
>
> INSERT INTO mydatabase
>   (id, Description, Department, RetailPrice, PrefSupPartNo, PrefSupplier)
> VALUES
>   (1, "Bunting Plastic Union Jack 4m", "Flags & Bunting", "2.5", "JFB",
> "Smiths");
>
> Is there a way of "including" the sql script file into a PHP page or do I
> have to copy and paste the statements into a PHP page with a "mysql_query"
> statement after each sql statement, to load these records to my ISP's
remote
> server.
>
> p.s My ISP has no GUI interface into mysql so all manipulation is done via
> PHP.
>
> Thanks very much for any guidence.
>
> Phil.
>
>
>
>
> -- 
> 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 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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Newbie Question

2003-08-21 Thread Bryan Koschmann - GKT
> Hi Robbert,
>
> I beleive my ISP does not allow any GUI interface into mysql databases on
> the server.
> They have advised me that ALL functions, table creation, modification,
> loading data etc has to be done from PHP.
>
> It appears I have to use SQL statements within a PHP page to load the data.


It's web based, uses PHP to do everything. Pretty cool setup.

Bryan


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



Re: [PHP] Newbie Question

2003-08-21 Thread Robert Cummings
Even if they do know about it, it's functionality conforms to what they
said you can do: use SQL statements within a PHP page to load the data
*grin*.

Cheers,
Rob.

On Thu, 2003-08-21 at 14:53, Curt Zirzow wrote:
> * Thus wrote Phil King ([EMAIL PROTECTED]):
> > Hi Robbert,
> > 
> > I beleive my ISP does not allow any GUI interface into mysql databases on
> > the server.
> > They have advised me that ALL functions, table creation, modification,
> > loading data etc has to be done from PHP.
> > 
> > It appears I have to use SQL statements within a PHP page to load the data.
> 
> Just go to phpMyAdmin.com, download the source code and install it on
> the server. The hosting company doesn't need to know anything about
> it. 
> 
> 
> Curt
> -- 
> "I used to think I was indecisive, but now I'm not so sure."
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
-- 
.-.
| Worlds of Carnage - http://www.wocmud.org   |
:-:
| Come visit a world of myth and legend where |
| fantastical creatures come to life and the  |
| stuff of nightmares grasp for your soul.|
`-'

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



Re: [PHP] Newbie Question

2003-08-21 Thread Curt Zirzow
* Thus wrote Phil King ([EMAIL PROTECTED]):
> Hi Robbert,
> 
> I beleive my ISP does not allow any GUI interface into mysql databases on
> the server.
> They have advised me that ALL functions, table creation, modification,
> loading data etc has to be done from PHP.
> 
> It appears I have to use SQL statements within a PHP page to load the data.

Just go to phpMyAdmin.com, download the source code and install it on
the server. The hosting company doesn't need to know anything about
it. 


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

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



Re: [PHP] Newbie Question

2003-08-21 Thread Phil King
Hi Robbert,

I beleive my ISP does not allow any GUI interface into mysql databases on
the server.
They have advised me that ALL functions, table creation, modification,
loading data etc has to be done from PHP.

It appears I have to use SQL statements within a PHP page to load the data.

Phil.

"Van Andel" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Sorry, I did mean phpMyAdmin (no such thing as phpMySQL).  Brain fart.
> Won't happen again.
>
> Robbert van Andel
>
>
>
> -Original Message-
> From: Dan Van Derveer [mailto:[EMAIL PROTECTED]
> Sent: Thursday, August 21, 2003 9:25 AM
> To: '[EMAIL PROTECTED]'
> Subject: RE: [PHP] Newbie Question
>
>
> On the same note I recommend phpMyAdmin(www.phpmyadmin.net). Its interface
> is quite useful especially when you have multiple DB's to manage on the
same
> server.
>
> Dan
>
> -Original Message-
> From: Van Andel, Robbert [mailto:[EMAIL PROTECTED]
> Sent: Thursday, August 21, 2003 12:24 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [PHP] Newbie Question
>
> You can download PHPMySQL and locate it in a secure portion of your site.
> It's an excellent gui interface into mySQL.  This tool will allow you to
> upload the script file and insert the data.  I'm sorry, but I don't know
the
> URL where to get it.  Check sourceforge.
>
> Robbert van Andel
>
>
> -Original Message-
> From: Phil King [mailto:[EMAIL PROTECTED]
> Sent: Thursday, August 21, 2003 7:40 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Newbie Question
>
>
> Hi,
>
> I 'm in the process of modify one of my sites to use PHP/mysql instead of
> ASP/Ms Access.
>
> The Access database has 200 records in it.
>
> I have PWS, mysql and PHP running on my local PC.
>
> I have used Navicat from mysqlstudio.com to import the access database
into
> mysql and then exported the data back out as an sql script.
> The script consists of multiple sql statements like :
>
> INSERT INTO mydatabase
>   (id, Description, Department, RetailPrice, PrefSupPartNo, PrefSupplier)
> VALUES
>   (1, "Bunting Plastic Union Jack 4m", "Flags & Bunting", "2.5", "JFB",
> "Smiths");
>
> Is there a way of "including" the sql script file into a PHP page or do I
> have to copy and paste the statements into a PHP page with a "mysql_query"
> statement after each sql statement, to load these records to my ISP's
remote
> server.
>
> p.s My ISP has no GUI interface into mysql so all manipulation is done via
> PHP.
>
> Thanks very much for any guidence.
>
> Phil.
>
>
>
>
> -- 
> 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 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] Newbie Question

2003-08-21 Thread Van Andel, Robbert
Sorry, I did mean phpMyAdmin (no such thing as phpMySQL).  Brain fart.
Won't happen again.

Robbert van Andel 



-Original Message-
From: Dan Van Derveer [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 21, 2003 9:25 AM
To: '[EMAIL PROTECTED]'
Subject: RE: [PHP] Newbie Question


On the same note I recommend phpMyAdmin(www.phpmyadmin.net). Its interface
is quite useful especially when you have multiple DB's to manage on the same
server.

Dan

-Original Message-
From: Van Andel, Robbert [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 21, 2003 12:24 PM
To: [EMAIL PROTECTED]
Subject: RE: [PHP] Newbie Question

You can download PHPMySQL and locate it in a secure portion of your site.
It's an excellent gui interface into mySQL.  This tool will allow you to
upload the script file and insert the data.  I'm sorry, but I don't know the
URL where to get it.  Check sourceforge.

Robbert van Andel 


-Original Message-
From: Phil King [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 21, 2003 7:40 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Newbie Question


Hi,

I 'm in the process of modify one of my sites to use PHP/mysql instead of
ASP/Ms Access.

The Access database has 200 records in it.

I have PWS, mysql and PHP running on my local PC.

I have used Navicat from mysqlstudio.com to import the access database into
mysql and then exported the data back out as an sql script.
The script consists of multiple sql statements like :

INSERT INTO mydatabase
  (id, Description, Department, RetailPrice, PrefSupPartNo, PrefSupplier)
VALUES
  (1, "Bunting Plastic Union Jack 4m", "Flags & Bunting", "2.5", "JFB",
"Smiths");

Is there a way of "including" the sql script file into a PHP page or do I
have to copy and paste the statements into a PHP page with a "mysql_query"
statement after each sql statement, to load these records to my ISP's remote
server.

p.s My ISP has no GUI interface into mysql so all manipulation is done via
PHP.

Thanks very much for any guidence.

Phil.




-- 
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 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] Newbie Question

2003-08-21 Thread Dan Van Derveer
On the same note I recommend phpMyAdmin(www.phpmyadmin.net). Its interface
is quite useful especially when you have multiple DB's to manage on the same
server.

Dan

-Original Message-
From: Van Andel, Robbert [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 21, 2003 12:24 PM
To: [EMAIL PROTECTED]
Subject: RE: [PHP] Newbie Question

You can download PHPMySQL and locate it in a secure portion of your site.
It's an excellent gui interface into mySQL.  This tool will allow you to
upload the script file and insert the data.  I'm sorry, but I don't know the
URL where to get it.  Check sourceforge.

Robbert van Andel 


-Original Message-
From: Phil King [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 21, 2003 7:40 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Newbie Question


Hi,

I 'm in the process of modify one of my sites to use PHP/mysql instead of
ASP/Ms Access.

The Access database has 200 records in it.

I have PWS, mysql and PHP running on my local PC.

I have used Navicat from mysqlstudio.com to import the access database into
mysql and then exported the data back out as an sql script.
The script consists of multiple sql statements like :

INSERT INTO mydatabase
  (id, Description, Department, RetailPrice, PrefSupPartNo, PrefSupplier)
VALUES
  (1, "Bunting Plastic Union Jack 4m", "Flags & Bunting", "2.5", "JFB",
"Smiths");

Is there a way of "including" the sql script file into a PHP page or do I
have to copy and paste the statements into a PHP page with a "mysql_query"
statement after each sql statement, to load these records to my ISP's remote
server.

p.s My ISP has no GUI interface into mysql so all manipulation is done via
PHP.

Thanks very much for any guidence.

Phil.




-- 
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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Newbie Question

2003-08-21 Thread Van Andel, Robbert
You can download PHPMySQL and locate it in a secure portion of your site.
It's an excellent gui interface into mySQL.  This tool will allow you to
upload the script file and insert the data.  I'm sorry, but I don't know the
URL where to get it.  Check sourceforge.

Robbert van Andel 


-Original Message-
From: Phil King [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 21, 2003 7:40 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Newbie Question


Hi,

I 'm in the process of modify one of my sites to use PHP/mysql instead of
ASP/Ms Access.

The Access database has 200 records in it.

I have PWS, mysql and PHP running on my local PC.

I have used Navicat from mysqlstudio.com to import the access database into
mysql and then exported the data back out as an sql script.
The script consists of multiple sql statements like :

INSERT INTO mydatabase
  (id, Description, Department, RetailPrice, PrefSupPartNo, PrefSupplier)
VALUES
  (1, "Bunting Plastic Union Jack 4m", "Flags & Bunting", "2.5", "JFB",
"Smiths");

Is there a way of "including" the sql script file into a PHP page or do I
have to copy and paste the statements into a PHP page with a "mysql_query"
statement after each sql statement, to load these records to my ISP's remote
server.

p.s My ISP has no GUI interface into mysql so all manipulation is done via
PHP.

Thanks very much for any guidence.

Phil.




-- 
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] Newbie Question regarding Syntax

2003-08-17 Thread Creative Solutions New Media
Thank you Curt.

Works great and your right I makes more sense to do it that way.

Tim Winters
Manager, Creative Development
Sampling Technologies Incorporated (STI)
[EMAIL PROTECTED]
[EMAIL PROTECTED]
W: 902 450 5500
C:  902 430 8498

-Original Message-
From: Curt Zirzow [mailto:[EMAIL PROTECTED]
Sent: August 17, 2003 8:45 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Newbie Question regarding Syntax

* Thus wrote Creative Solutions New Media ([EMAIL PROTECTED]):
> Sorry guys.It think there is a bit of confusion.
>
> I miss typed what I need to do.
>
>
>  HREF=mailto:'.$row_rep_RS['repEmail'].'>'.$row_rep_RS['repEmail'].'';
?>

You should make sure to quote your html values ( href="value" ), it
will lead to trouble if you don't.

I would still do it like this:

Email: 
  



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

--
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] Newbie Question regarding Syntax

2003-08-17 Thread Curt Zirzow
* Thus wrote Creative Solutions New Media ([EMAIL PROTECTED]):
> Sorry guys.It think there is a bit of confusion.
> 
> I miss typed what I need to do.
> 
> 
>  HREF=mailto:'.$row_rep_RS['repEmail'].'>'.$row_rep_RS['repEmail'].''; ?>

You should make sure to quote your html values ( href="value" ), it
will lead to trouble if you don't.

I would still do it like this:

Email: 
  



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

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



RE: [PHP] Newbie Question regarding Syntax

2003-08-17 Thread Creative Solutions New Media
Sorry guys.It think there is a bit of confusion.

I miss typed what I need to do.

$row_rep_RS['repEmail'] is actually the email address I want to turn into a
link.

So I guess it would look something like.

'.$row_rep_RS['repEmail'].''; ?>

Whewthink I made a mess of that

Is that any more clear?

Thanks for the very quick responses guys!

Tim Winters
Manager, Creative Development
Sampling Technologies Incorporated (STI)
[EMAIL PROTECTED]
[EMAIL PROTECTED]
W: 902 450 5500
C:  902 430 8498

-Original Message-
From: Curt Zirzow [mailto:[EMAIL PROTECTED]
Sent: August 17, 2003 8:28 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Newbie Question regarding Syntax

* Thus wrote Creative Solutions New Media ([EMAIL PROTECTED]):
>  HREF="mailto:[EMAIL PROTECTED]">'.$row_rep_RS['repEmail'].''; ?>
>
> Obviously this isn't working. What is the proper syntax when you have to
use
> double quotes inside the tag?

I usually prefer this method, its a style choice and others might
argue using it.:

Email: mailto:[EMAIL PROTECTED]">
  

A lot easier/cleaner than to trying to concat and escape
everything.


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

--
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] Newbie Question regarding Syntax

2003-08-17 Thread Curt Zirzow
* Thus wrote Creative Solutions New Media ([EMAIL PROTECTED]):
>  HREF="mailto:[EMAIL PROTECTED]">'.$row_rep_RS['repEmail'].''; ?>
> 
> Obviously this isn't working. What is the proper syntax when you have to use
> double quotes inside the tag?

I usually prefer this method, its a style choice and others might
argue using it.:

Email: mailto:[EMAIL PROTECTED]">
  

A lot easier/cleaner than to trying to concat and escape
everything.


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

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



RE: [PHP] Newbie Question regarding Syntax

2003-08-17 Thread Cesar Aracena
I would encourage you to use double quotes instead of single quotes
inside the PHP code. After this, you must comment HTML double quotes so
the PHP engine does not consider these as part of its code. I would type
your example like this:

mailto:[EMAIL PROTECTED]">".$row_rep_RS['repEmail']."";

?>

Note how the only concatenated string (using periods) is the variable
$row_rep_RS[] and the double quotes inside the HTML link were commented
using a backslash.

HTH,

Cesar Aracena
www.icaam.com.ar 

> -Mensaje original-
> De: Creative Solutions New Media [mailto:[EMAIL PROTECTED]
> Enviado el: Domingo, 17 de Agosto de 2003 08:08 p.m.
> Para: [EMAIL PROTECTED]
> Asunto: [PHP] Newbie Question regarding Syntax
> 
>  HREF="mailto:[EMAIL PROTECTED]">'.$row_rep_RS['repEmail'].''; ?>
> 
> Obviously this isn't working. What is the proper syntax when you have
to
> use
> double quotes inside the tag?
> 
> Thx
> 
> Tim Winters
> Manager, Creative Development
> Sampling Technologies Incorporated (STI)
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
> W: 902 450 5500
> C:  902 430 8498
> 
> 
> 
> 
> --
> 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] newbie question

2003-06-24 Thread Jay Blanchard
[snip]
I just setup php on my linux box and have been messing with a tutorial, 
and have had some issues.

The tutorial says any name=value pairs in the querystring "automatically

creates a variable with the name and value the querystring indicated". 
This does not seem to be happening.

I have installed:
RedHat 9.0
Mysql 4.0.13
PHP 4.3.2
[/snip]

It is because the tutorial is pre PHP 4.x where register_globals = off
in php.ini. Your form variables will be in either $_GET['variablename']
or $_POST['variablename'], or you can turn register_globals 'on'

HTH!

Jay



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



RE: [PHP] Newbie Question

2003-02-25 Thread Cal Evans
you have 2 functions named DBField.  This was ok until 4.3. After 4.3 you
couldn't re-declare a function like this.

PHP does not allow for overloading like Java and C++ (It looks like that's
what you are trying to do)

Check the docs for overloading.  There is some support for it but it's a bit
of a kludge. (IMHO, etc.)

=C=

* Cal Evans
* Stay Plugged Into Your Audience
* http://www.christianperformer.com

-Original Message-
From: Greg Luce [mailto:[EMAIL PROTECTED]
Sent: Tuesday, February 25, 2003 9:47 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Newbie Question


Can someone explain why this code works on the hosting company's server,
but won't run on my local server? I'm not sure what version is on the
host server, but I'm running 4.0.5 locally on winXP Pro. The error says:
Fatal error: Cannot redeclare dbfield() in
c:\inetpub\wwwroot\livinginnaples\database.php on line 30

7.class DBField
8.{
9.  var $name;
10. var $type;
11. var $table;
12. var $title;
13.
14. var $size;
15. var $rows;
16. var $maxlength;
17. var $value;
18. var $prefix;
19. var $postfix;
20. var $display;
21.
22. function DBField()
23. {
24. $name = "";
25. $table = "";
26.
27. $this->display = true;
28. }
29.
30. function DBField( $name, $table, $size, $value )
31. {
32. if( $size == "" ) $size=20;
33.
$this->display = true;
$this->name = $name;
$this->table = $table;
$this->size = $size;
$this->rows = 5;
$this->value = $value;
$this->title = ucwords( $name );
}

function display()
{
if( !$this->display ) return;

$prefix = str_replace( "[TITLE]", $this->title,
$this->prefix );
echo $prefix;

switch( $this->type )
{
case "blob": ?>
value ?>value != "" ) $time =
strtotime( $this->value );
else $time = strtotime( "now" ); ?>
">/">/">
postfix . "\r\n";
}
}



--
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] Newbie Question

2002-12-02 Thread Jon Haworth
Hi Hacook,

> I have a mySQL database called "srchresult"  in a "srchresult" base.
> In it, i have 9 fields. Everything works perfectly.
> I would like to know how can  i list in a HTML table 30 results for
example
> but only with 7 columns (7 fields only) ?

Try this:

;

// loop through the results
while ($r = mysql_fetch_array($q)) {

  // echo a table row
  ?>

  
  
  

  ";

?>

It's untested - shout if it doesn't work.

Cheers
Jon





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




Re: [PHP] newbie question, open file error

2002-10-30 Thread Marek Kilimajer
Give it a try, that's the way I do it.

jennifer villany wrote:


hi,
thanks for your feedback. chmod is greyed out in my ftp client.
im using smart ftp. can i make these changes at the command line?

thanks again,

jennifer

"Marek Kilimajer" <[EMAIL PROTECTED]> wrote in message
news:<[EMAIL PROTECTED]>...
 

You might be able to solve this yourself, connect using ftp and try
"chmod o+w directory",
where directory is the directory that you want to write to.

[EMAIL PROTECTED] wrote:

   

hi,

i hope im sending this to the correct place.

im getting this error (below) when i run a script on my server. Im
 

assuming I need to communicate with my admin about permissions, but im not
100% sure what the permission is. I'm basically trying to create an html
file.
 

if anyone can give me some advice as to where the error lies, i would
 

greatly appreciate it.
 

thanks,

jennifer

Warning: fopen("1037202617.html","w+") - Permission denied in
 

/home/villany2k1/www.villany2k1.com/htdocs/ecards/index.php3 on line 157
 


· · ·

jv :  www.whitenoisemachine.net  : 201-776-8511 : visual energy
 

specialist
 



-
Do you Yahoo!?
HotJobs - Search new jobs daily now


 


 



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




Re: [PHP] newbie question, open file error

2002-10-30 Thread Marek Kilimajer
You might be able to solve this yourself, connect using ftp and try 
"chmod o+w directory",
where directory is the directory that you want to write to.

[EMAIL PROTECTED] wrote:

hi, 

i hope im sending this to the correct place. 

im getting this error (below) when i run a script on my server. Im assuming I need to communicate with my admin about permissions, but im not 100% sure what the permission is. I'm basically trying to create an html file.

if anyone can give me some advice as to where the error lies, i would greatly appreciate it.

thanks, 

jennifer

Warning: fopen("1037202617.html","w+") - Permission denied in /home/villany2k1/www.villany2k1.com/htdocs/ecards/index.php3 on line 157



· · ·

jv :  www.whitenoisemachine.net  : 201-776-8511 : visual energy specialist




-
Do you Yahoo!?
HotJobs - Search new jobs daily now
 



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




Re: [PHP] newbie question

2002-10-03 Thread Scott Houseman

This is very simple

To access variables from GET form, which you would use request.querystring( ) for in 
ASP,
use the $_GET array in PHP, e.g. $var = $_GET{'var'}
To access POST form values, which you would use request.form( ) for in ASP, use the 
$_POST
array in PHP e.g. $var = $_POST{'var'}.

Cheers!

Scott

On 10/2/2002 1:24 PM, Remon Redika wrote:
> I am newbie in php
> I have var $query_string in my address page.
> I want get value of query string.
> For example I give string on my query string like 
> www.mypages.com?var=numberx
> I just want get a value of var or "numberx"
> I usually do this var on asp
> request.querystring("var") , so I'll get the value = "numberx"
> how i do it on php...?
> sorry about my English.


-- 
////
// Scott Houseman //
// Jam Warehouse http://www.jamwarehouse.com/ //
// Smart Business Innovation  //
// +27 21 4477440 / +27 82 4918021//
////


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




RE: [PHP] newbie question

2002-10-03 Thread M.A.Bond

It depends on the version of PHP, in older versions you just use the
variable name ie in your example just use $var to access it's contents. In
new versions, with register globals turned off use $_GET['var'] to access it
ie:

Print $_GET['var']

Will print numberx

Thanks

Mark


-Original Message-
From: Remon Redika [mailto:[EMAIL PROTECTED]] 
Sent: 02 October 2002 12:24
To: [EMAIL PROTECTED]
Subject: [PHP] newbie question


I am newbie in php
I have var $query_string in my address page.
I want get value of query string.
For example I give string on my query string like 
www.mypages.com?var=numberx
I just want get a value of var or "numberx"
I usually do this var on asp
request.querystring("var") , so I'll get the value = "numberx" how i do it
on php...? sorry about my English. 

-- 
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] newbie question

2002-08-30 Thread Daniel Masson

Just do this:

Header("Location: $where_you_wanna_go\n\n");

And make sure you do this before produce any HTML autput !! Hope this is
helpful !!

How do I get PHP to automatically open another PHP page in a browser if
a condition is met?

 I have a pull down HTML table that submits a form to a PHP script.
That script then uses a little logic to figure out which web page to go
to.  I have 5 different pages, and each has different content.  Right
now, I can make it bring up links, but I can't figure a way out to make
it automatically go to the proper web page.

I know this has to be easy, but I can't find any info one it.

Thanks for your help,

Brian



-- 
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] newbie question

2002-08-30 Thread Kevin Stone

include($thefile.".html");
http://www.php.net/manual/en/function.include.php

header("Location: ".$thefile);
http://www.php.net/manual/en/function.header.php

-Kevin

- Original Message - 
From: "Brian & Shannon Windsor" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, August 30, 2002 1:25 PM
Subject: [PHP] newbie question


> How do I get PHP to automatically open another PHP page in a browser if a
> condition is met?
> 
>  I have a pull down HTML table that submits a form to a PHP script.  That
> script then uses a little logic to figure out which web page to go to.  I
> have 5 different pages, and each has different content.  Right now, I can
> make it bring up links, but I can't figure a way out to make it
> automatically go to the proper web page.
> 
> I know this has to be easy, but I can't find any info one it.
> 
> Thanks for your help,
> 
> Brian
> 
> 
> 
> -- 
> 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] newbie question

2002-08-30 Thread Jason Wong

On Saturday 31 August 2002 03:25, Brian & Shannon Windsor wrote:

Please do not be lazy and choose a proper descriptive text for your subject. 

Imagine the blandness and confusion and the utter uselessness if everybody 
used generic subjects such as "Help", "Quick question", "This one is easy", 
"What am I doing wrong?".

Not to mention the fact that I usually (and I bet many others do as well) 
delete such messages straight away.

> How do I get PHP to automatically open another PHP page in a browser if a
> condition is met?
>
>  I have a pull down HTML table that submits a form to a PHP script.  That
> script then uses a little logic to figure out which web page to go to.  I
> have 5 different pages, and each has different content.  Right now, I can
> make it bring up links, but I can't figure a way out to make it
> automatically go to the proper web page.
>
> I know this has to be easy, but I can't find any info one it.

Without a better explanation of what you mean by "go to the proper web page" 
the best answer that can be given is:

   header("Location: http://www.doo.com/dah.php";)

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
That secret you've been guarding, isn't.
*/


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




Re: [PHP] Newbie question about UNIX command-line directives

2002-08-12 Thread Rasmus Lerdorf

As mentioned a couple of times on that include page, you can just use
ini_set() directly in your application to set include_path.

eg.




That will run through each directory listed in your include path.  That
is, it will check for:

 ./foo.inc
 ../foo.inc
 ../../foo.inc
 /usr/local/lib/php/foo.inc

in that order.

-Rasmus

On Mon, 12 Aug 2002, Al wrote:

> I wasn't clear before.  The problem I'm having, and most of the others
> folks who commented, with include is really with "include_path".
>
> A good bit of the problem seems to be my virtual host's environment.
> Most things I've tried with directives in an htaccess don't work and the
>   error log says "not allowed" etc.
>
> I appreciate your help.
>
> Rasmus Lerdorf wrote:
> > What does include have to do with DirectoryIndex?  And what exactly is
> > your problem with include?  The only trick is setting the include_path
> > which doesn't seem all that obtuse to me.
> >
> > -Rasmus
> >
> > On Sun, 11 Aug 2002, Al wrote:
> >
> >
> >>The problem may be due to the fact that my environment is Apache Unix.
> >>
> >>I spent about two hours today pouring over the php on-line manual
> >>"include" spec and trying dozens of combinations.
> >>http://www.php.net/manual/en/function.include.php
> >>
> >>There must be at least 20 user contributed notes at the bottom.
> >>
> >>It is incredible that such a basic php function should be so obtuse and
> >>ill defined.
> >>
> >>I'm going to give your other suggestion a try tomorrow.
> >>
> >>Thanks again
> >>
> >>Analysis & Solutions wrote:
> >>
> >>>On Sun, Aug 11, 2002 at 12:33:55PM -0400, Al wrote:
> >>>
> >>>
> The .htaccess approach appears to fit my situation best; but, I've not
> been able to get it to work.
> >>>
> >>>
> >>>I wondered about the DirectoryIndex directive's ability to utilize files
> >>>in other directories, so did a little test, which is what you indicated
> >>>you tried in your initial email:
> >>>
> >>>   DirectoryIndex ../index.htm
> >>>
> >>>Worked fine.  Apache 1.3.26.  Windows NT.
> >>>
> >>>So, your problem could be a web server configuration thing, as Rasmus
> >>>hinted at.
> >>>
> >>>Beyond the things already discussed, I'm at a loss.
> >>>
> >>>Good luck,
> >>>
> >>>--Dan
> >>>
> >>
> >>
> >>--
> >>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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Newbie question about UNIX command-line directives

2002-08-12 Thread Al

I wasn't clear before.  The problem I'm having, and most of the others 
folks who commented, with include is really with "include_path".

A good bit of the problem seems to be my virtual host's environment. 
Most things I've tried with directives in an htaccess don't work and the 
  error log says "not allowed" etc.

I appreciate your help.

Rasmus Lerdorf wrote:
> What does include have to do with DirectoryIndex?  And what exactly is
> your problem with include?  The only trick is setting the include_path
> which doesn't seem all that obtuse to me.
> 
> -Rasmus
> 
> On Sun, 11 Aug 2002, Al wrote:
> 
> 
>>The problem may be due to the fact that my environment is Apache Unix.
>>
>>I spent about two hours today pouring over the php on-line manual
>>"include" spec and trying dozens of combinations.
>>http://www.php.net/manual/en/function.include.php
>>
>>There must be at least 20 user contributed notes at the bottom.
>>
>>It is incredible that such a basic php function should be so obtuse and
>>ill defined.
>>
>>I'm going to give your other suggestion a try tomorrow.
>>
>>Thanks again
>>
>>Analysis & Solutions wrote:
>>
>>>On Sun, Aug 11, 2002 at 12:33:55PM -0400, Al wrote:
>>>
>>>
The .htaccess approach appears to fit my situation best; but, I've not
been able to get it to work.
>>>
>>>
>>>I wondered about the DirectoryIndex directive's ability to utilize files
>>>in other directories, so did a little test, which is what you indicated
>>>you tried in your initial email:
>>>
>>>   DirectoryIndex ../index.htm
>>>
>>>Worked fine.  Apache 1.3.26.  Windows NT.
>>>
>>>So, your problem could be a web server configuration thing, as Rasmus
>>>hinted at.
>>>
>>>Beyond the things already discussed, I'm at a loss.
>>>
>>>Good luck,
>>>
>>>--Dan
>>>
>>
>>
>>--
>>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] Newbie question about UNIX command-line directives

2002-08-11 Thread Rasmus Lerdorf

What does include have to do with DirectoryIndex?  And what exactly is
your problem with include?  The only trick is setting the include_path
which doesn't seem all that obtuse to me.

-Rasmus

On Sun, 11 Aug 2002, Al wrote:

> The problem may be due to the fact that my environment is Apache Unix.
>
> I spent about two hours today pouring over the php on-line manual
> "include" spec and trying dozens of combinations.
> http://www.php.net/manual/en/function.include.php
>
> There must be at least 20 user contributed notes at the bottom.
>
> It is incredible that such a basic php function should be so obtuse and
> ill defined.
>
> I'm going to give your other suggestion a try tomorrow.
>
> Thanks again
>
> Analysis & Solutions wrote:
> > On Sun, Aug 11, 2002 at 12:33:55PM -0400, Al wrote:
> >
> >>The .htaccess approach appears to fit my situation best; but, I've not
> >>been able to get it to work.
> >
> >
> > I wondered about the DirectoryIndex directive's ability to utilize files
> > in other directories, so did a little test, which is what you indicated
> > you tried in your initial email:
> >
> >DirectoryIndex ../index.htm
> >
> > Worked fine.  Apache 1.3.26.  Windows NT.
> >
> > So, your problem could be a web server configuration thing, as Rasmus
> > hinted at.
> >
> > Beyond the things already discussed, I'm at a loss.
> >
> > Good luck,
> >
> > --Dan
> >
>
>
> --
> 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] Newbie question about UNIX command-line directives

2002-08-11 Thread Al

The problem may be due to the fact that my environment is Apache Unix.

I spent about two hours today pouring over the php on-line manual 
"include" spec and trying dozens of combinations. 
http://www.php.net/manual/en/function.include.php

There must be at least 20 user contributed notes at the bottom.

It is incredible that such a basic php function should be so obtuse and 
ill defined.

I'm going to give your other suggestion a try tomorrow.

Thanks again

Analysis & Solutions wrote:
> On Sun, Aug 11, 2002 at 12:33:55PM -0400, Al wrote:
> 
>>The .htaccess approach appears to fit my situation best; but, I've not 
>>been able to get it to work.
> 
> 
> I wondered about the DirectoryIndex directive's ability to utilize files 
> in other directories, so did a little test, which is what you indicated 
> you tried in your initial email:
> 
>DirectoryIndex ../index.htm
> 
> Worked fine.  Apache 1.3.26.  Windows NT.
> 
> So, your problem could be a web server configuration thing, as Rasmus 
> hinted at.
> 
> Beyond the things already discussed, I'm at a loss.
> 
> Good luck,
> 
> --Dan
> 


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




Re: [PHP] Newbie question about UNIX command-line directives

2002-08-11 Thread Analysis & Solutions

On Sun, Aug 11, 2002 at 12:33:55PM -0400, Al wrote:
> 
> The .htaccess approach appears to fit my situation best; but, I've not 
> been able to get it to work.

I wondered about the DirectoryIndex directive's ability to utilize files 
in other directories, so did a little test, which is what you indicated 
you tried in your initial email:

   DirectoryIndex ../index.htm

Worked fine.  Apache 1.3.26.  Windows NT.

So, your problem could be a web server configuration thing, as Rasmus 
hinted at.

Beyond the things already discussed, I'm at a loss.

Good luck,

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

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




Re: [PHP] Newbie question about UNIX command-line directives

2002-08-11 Thread Rasmus Lerdorf

Does your AllowOverride include "Indexes"?  If it doesn't, you can't put
DirectoryIndex in a .htaccess.

httpd -L is your friend.

-Rasmus

On Sun, 11 Aug 2002, Al wrote:

> Appreciate the feedback, but.
>
> The .htaccess approach appears to fit my situation best; but, I've not
> been able to get it to work.
>
> I have a folder with a php script and that folder has several
> sub-folders each with a small configuration script.  I'd like the entry
> point to be a subfolder and main script [in the parent folder] to be
> "symbolically" executed.
>
> I'm familiar with the DirectorIndex and use it often, but only for
> defining the default file for the particular folder.
>
> Could I be doing something wrong? Or is there another htaccess directive
>   that may work?
>
> Thanks.
>
> Analysis & Solutions wrote:
> > On Sat, Aug 10, 2002 at 01:12:38PM -0400, Al wrote:
> >
> >>I'm on a virtual host without a shell account and need execute a UNIX
> >>command.
> >>
> >>ln -s ../afile.php index.php
> >
> >
> > In a PHP script, you can do this -- if permissions are favorable:
> >
> >exec('ln -s ../afile.php index.php');
> >
> >
> >
> >>Is there some way to do this [e.g., with a htaccess file]?
> >
> >
> > In an .htaccess file, you can put this
> >
> > DirectoryIndex afile.php
> >
> >
> >
> >>What happens when you execute UNIX commands like the one above?  Does it
> >>make a file, change the config?
> >
> >
> > It makes a link in the file system.  -s makes the link symbolic.
> > http://www.tac.eu.org/cgi-bin/man-cgi?ln++NetBSD-current
> >
> > --Dan
> >
>
>
> --
> 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] Newbie question about UNIX command-line directives

2002-08-11 Thread Al

Appreciate the feedback, but.

The .htaccess approach appears to fit my situation best; but, I've not 
been able to get it to work.

I have a folder with a php script and that folder has several 
sub-folders each with a small configuration script.  I'd like the entry 
point to be a subfolder and main script [in the parent folder] to be 
"symbolically" executed.

I'm familiar with the DirectorIndex and use it often, but only for 
defining the default file for the particular folder.

Could I be doing something wrong? Or is there another htaccess directive 
  that may work?

Thanks.

Analysis & Solutions wrote:
> On Sat, Aug 10, 2002 at 01:12:38PM -0400, Al wrote:
> 
>>I'm on a virtual host without a shell account and need execute a UNIX 
>>command.
>>
>>ln -s ../afile.php index.php
> 
> 
> In a PHP script, you can do this -- if permissions are favorable:
> 
>exec('ln -s ../afile.php index.php');
> 
> 
> 
>>Is there some way to do this [e.g., with a htaccess file]?
> 
> 
> In an .htaccess file, you can put this
> 
> DirectoryIndex afile.php
> 
> 
> 
>>What happens when you execute UNIX commands like the one above?  Does it 
>>make a file, change the config?
> 
> 
> It makes a link in the file system.  -s makes the link symbolic.
> http://www.tac.eu.org/cgi-bin/man-cgi?ln++NetBSD-current
> 
> --Dan
> 


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




Re: [PHP] Newbie question about UNIX command-line directives

2002-08-10 Thread Analysis & Solutions

On Sat, Aug 10, 2002 at 01:12:38PM -0400, Al wrote:
> I'm on a virtual host without a shell account and need execute a UNIX 
> command.
> 
> ln -s ../afile.php index.php

In a PHP script, you can do this -- if permissions are favorable:

   exec('ln -s ../afile.php index.php');


> Is there some way to do this [e.g., with a htaccess file]?

In an .htaccess file, you can put this

DirectoryIndex afile.php


> What happens when you execute UNIX commands like the one above?  Does it 
> make a file, change the config?

It makes a link in the file system.  -s makes the link symbolic.
http://www.tac.eu.org/cgi-bin/man-cgi?ln++NetBSD-current

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

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




Re: [PHP] Newbie question about SQL result formatting

2002-08-09 Thread Analysis & Solutions

On Fri, Aug 09, 2002 at 10:55:52PM +0200, Kristoffer Strom wrote:
> 
> How do I convert the result to HTML code, I especially want the linebreaks!!

Two options.  Put the output in between  tags.  Or if you want the 
regular font, in PHP use the nl2br() function.

--Dan

PS:  For future reference...  The mailing list archive is at

http://groups.google.com/groups?hl=en&safe=off&group=php.general

Putting in the search terms "line break" produces a plethora of results 
with this same answer.

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

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




RE: [PHP] Newbie Question on Efficiency : Follow-up Question

2002-07-16 Thread Michael Kennedy

Exactly- I could see uses in PHP, but they're so limited that it's
obvious to see why it works the way it does.

Michael Kennedy

-Original Message-
From: Martin Towell [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, July 16, 2002 10:46 PM
To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED]
Subject: RE: [PHP] Newbie Question on Efficiency : Follow-up Question

The only reason a compiled language would not include a
function/module/etc
is to reduce the size of the final executable.

Since php doesn't store (barring the caching engines, but they work
differently anyway) a compiled version, it doesn't need to worry about
not
including something.

Martin

-Original Message-
From: Michael Kennedy [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 17, 2002 1:36 PM
To: [EMAIL PROTECTED]
Subject: RE: [PHP] Newbie Question on Efficiency : Follow-up Question


Yeah, that's what I figured.  With C++ you could find evidence that it
only grabbed the used portions, but in PHP I didn't see anything to
support that.  Of course, like I said, the answer likely wouldn't have
made a difference in anything I did, but it's nice to delve a little
deeper sometimes.  Thanks.

Michael

-Original Message-
From: John Holmes [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, July 16, 2002 8:05 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: [PHP] Newbie Question on Efficiency : Follow-up Question

PHP loads everything up before it starts doing anything. It's only going
to execute the code it needs to, though, of course. I asked this
question a while ago and got that answer. The process of loading all of
the code is minimal, though, compared the actually executing the code. 

---John Holmes...

> -Original Message-
> From: Michael Kennedy [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 16, 2002 7:26 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [PHP] Newbie Question on Efficiency : Follow-up Question
> 
> OK, if I understand C++ correctly, if I write a program and #include
>  or something similar and compile the program it only
> compiles with the used functions in it, right?  So, if I never use
'cin'
> it leaves that function out of the final complied app.
> 
> Does/can PHP do anything similar?  I'm always much more comfortable
with
> a language when I can understand how it works and I'm sure some of you
> feel the same.
> 
> Now, I fully understand that PHP documents are not even close to being
> compiled in the traditional sense.  But, I'm wondering if it pulls all
> the necessary functions into memory when the page is accessed, then
uses
> them when needed, or does it pull the whole include()d file into
memory
> and just combine the whole mess together into one big memory heap and
> run like that?
> 
> My gut tells me that it's the second one, but I'm just wanting to be
> sure.  Of course, the answer likely won't make a single difference in
my
> life, but I'm just curious...  Also, I hope the above question isn't
> stupid.  I do have a habit of thinking about something for a while and
> then having it suddenly hit me later that the answer is simple very
> trivial.  Ah, well...
> 
> Thanks for humoring me.
> Michael
> 
> -Original Message-
> From: Monty [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 16, 2002 5:44 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] Newbie Question on Efficiency
> 
> If you have have a large number of functions, it might be better to
> separate
> them into a few files that you can include as needed. I use one file
> that
> contains functions needed by every page. I have a few other files that
> contain functions that aren't needed by every page, so, I include them
> only
> on pages that need them. But most functions go in the main include
file
> used
> on every page.
> 
> Separating them will also minimize some overhead if you have a lot of
> functions. Otherwise, if your include files aren't War & Peace in
> length,
> one include file is fine.
> 
> 
> >>>> [EMAIL PROTECTED] 07/16/02 04:59PM >>>
> > Hello everyone, I'm a newbie and have a question on style that I've
> not
> > seen addressed anywhere.  I have a large number of frequently used
> > functions that I'm trying to find a good way to organize.  The
method
> > I'm thinking of using is to simply create a .php file called, for
> > example, functions.php.  Then, just include the file at the top of
> each
> > page that needs any of the functions, and just call them as needed.
> My
> > question is this- if that file gets very large with tons of
different
> > functions, is that an inefficient method?  I'm not entirely clear on
> how
> &g

RE: [PHP] Newbie Question on Efficiency : Follow-up Question

2002-07-16 Thread Martin Towell

The only reason a compiled language would not include a function/module/etc
is to reduce the size of the final executable.

Since php doesn't store (barring the caching engines, but they work
differently anyway) a compiled version, it doesn't need to worry about not
including something.

Martin

-Original Message-
From: Michael Kennedy [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 17, 2002 1:36 PM
To: [EMAIL PROTECTED]
Subject: RE: [PHP] Newbie Question on Efficiency : Follow-up Question


Yeah, that's what I figured.  With C++ you could find evidence that it
only grabbed the used portions, but in PHP I didn't see anything to
support that.  Of course, like I said, the answer likely wouldn't have
made a difference in anything I did, but it's nice to delve a little
deeper sometimes.  Thanks.

Michael

-Original Message-
From: John Holmes [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, July 16, 2002 8:05 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: [PHP] Newbie Question on Efficiency : Follow-up Question

PHP loads everything up before it starts doing anything. It's only going
to execute the code it needs to, though, of course. I asked this
question a while ago and got that answer. The process of loading all of
the code is minimal, though, compared the actually executing the code. 

---John Holmes...

> -Original Message-
> From: Michael Kennedy [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 16, 2002 7:26 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [PHP] Newbie Question on Efficiency : Follow-up Question
> 
> OK, if I understand C++ correctly, if I write a program and #include
>  or something similar and compile the program it only
> compiles with the used functions in it, right?  So, if I never use
'cin'
> it leaves that function out of the final complied app.
> 
> Does/can PHP do anything similar?  I'm always much more comfortable
with
> a language when I can understand how it works and I'm sure some of you
> feel the same.
> 
> Now, I fully understand that PHP documents are not even close to being
> compiled in the traditional sense.  But, I'm wondering if it pulls all
> the necessary functions into memory when the page is accessed, then
uses
> them when needed, or does it pull the whole include()d file into
memory
> and just combine the whole mess together into one big memory heap and
> run like that?
> 
> My gut tells me that it's the second one, but I'm just wanting to be
> sure.  Of course, the answer likely won't make a single difference in
my
> life, but I'm just curious...  Also, I hope the above question isn't
> stupid.  I do have a habit of thinking about something for a while and
> then having it suddenly hit me later that the answer is simple very
> trivial.  Ah, well...
> 
> Thanks for humoring me.
> Michael
> 
> -Original Message-
> From: Monty [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 16, 2002 5:44 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] Newbie Question on Efficiency
> 
> If you have have a large number of functions, it might be better to
> separate
> them into a few files that you can include as needed. I use one file
> that
> contains functions needed by every page. I have a few other files that
> contain functions that aren't needed by every page, so, I include them
> only
> on pages that need them. But most functions go in the main include
file
> used
> on every page.
> 
> Separating them will also minimize some overhead if you have a lot of
> functions. Otherwise, if your include files aren't War & Peace in
> length,
> one include file is fine.
> 
> 
> >>>> [EMAIL PROTECTED] 07/16/02 04:59PM >>>
> > Hello everyone, I'm a newbie and have a question on style that I've
> not
> > seen addressed anywhere.  I have a large number of frequently used
> > functions that I'm trying to find a good way to organize.  The
method
> > I'm thinking of using is to simply create a .php file called, for
> > example, functions.php.  Then, just include the file at the top of
> each
> > page that needs any of the functions, and just call them as needed.
> My
> > question is this- if that file gets very large with tons of
different
> > functions, is that an inefficient method?  I'm not entirely clear on
> how
> > PHP is parsed and passed to the client.  I assume it would be best
to
> > divide up the functions into multiple files (ex. dbfunctions.php,
> etc.),
> > but is that still the best method?  Basically, I'm just curious on
how
> > you guys handle things like this.
> >
> > Thanks in advance.
> > Michael Kennedy
> >
> 
&g

RE: [PHP] Newbie Question on Efficiency : Follow-up Question

2002-07-16 Thread Michael Kennedy

Yeah, that's what I figured.  With C++ you could find evidence that it
only grabbed the used portions, but in PHP I didn't see anything to
support that.  Of course, like I said, the answer likely wouldn't have
made a difference in anything I did, but it's nice to delve a little
deeper sometimes.  Thanks.

Michael

-Original Message-
From: John Holmes [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, July 16, 2002 8:05 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: [PHP] Newbie Question on Efficiency : Follow-up Question

PHP loads everything up before it starts doing anything. It's only going
to execute the code it needs to, though, of course. I asked this
question a while ago and got that answer. The process of loading all of
the code is minimal, though, compared the actually executing the code. 

---John Holmes...

> -Original Message-
> From: Michael Kennedy [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 16, 2002 7:26 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [PHP] Newbie Question on Efficiency : Follow-up Question
> 
> OK, if I understand C++ correctly, if I write a program and #include
>  or something similar and compile the program it only
> compiles with the used functions in it, right?  So, if I never use
'cin'
> it leaves that function out of the final complied app.
> 
> Does/can PHP do anything similar?  I'm always much more comfortable
with
> a language when I can understand how it works and I'm sure some of you
> feel the same.
> 
> Now, I fully understand that PHP documents are not even close to being
> compiled in the traditional sense.  But, I'm wondering if it pulls all
> the necessary functions into memory when the page is accessed, then
uses
> them when needed, or does it pull the whole include()d file into
memory
> and just combine the whole mess together into one big memory heap and
> run like that?
> 
> My gut tells me that it's the second one, but I'm just wanting to be
> sure.  Of course, the answer likely won't make a single difference in
my
> life, but I'm just curious...  Also, I hope the above question isn't
> stupid.  I do have a habit of thinking about something for a while and
> then having it suddenly hit me later that the answer is simple very
> trivial.  Ah, well...
> 
> Thanks for humoring me.
> Michael
> 
> -Original Message-
> From: Monty [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 16, 2002 5:44 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] Newbie Question on Efficiency
> 
> If you have have a large number of functions, it might be better to
> separate
> them into a few files that you can include as needed. I use one file
> that
> contains functions needed by every page. I have a few other files that
> contain functions that aren't needed by every page, so, I include them
> only
> on pages that need them. But most functions go in the main include
file
> used
> on every page.
> 
> Separating them will also minimize some overhead if you have a lot of
> functions. Otherwise, if your include files aren't War & Peace in
> length,
> one include file is fine.
> 
> 
> >>>> [EMAIL PROTECTED] 07/16/02 04:59PM >>>
> > Hello everyone, I'm a newbie and have a question on style that I've
> not
> > seen addressed anywhere.  I have a large number of frequently used
> > functions that I'm trying to find a good way to organize.  The
method
> > I'm thinking of using is to simply create a .php file called, for
> > example, functions.php.  Then, just include the file at the top of
> each
> > page that needs any of the functions, and just call them as needed.
> My
> > question is this- if that file gets very large with tons of
different
> > functions, is that an inefficient method?  I'm not entirely clear on
> how
> > PHP is parsed and passed to the client.  I assume it would be best
to
> > divide up the functions into multiple files (ex. dbfunctions.php,
> etc.),
> > but is that still the best method?  Basically, I'm just curious on
how
> > you guys handle things like this.
> >
> > Thanks in advance.
> > Michael Kennedy
> >
> 
> 
> --
> 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 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] Newbie Question on Efficiency : Follow-up Question

2002-07-16 Thread Analysis & Solutions

On Tue, Jul 16, 2002 at 06:25:42PM -0500, Michael Kennedy wrote:
> OK, if I understand C++ correctly, if I write a program and #include
>  or something similar and compile the program it only
> compiles with the used functions in it, right?  So, if I never use 'cin'
> it leaves that function out of the final complied app.  
> 
> Does/can PHP do anything similar?

Nope.  Everything is brought into memory at compile time.  Or at least 
that's the way I understood it to be.  I suspect it's still the case.

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

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




RE: [PHP] Newbie Question on Efficiency : Follow-up Question

2002-07-16 Thread John Holmes

PHP loads everything up before it starts doing anything. It's only going
to execute the code it needs to, though, of course. I asked this
question a while ago and got that answer. The process of loading all of
the code is minimal, though, compared the actually executing the code. 

---John Holmes...

> -Original Message-
> From: Michael Kennedy [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 16, 2002 7:26 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [PHP] Newbie Question on Efficiency : Follow-up Question
> 
> OK, if I understand C++ correctly, if I write a program and #include
>  or something similar and compile the program it only
> compiles with the used functions in it, right?  So, if I never use
'cin'
> it leaves that function out of the final complied app.
> 
> Does/can PHP do anything similar?  I'm always much more comfortable
with
> a language when I can understand how it works and I'm sure some of you
> feel the same.
> 
> Now, I fully understand that PHP documents are not even close to being
> compiled in the traditional sense.  But, I'm wondering if it pulls all
> the necessary functions into memory when the page is accessed, then
uses
> them when needed, or does it pull the whole include()d file into
memory
> and just combine the whole mess together into one big memory heap and
> run like that?
> 
> My gut tells me that it's the second one, but I'm just wanting to be
> sure.  Of course, the answer likely won't make a single difference in
my
> life, but I'm just curious...  Also, I hope the above question isn't
> stupid.  I do have a habit of thinking about something for a while and
> then having it suddenly hit me later that the answer is simple very
> trivial.  Ah, well...
> 
> Thanks for humoring me.
> Michael
> 
> -Original Message-
> From: Monty [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 16, 2002 5:44 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] Newbie Question on Efficiency
> 
> If you have have a large number of functions, it might be better to
> separate
> them into a few files that you can include as needed. I use one file
> that
> contains functions needed by every page. I have a few other files that
> contain functions that aren't needed by every page, so, I include them
> only
> on pages that need them. But most functions go in the main include
file
> used
> on every page.
> 
> Separating them will also minimize some overhead if you have a lot of
> functions. Otherwise, if your include files aren't War & Peace in
> length,
> one include file is fine.
> 
> 
> >>>> [EMAIL PROTECTED] 07/16/02 04:59PM >>>
> > Hello everyone, I'm a newbie and have a question on style that I've
> not
> > seen addressed anywhere.  I have a large number of frequently used
> > functions that I'm trying to find a good way to organize.  The
method
> > I'm thinking of using is to simply create a .php file called, for
> > example, functions.php.  Then, just include the file at the top of
> each
> > page that needs any of the functions, and just call them as needed.
> My
> > question is this- if that file gets very large with tons of
different
> > functions, is that an inefficient method?  I'm not entirely clear on
> how
> > PHP is parsed and passed to the client.  I assume it would be best
to
> > divide up the functions into multiple files (ex. dbfunctions.php,
> etc.),
> > but is that still the best method?  Basically, I'm just curious on
how
> > you guys handle things like this.
> >
> > Thanks in advance.
> > Michael Kennedy
> >
> 
> 
> --
> 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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Newbie Question on Efficiency : Follow-up Question

2002-07-16 Thread Michael Kennedy

OK, if I understand C++ correctly, if I write a program and #include
 or something similar and compile the program it only
compiles with the used functions in it, right?  So, if I never use 'cin'
it leaves that function out of the final complied app.  

Does/can PHP do anything similar?  I'm always much more comfortable with
a language when I can understand how it works and I'm sure some of you
feel the same.

Now, I fully understand that PHP documents are not even close to being
compiled in the traditional sense.  But, I'm wondering if it pulls all
the necessary functions into memory when the page is accessed, then uses
them when needed, or does it pull the whole include()d file into memory
and just combine the whole mess together into one big memory heap and
run like that?

My gut tells me that it's the second one, but I'm just wanting to be
sure.  Of course, the answer likely won't make a single difference in my
life, but I'm just curious...  Also, I hope the above question isn't
stupid.  I do have a habit of thinking about something for a while and
then having it suddenly hit me later that the answer is simple very
trivial.  Ah, well...

Thanks for humoring me.
Michael

-Original Message-
From: Monty [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, July 16, 2002 5:44 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Newbie Question on Efficiency

If you have have a large number of functions, it might be better to
separate
them into a few files that you can include as needed. I use one file
that
contains functions needed by every page. I have a few other files that
contain functions that aren't needed by every page, so, I include them
only
on pages that need them. But most functions go in the main include file
used
on every page.

Separating them will also minimize some overhead if you have a lot of
functions. Otherwise, if your include files aren't War & Peace in
length,
one include file is fine.


>>>> [EMAIL PROTECTED] 07/16/02 04:59PM >>>
> Hello everyone, I'm a newbie and have a question on style that I've
not
> seen addressed anywhere.  I have a large number of frequently used
> functions that I'm trying to find a good way to organize.  The method
> I'm thinking of using is to simply create a .php file called, for
> example, functions.php.  Then, just include the file at the top of
each
> page that needs any of the functions, and just call them as needed.
My
> question is this- if that file gets very large with tons of different
> functions, is that an inefficient method?  I'm not entirely clear on
how
> PHP is parsed and passed to the client.  I assume it would be best to
> divide up the functions into multiple files (ex. dbfunctions.php,
etc.),
> but is that still the best method?  Basically, I'm just curious on how
> you guys handle things like this.
> 
> Thanks in advance.
> Michael Kennedy
> 


-- 
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] Newbie Question on Efficiency

2002-07-16 Thread Monty

If you have have a large number of functions, it might be better to separate
them into a few files that you can include as needed. I use one file that
contains functions needed by every page. I have a few other files that
contain functions that aren't needed by every page, so, I include them only
on pages that need them. But most functions go in the main include file used
on every page.

Separating them will also minimize some overhead if you have a lot of
functions. Otherwise, if your include files aren't War & Peace in length,
one include file is fine.


 [EMAIL PROTECTED] 07/16/02 04:59PM >>>
> Hello everyone, I'm a newbie and have a question on style that I've not
> seen addressed anywhere.  I have a large number of frequently used
> functions that I'm trying to find a good way to organize.  The method
> I'm thinking of using is to simply create a .php file called, for
> example, functions.php.  Then, just include the file at the top of each
> page that needs any of the functions, and just call them as needed.  My
> question is this- if that file gets very large with tons of different
> functions, is that an inefficient method?  I'm not entirely clear on how
> PHP is parsed and passed to the client.  I assume it would be best to
> divide up the functions into multiple files (ex. dbfunctions.php, etc.),
> but is that still the best method?  Basically, I'm just curious on how
> you guys handle things like this.
> 
> Thanks in advance.
> Michael Kennedy
> 


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




RE: [PHP] Newbie Question on Efficiency

2002-07-16 Thread Michael Kennedy

Yeah, that's what I was thinking.  Mostly I was curious if the procedure
I mentioned was a good one or if there was something better to be doing.
Thanks for the super quick reply.  :)

Michael

-Original Message-
From: Martin Clifford [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, July 16, 2002 4:01 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED];
[EMAIL PROTECTED]
Subject: Re: [PHP] Newbie Question on Efficiency

Unless the file is getting retartedly big (10-20K), then I wouldn't
separate them.  Though if you have enough functions, you could justify
making separate files for your database functions, output functions,
backend functions, etc.

Martin Clifford
Homepage: http://www.completesource.net
Developer's Forums: http://www.completesource.net/forums/


>>> [EMAIL PROTECTED] 07/16/02 04:59PM >>>
Hello everyone, I'm a newbie and have a question on style that I've not
seen addressed anywhere.  I have a large number of frequently used
functions that I'm trying to find a good way to organize.  The method
I'm thinking of using is to simply create a .php file called, for
example, functions.php.  Then, just include the file at the top of each
page that needs any of the functions, and just call them as needed.  My
question is this- if that file gets very large with tons of different
functions, is that an inefficient method?  I'm not entirely clear on how
PHP is parsed and passed to the client.  I assume it would be best to
divide up the functions into multiple files (ex. dbfunctions.php, etc.),
but is that still the best method?  Basically, I'm just curious on how
you guys handle things like this.
 
Thanks in advance.
Michael Kennedy


-- 
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] Newbie Question on Efficiency

2002-07-16 Thread Martin Clifford

Unless the file is getting retartedly big (10-20K), then I wouldn't separate them.  
Though if you have enough functions, you could justify making separate files for your 
database functions, output functions, backend functions, etc.

Martin Clifford
Homepage: http://www.completesource.net
Developer's Forums: http://www.completesource.net/forums/


>>> [EMAIL PROTECTED] 07/16/02 04:59PM >>>
Hello everyone, I'm a newbie and have a question on style that I've not
seen addressed anywhere.  I have a large number of frequently used
functions that I'm trying to find a good way to organize.  The method
I'm thinking of using is to simply create a .php file called, for
example, functions.php.  Then, just include the file at the top of each
page that needs any of the functions, and just call them as needed.  My
question is this- if that file gets very large with tons of different
functions, is that an inefficient method?  I'm not entirely clear on how
PHP is parsed and passed to the client.  I assume it would be best to
divide up the functions into multiple files (ex. dbfunctions.php, etc.),
but is that still the best method?  Basically, I'm just curious on how
you guys handle things like this.
 
Thanks in advance.
Michael Kennedy


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




Re: [PHP] Newbie question

2002-07-13 Thread Alberto Serra

ðÒÉ×ÅÔ!

Cal Evans wrote:
> ++ is an incrementor. 

He may also consider the position of the inc/decrementor.
Example (note that the first element of an array has index 0):

$a = Array(1,2,3,4,5);
$i = 1;

executing

echo $a[++$i]
will output
3 2

echo $a[$i++]
will output
2 2

In both cases $i gets incremented, but the value used to access the 
array might be before or after the increment takes place, according to 
the incrementor (or decrementor, if you use --) position. A subtle, but 
often very handy nuance.

ÐÏËÁ
áÌØÂÅÒÔÏ
ëÉÅ×


@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@

LoRd, CaN yOu HeAr Me, LiKe I'm HeArInG yOu?
lOrD i'M sHiNiNg...
YoU kNoW I AlMoSt LoSt My MiNd, BuT nOw I'm HoMe AnD fReE
tHe TeSt, YeS iT iS
ThE tEsT, yEs It Is
tHe TeSt, YeS iT iS
ThE tEsT, yEs It Is...


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




RE: [PHP] Newbie question

2002-07-13 Thread Cal Evans

++ is an incrementor. 

$i=1;
$i++;
echo $i;

=C=

p.s. -- is a decrementor.

*
* Cal Evans
* The Virtual CIO
* http://www.calevans.com
*
 

-Original Message-
From: Jay [mailto:[EMAIL PROTECTED]]
Sent: Saturday, July 13, 2002 8:32 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Newbie question


I have just started to teach myself php so I am reading through several
scripts to see how the language is "spoken". I came across the following
at  phpworld.com


$i = 1;
while ($i <= 10) {
print $i++

Its a little script that counts from 1 to 10,  but what does $i++ mean.
What does the ++ do? Why ++ and not just one +

Thanks

-Jay



-- 
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] newbie: question about question marks

2002-07-09 Thread Martin Clifford

In that case, the question marks are part of the PHP opening and closing tags.

There are several ways to open and close sections of PHP script, mainly being , , and <% %>.  What the below equals is , since http://www.completesource.net (Now Open!)

>>> "Alexander Ross" <[EMAIL PROTECTED]> 07/09/02 09:54AM >>>
How bout the question marks in the following line of php generated html:



what do they mean?


"Miguel Cruz" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> On Sun, 7 Jul 2002, Alexander Ross wrote:
> > Can someone explain to me what the ? does.  I have a vague idea of what
> > it means in a URL (please cearify that) but I haven't the slightest what
> > it means in php code.  Thanks for your help
>
> Read about the ternary operator at:
>
>   http://www.php.net/manual/en/language.operators.comparison.php 
>
> miguel
>



-- 
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] newbie: question about question marks

2002-07-09 Thread Alexander Ross

How bout the question marks in the following line of php generated html:



what do they mean?


"Miguel Cruz" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> On Sun, 7 Jul 2002, Alexander Ross wrote:
> > Can someone explain to me what the ? does.  I have a vague idea of what
> > it means in a URL (please cearify that) but I haven't the slightest what
> > it means in php code.  Thanks for your help
>
> Read about the ternary operator at:
>
>   http://www.php.net/manual/en/language.operators.comparison.php
>
> miguel
>



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




Re: [PHP] newbie: question about question marks

2002-07-07 Thread Miguel Cruz

On Sun, 7 Jul 2002, Alexander Ross wrote:
> Can someone explain to me what the ? does.  I have a vague idea of what
> it means in a URL (please cearify that) but I haven't the slightest what
> it means in php code.  Thanks for your help

Read about the ternary operator at:

  http://www.php.net/manual/en/language.operators.comparison.php

miguel


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




Re: [PHP] newbie question - retaining values

2002-06-13 Thread Miguel Cruz

On Thu, 13 Jun 2002, Leston Drake wrote:
> I've been creating forms that use hidden inputs to retain variables and 
> values from one instance of the form to the next (by calling itself in the 
> FORM ACTION).
> 
> Are there other ways to retain *global* variables and values between 
> instances of loading a page?

http://php.net/session

miguel


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




Re: [PHP] Newbie question about PHP and Oracle

2002-05-28 Thread DrouetL


I don't know how it works in my sql.

I've written some functions to help me construct these sort of things.


It might help you

PS : Sorry but the comments are in French.

Laurent Drouet

/*
** Cette fonction retourne toutes les lignes d'une
**
** requette dans un tableau multidimensionnel. Une
**
** variable globale $db_selectall2_nrows2 est
**
** definie pour pouvoir transmettre le nombre
**
** de ligne de la requette
**
**/
function db_selectall2($id_connect,$query)
 {
 global $db_selectall2_nrows2;
 $stmt = ociparse($id_connect,$query);
 ociexecute($stmt);
 $db_selectall2_nrows2 = ociFetchStatement($stmt,$results);
 return $results;
 }


/*
** Creation d'une liste d'options (SELECT) a partir d'un**
** tableau bidimensionnel. Les parametres a fournir a   **
** cette fonction sont le tableau et le nombre de lignes**
** de la requette. Le premier parametre du tableau
**
** contient la valeur de la liste deroulante. Les
**
** autres colonnes du tableau sont concatenees avec **
** la premiere et sont affichees. Cette fonction
**
** peut etre appelee apres db_selectall2
**
**/
function creat_select($resquery,$totlines, $action)
 {
 $nbre=sizeof($resquery);
 $colres=array_keys($resquery);
 print "\n";
 for ($row=0; $row<$totlines; $row++ )
{
print "";
for ($x=0; $x<$nbre; $x++)
{
if ($x<>0)
 {
 print ", ".$resquery[$colres[$x]]
[$row];
 }
else
 {
 print $resquery[$colres[$x]]
[$row];
 }
}
print "\n";
}
 print "";
 }

/*
** Creation d'une liste d'options (SELECT) a partir **
** d'un tableau bidimensionnel. Les parametres a fournir**
** a cette fonction sont le tableau et le nombre de **
** ligne de la requette. la valeur de la liste
**
** deroulante sera la concatenation de toutes
**
** les valeurs. Cette fonction peut etre appelee
**
** apres db_selectall2
**
**/
function creat_select1value($resquery,$totlines, $action)
 {
 $nbre=sizeof($resquery);
 $colres=array_keys($resquery);
 print "\n";
 print "<--SELECT-->\n";
 for ($row=0; $row<$totlines; $row++ )
{
print "0)
 {
 $texte.=", ".$resquery[$colres
[$x]][$row];

 }
else
 {
 $texte=$resquery[$colres[$x]]
[$row];
 }
}
print $texte."\">".$texte."\n";
}
 print "";
 }

/*
** Creation d'une liste d'options (SELECT) a partir **
** d'un tableau bidimensionnel. Les parametres a fournir**
** a cette fonction sont le tableau et le nombre de **
** ligne de la requette. la valeur de la liste
**
** deroulante sera la concatenation de toutes
**
** les valeurs. Cette fonction peut etre appelee
**
** apres db_selectall2
**
**/
function creat_selectcomplex($resquery,$headervalue, $headerdisplay,
$totlines, $action)
 {
 $nbrevalue=sizeof($headervalue);
 $nbredisplay=sizeof($headerdisplay);
 //$colres=array_keys($resquery);
 print "\n";
 print "<--SELECT-->\n";
 for ($row=0; $row<$totlines; $row++ )
{
print "0)
 {
 $textevalue.=", ".$resquery
[$headervalue[$y]][$row];

 }
else
 {
 $textevalue=$resquery[$headervalue
[$y]][$row];
 }
}
for ($x=0; $x<$nbredisplay; $x++)
{
if ($x<>0)
 {
 $textedisplay.=", ".$resquery
[$headerdisplay[$x]][$row];

 }
else
 {
 $textedisplay

Re: [PHP] Newbie question to everybody....PHP

2002-05-11 Thread Olexandr Vynnychenko

Hello r,

Sunday, May 12, 2002, 4:25:37 AM, you wrote:

r> Greetings people,
r> Special greetings to all of you who have helped me in the past.

r> As most of you know i am a newbie, I learned a bit of PHP via webmonkey and
r> a few other places, seeing the power of PHP i decided to convert from Java
r> servlets and JSP (JSP coz its expensive to host and not many hosting
r> opportunities) so I baught a book called "The PHP black book".
r> Anyway, now that the background is done heres my questions:

r> 1)How many of you have seriously dug into arrays and has it been important
r> in your programming?
r> 1.1)Do you think you could have done the same thing you did with arrays
r> WITHOUT arrays?
r> (The reason i ask this is theres a whole chapter dedicated to arrays in the
r> book & its pretty frustrating)

Arrays in PHP are very useful and easy to use. I had no problem. And I
have no book about PHP :). I use manual, because it's the best book. I
looked through some books and find that the PHP manual is MUCH better.

r> Last question:
r> Is ther any function to make the program "sleep" for 10 seconds or so? or
r> does anybody have a function that does this?

It's called sleep() :)
Once again, use manual. Espacially if you work on Windows. Then just
download the manual in CHM.It includes index and search capabilities.

-- 
Best regards,
 Olexandrmailto:[EMAIL PROTECTED]


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




RE: [PHP] Newbie question to everybody....PHP

2002-05-11 Thread John Holmes

> 1)How many of you have seriously dug into arrays and has it been
important
> in your programming?
> 1.1)Do you think you could have done the same thing you did with
arrays
> WITHOUT arrays?
> (The reason i ask this is theres a whole chapter dedicated to arrays
in
> the
> book & its pretty frustrating)
> Last question:
> Is ther any function to make the program "sleep" for 10 seconds or so?
or
> does anybody have a function that does this?

You should be ashamed of yourself... www.php.net/sleep :)

As for arrays, they are invaluable and not that hard to understand.
Don't skip over them, read the chapter a couple times if you have to...

---John Holmes...


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




Re: [PHP] Newbie question to everybody....PHP

2002-05-11 Thread Rasmus Lerdorf

I have never really understood why people have problems with arrays.  Just
think of an array as a table of values.  A one-dimensional array would be
a table with a single column and each row has a number (or index)
assigned to it:

  +---++
  | 0 | Apple  |
  +---++
  | 1 | Orange |
  +---++
  | 2 | Banana |
  +---++

In PHP this simple array could br created like this:

  $fruits[0] = 'Apple';
  $fruits[1] = 'Orange';
  $fruits[2] = 'Banana';

Or there is a shortcut:

  $fruits = array('Apple','Orange','Banana');

Now, the row numbers (or indices) do not have to start at 0.

  $fruits[7] = 'Apple';
  $fruits[10] = 'Orange';
  $fruits['foo'] = 'Banana';

Would create a table like this:

  +-++
  | 7   | Apple  |
  +-++
  | 10  | Orange |
  +-++
  | foo | Banana |
  +-++

As you can see, row names don't even have to be numbers.  When using
non-numerical array indices like this the array is sometimes referred to
as an associative array, although in PHP we don't really differentiate.

The shortcut for creating this array where you name each row would be:

  $fruits = array(7=>'Apple', 10=>'Orange', 'foo'=>'Banana');

and obviously, to display an element you would do:

  echo $fruits['foo'];

To loop through and display every value in the array you can use foreach:

  foreach($fruits as $value) echo $value;

If you also want to display the row name (also known as the index or the
key):

  foreach($fruits as $key=>$value) echo "$key: $value";

Now, what really seems to confuse people are multi-dimensional arrays, but
they are exactly the same.  A multi-dimensional array can be thought of as
a table with more columns and you give each column a name as well now.
Just like a tic-tac-toe board:

  01
  +---++---+
  | 0 | Apple  | 1.99  |
  +---++---+
  | 1 | Orange | 2.99  |
  +---++---+
  | 2 | Banana | 0.89  |
  +---++---+

So the Apple element would be in position 0,0, Orange would be 1,0 and
0.89 would be in position 2,1.  Or in PHP you would write this as:

  $fruits[0][0] = 'Apple';
  $fruits[0][1] = 1.99;
  $fruits[1][0] = 'Orange';
  $fruits[1][1] = 2.99;
  $fruits[2][0] = 'Banana';
  $fruits[2][1] = 0.89;

That's of course a bit wordy.  If you think of this slightly differently,
consider that each row is actually a small array of two items.  The fruit
and the price.  So you could also write this as:

  $fruits[0] = array('Apple',1.99);
  $fruits[1] = array('Orange',2.99);
  $fruits[2] = array('Banana',0.89);

And then further breaking it down, we see that $fruits is just an array of
arrays, so it could actually be written as:

  $fruits = array(array('Apple',1.99), array('Orange',2.99), array('Banana',0.89));

and again, you don't have to use simple numbers to name your rows and
columns.

 NamePrice
  +---++---+
  | a | Apple  | 1.99  |
  +---++---+
  | b | Orange | 2.99  |
  +---++---+
  | c | Banana | 0.89  |
  +---++---+

  $fruits = array( 'a'=>array('Name'=>'Apple', 'Price'=>1.99),
   'b'=>array('Name'=>'Orange','Price'=>2.99),
   'c'=>array('Name'=>'Banana','Price'=>0.89) );

Looping through a multi-dimensional array is a little trickier:

 foreach($fruits as $k=>$arr) {
echo "$k: ";
foreach($arr as $kk=>$val) {
   echo "$kk: $val ";
}
echo "\n";
 }

If you run that code on the $fruits array you will get this output:

a: Name: Apple Price: 1.99
b: Name: Orange Price: 2.99
c: Name: Banana Price: 0.89

So basically you loop through all the rows and then inside each row
iteration you loop through each column.

This is about as complex as you are ever likely to get.  You may end up
with 3-dimensional or higher arrays, but there really is no difference.
The display loop will of course get more complex as you will need another
level of looping.  For a 3-dimensional array you would have items like
$fruits[0][0][0] and your display loop would be:

  foreach() {
foreach() {
  foreach() { }
}
  }

-Rasmus

 On Sat, 11 May 2002, r wrote:

> Greetings people,
> Special greetings to all of you who have helped me in the past.
>
> As most of you know i am a newbie, I learned a bit of PHP via webmonkey and
> a few other places, seeing the power of PHP i decided to convert from Java
> servlets and JSP (JSP coz its expensive to host and not many hosting
> opportunities) so I baught a book called "The PHP black book".
> Anyway, now that the background is done heres my questions:
>
> 1)How many of you have seriously dug into arrays and has it been important
> in your programming?
> 1.1)Do you think you could have done the same thing you did with arrays
> WITHOUT arrays?
> (The reason i ask this is theres a whole chapter dedicated to arrays in the
> book & its pretty frustrating)
> Last question:
> Is ther any function to make the program "sleep" for 10 sec

RE: [PHP] Newbie question to everybody....PHP

2002-05-11 Thread Matthew Walker

1. I have dug deeper into arrays than I care to remember.

2. Absolutely not.

3. See http://www.php.net/sleep and http://www.php.net/usleep

Glad to hear you're converting to PHP! It's an amazing language, and I
don't see it going away any time in the near future. Hope you have fun,
and be sure to ask if you have any more questions. I always try and
answer questions on the list if I have the time, and know the answer.

Matthew Walker
Senior Software Engineer
ePliant Marketing
 

-Original Message-
From: r [mailto:[EMAIL PROTECTED]] 
Sent: Saturday, May 11, 2002 7:26 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Newbie question to everybodyPHP

Greetings people,
Special greetings to all of you who have helped me in the past.

As most of you know i am a newbie, I learned a bit of PHP via webmonkey
and
a few other places, seeing the power of PHP i decided to convert from
Java
servlets and JSP (JSP coz its expensive to host and not many hosting
opportunities) so I baught a book called "The PHP black book".
Anyway, now that the background is done heres my questions:

1)How many of you have seriously dug into arrays and has it been
important
in your programming?
1.1)Do you think you could have done the same thing you did with arrays
WITHOUT arrays?
(The reason i ask this is theres a whole chapter dedicated to arrays in
the
book & its pretty frustrating)
Last question:
Is ther any function to make the program "sleep" for 10 seconds or so?
or
does anybody have a function that does this?

ANY replies good,bad,flames will be welcome.
Cheers,
-Ryan.

/* You cannot get to the top by sitting on your bottom. */





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



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/2002
 

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




Re: [PHP] Newbie question to everybody....PHP

2002-05-11 Thread Bogdan Stancescu

Hi!

1. I believe every serious programmer out there uses arrays on a regular 
basis...
1.1. ...exactly because there are so many problems virtually unsolvable 
without them. Take for instance the case of a product page where people 
would fill in ordering quantitites.

My recommendation would be not to study arrays, but rather try solving 
problems using them - that way you'll have a better chance to remember 
what you've learned. But then again, that's me - maybe you learn better 
in other ways.

If you want to sleep, you can use sleep($seconds). But why in God's name 
would you want to do that?

Bogdan

r wrote:

>Greetings people,
>Special greetings to all of you who have helped me in the past.
>
>As most of you know i am a newbie, I learned a bit of PHP via webmonkey and
>a few other places, seeing the power of PHP i decided to convert from Java
>servlets and JSP (JSP coz its expensive to host and not many hosting
>opportunities) so I baught a book called "The PHP black book".
>Anyway, now that the background is done heres my questions:
>
>1)How many of you have seriously dug into arrays and has it been important
>in your programming?
>1.1)Do you think you could have done the same thing you did with arrays
>WITHOUT arrays?
>(The reason i ask this is theres a whole chapter dedicated to arrays in the
>book & its pretty frustrating)
>Last question:
>Is ther any function to make the program "sleep" for 10 seconds or so? or
>does anybody have a function that does this?
>
>ANY replies good,bad,flames will be welcome.
>Cheers,
>-Ryan.
>
>/* You cannot get to the top by sitting on your bottom. */
>
>
>
>
>




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




Re: [PHP] Newbie question to everybody....PHP

2002-05-11 Thread Neil Highley

Why would you want a scripting language to sleep, there is no such thing as
a loop in a web page (yes, I know it would be possible, but it would lock up
a users machine).

I know you can set up the apache daemon to run on-demand to conserver
resources, but I think you are getting mixed up between compiled and
interpreted (aka scripting) languages.

[EMAIL PROTECTED]
---
"Life must be lived as play."
- Plato (427 - 347 BC)

- Original Message -
From: "r" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, May 12, 2002 2:25 AM
Subject: [PHP] Newbie question to everybodyPHP


> Greetings people,
> Special greetings to all of you who have helped me in the past.
>
> As most of you know i am a newbie, I learned a bit of PHP via webmonkey
and
> a few other places, seeing the power of PHP i decided to convert from Java
> servlets and JSP (JSP coz its expensive to host and not many hosting
> opportunities) so I baught a book called "The PHP black book".
> Anyway, now that the background is done heres my questions:
>
> 1)How many of you have seriously dug into arrays and has it been important
> in your programming?
> 1.1)Do you think you could have done the same thing you did with arrays
> WITHOUT arrays?
> (The reason i ask this is theres a whole chapter dedicated to arrays in
the
> book & its pretty frustrating)
> Last question:
> Is ther any function to make the program "sleep" for 10 seconds or so? or
> does anybody have a function that does this?
>
> ANY replies good,bad,flames will be welcome.
> Cheers,
> -Ryan.
>
> /* You cannot get to the top by sitting on your bottom. */
>
>
>
>
>
> --
> 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




<    1   2   3   4   >