php-general Digest 10 Feb 2002 22:08:34 -0000 Issue 1164

Topics (messages 84158 through 84186):

Re: mysql_select_db() problem
        84158 by: DL Neil

Re: Sitenavigation
        84159 by: Nick Wilson

possible bug in date() function
        84160 by: LaserJetter
        84164 by: Edward van Bilderbeek - Bean IT
        84166 by: LaserJetter

subject line in mail()
        84161 by: Kunal Jhunjhunwala
        84162 by: Kunal Jhunjhunwala
        84163 by: Kunal Jhunjhunwala
        84185 by: Michael Kimsal

Searching class capable of parsing ID3-tags in MP3-files
        84165 by: Stefan Rusterholz
        84167 by: Girish Nath

APACHE .htaccess and PHP 403 errors
        84168 by: Andre Bajew

How can I open URL using HTTP POST instead of HTTP GET?
        84169 by: Zlutarch G.
        84171 by: Hugh Bothwell
        84172 by: James Cox

cookie problem
        84170 by: Impex Holidays Maldives / Hasan

Creating an array with a file
        84173 by: Scott

Re: Creating an array with a file--Fixed
        84174 by: Scott

Re: Phatt MySQL entry
        84175 by: Peter J. Schoenster
        84183 by: Michael Kimsal
        84184 by: Michael Kimsal

Expat Installation on windows
        84176 by: karthikeyan

Re: mime emails
        84177 by: Michael Kimsal
        84178 by: Michael Kimsal

my math stinks
        84179 by: Gary
        84180 by: Lars Torben Wilson
        84181 by: Jason Wong
        84182 by: Andrew Brampton

Re: escaping ?>
        84186 by: Martin Towell

Administrivia:

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

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

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


----------------------------------------------------------------------
--- Begin Message ---
> > What do you get if you use error checking?
>
> Well, that seems to be it, I'm getting 'Access deneid to user
> '@localhost'.....
>
> I'm talking to a guy on the mysql list, apparently it is a
> phenomememememememmemonmmm that when you GRANT ALL using wildcards it
> tends to grant all on * except localhost!


It's not so much a "phenomememememememmemonmmm" as a deliberate design feature.

On multi-user machines and network servers it is very common to have a security layer 
allowing tasks to only/not
be performed on the 'system console'. For example, would you want a remote user to 
bring down a mainframe with
some sort of STOP command? If you were an ISP or a DB Service Provider, would you want 
one user (using only one
table, or one database) to be able to reboot the entire MySQL server (and affect all 
the other
users/user-tables/user-databases)?

Thus Fred@localhost is not the same privilege profile as Fred@somewhere-else to enable 
flexibility in
access/security - even if Fred is the only user to ever touch the system! You have 
figured out by now, that to
give Fred the same privileges on the server as from a client machine, they need to be 
GRANTed 'twice'.

Looking at it the other way, such 'security' controls can be either limited by the 
user location, or by the name
of the user, or by both!

Regards,
=dn


--- End Message ---
--- Begin Message ---
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


* and then Raymond Lilleodegard declared....
> Hi!
> 
> Is i possible to make a function that makes a prev and a next link on the
> page if it returns, say over 20 rows or hits in a query? Could anyone give
> me a hint if they know how to?

There is a very good article on this exact topic at phpbuiler.com
Have fun.
- -- 

Nick Wilson

Tel:    +45 3325 0688
Fax:    +45 3325 0677
Web:    www.explodingnet.com



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)

iD8DBQE8ZkszHpvrrTa6L5oRAjYnAJ9Vox0Ora6hTtD1owtKBgP3PqSJkgCfctOP
k1yAJz+Ln1Dy0YUvldAp57E=
=YjNr
-----END PGP SIGNATURE-----
--- End Message ---
--- Begin Message ---
Using the code below:

$buffer['Last_access'] = 1013336429;
$date = date("H:i D, nS M Y",$buffer['Last_access']);
print $date;

prints "10:20 Sun, 2th Feb 2002"
I didnt know there was a 2th of February!!

Is this a bug and do I get a prize for finding it?  ;o)

LJ



--- End Message ---
--- Begin Message ---
it was last week though...

guesss you mean 29th?

Edward

"LaserJetter" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Using the code below:
>
> $buffer['Last_access'] = 1013336429;
> $date = date("H:i D, nS M Y",$buffer['Last_access']);
> print $date;
>
> prints "10:20 Sun, 2th Feb 2002"
> I didnt know there was a 2th of February!!
>
> Is this a bug and do I get a prize for finding it?  ;o)
>
> LJ
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


--- End Message ---
--- Begin Message ---
I've just realised that the suffix for the day of the month is correct for
today (1013336429) but it isn't the 2nd today and my clock is set right.
Anyone got any ideas?



"Laserjetter" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Using the code below:
>
> $buffer['Last_access'] = 1013336429;
> $date = date("H:i D, nS M Y",$buffer['Last_access']);
> print $date;
>
> prints "10:20 Sun, 2th Feb 2002"
> I didnt know there was a 2th of February!!
>
> Is this a bug and do I get a prize for finding it?  ;o)
>
> LJ
>
>
>


--- End Message ---
--- Begin Message ---
Hey,
I'm trying to force a subject line on the reply email of a recieved email...
the recieved email is sent using the mail() function in php... can this be
done? I know i can do it using html by doing :
mailto:[EMAIL PROTECTED]?subject=subect comes here

but not everyone allows html email... can i do something similar using the
mail() function?

Regards,
Kunal Jhunjhunwala

"Minds think with ideas, not information. No amount of data, bandwidth, or
processing power can substitute for inspired thought." - Clifford Stoll

--- End Message ---
--- Begin Message ---
yea... this sends out the email just fine... but if a user replies to the
email sent out via this method, the sbuject line changes... i want to keep
it static :)
Regards,
Kunal Jhunjhunwala

"Minds think with ideas, not information. No amount of data, bandwidth, or
processing power can substitute for inspired thought." - Clifford Stoll
----- Original Message -----
From: "TV Karthick Kumar" <[EMAIL PROTECTED]>
To: "Kunal Jhunjhunwala" <[EMAIL PROTECTED]>
Sent: Sunday, February 10, 2002 4:10 PM
Subject: Re: [PHP] subject line in mail()


> Did you use mail(to,subject,message,from) ??...
>
> Hth,
> Karthick
>
>
> ----- Original Message -----
> From: "Kunal Jhunjhunwala" <[EMAIL PROTECTED]>
> To: "php-list" <[EMAIL PROTECTED]>
> Sent: Sunday, February 10, 2002 11:31 AM
> Subject: [PHP] subject line in mail()
>
>
> > Hey,
> > I'm trying to force a subject line on the reply email of a recieved
> email...
> > the recieved email is sent using the mail() function in php... can this
be
> > done? I know i can do it using html by doing :
> > mailto:[EMAIL PROTECTED]?subject=subect comes here
> >
> > but not everyone allows html email... can i do something similar using
the
> > mail() function?
> >
> > Regards,
> > Kunal Jhunjhunwala
> >
> > "Minds think with ideas, not information. No amount of data, bandwidth,
or
> > processing power can substitute for inspired thought." - Clifford Stoll
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
>
>

--- End Message ---
--- Begin Message ---
hi,
hidden value where?? :)
Regards,
Kunal Jhunjhunwala

"Minds think with ideas, not information. No amount of data, bandwidth, or
processing power can substitute for inspired thought." - Clifford Stoll
----- Original Message -----
From: "TV Karthick Kumar" <[EMAIL PROTECTED]>
To: "Kunal Jhunjhunwala" <[EMAIL PROTECTED]>
Sent: Sunday, February 10, 2002 4:47 PM
Subject: Re: [PHP] subject line in mail()


> yeah, that's right, you don't even want to have 'Re: subject' in your
reply
> message ?. mm... if you can pass the subject (value) as a hidden variable
> then you can have it static and move around with it... So far, I have
> thought only this way....
>
> Is it going to help you ?. If it does, you are a happy man.
>
> Hth,
> Karthick
>
>
> > yea... this sends out the email just fine... but if a user replies to
the
> > email sent out via this method, the sbuject line changes... i want to
keep
> > it static :)
> > Regards,
> > Kunal Jhunjhunwala
> >
> > "Minds think with ideas, not information. No amount of data, bandwidth,
or
> > processing power can substitute for inspired thought." - Clifford Stoll
> > ----- Original Message -----
> > From: "TV Karthick Kumar" <[EMAIL PROTECTED]>
> > To: "Kunal Jhunjhunwala" <[EMAIL PROTECTED]>
> > Sent: Sunday, February 10, 2002 4:10 PM
> > Subject: Re: [PHP] subject line in mail()
> >
> >
> > > Did you use mail(to,subject,message,from) ??...
> > >
> > > Hth,
> > > Karthick
> > >
> > >
> > > ----- Original Message -----
> > > From: "Kunal Jhunjhunwala" <[EMAIL PROTECTED]>
> > > To: "php-list" <[EMAIL PROTECTED]>
> > > Sent: Sunday, February 10, 2002 11:31 AM
> > > Subject: [PHP] subject line in mail()
> > >
> > >
> > > > Hey,
> > > > I'm trying to force a subject line on the reply email of a recieved
> > > email...
> > > > the recieved email is sent using the mail() function in php... can
> this
> > be
> > > > done? I know i can do it using html by doing :
> > > > mailto:[EMAIL PROTECTED]?subject=subect comes here
> > > >
> > > > but not everyone allows html email... can i do something similar
using
> > the
> > > > mail() function?
> > > >
> > > > Regards,
> > > > Kunal Jhunjhunwala
> > > >
> > > > "Minds think with ideas, not information. No amount of data,
> bandwidth,
> > or
> > > > processing power can substitute for inspired thought." - Clifford
> Stoll
> > > >
> > > >
> > > > --
> > > > PHP General Mailing List (http://www.php.net/)
> > > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> > > _________________________________________________________
> > > Do You Yahoo!?
> > > Get your free @yahoo.com address at http://mail.yahoo.com
> > >
> > >
> > >
> > >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
>
>

--- End Message ---
--- Begin Message ---
Kunal Jhunjhunwala wrote:
> Hey,
> I'm trying to force a subject line on the reply email of a recieved email...
> the recieved email is sent using the mail() function in php... can this be
> done? I know i can do it using html by doing :
> mailto:[EMAIL PROTECTED]?subject=subect comes here
> 
> but not everyone allows html email... can i do something similar using the
> mail() function?
> 
> Regards,
> Kunal Jhunjhunwala


You can't control anything about what someone sends you.  Regardless
of what you try to do with browser/email client tricks, if I want to
send you a message with the subject as 'foo', that's what you'll get. 
You can't stop or alter that.



--- End Message ---
--- Begin Message ---
I
I search a class to parse mp3-files' id3 tag. I already found one at 
upperdesign.com but it seems not to be capable of parsing newer versions 
of the id3 tag :(
So does anyone know an already existing class doing that for me?

TIA
Stefan Rusterholz

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

There is a class that can manipluate version 1 tags here :

http://leknor.com/code/php/view/class.id3.php.txt

and a some beta code for handling version 2 tags here :

http://leknor.com/code/php/view/beta/class.id3v2.php.txt

I don't know if that helps.

Regards


Girish
--
www.girishnath.co.uk


----- Original Message ----- 
From: "Stefan Rusterholz" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, February 10, 2002 12:02 PM
Subject: [PHP] Searching class capable of parsing ID3-tags in MP3-files


I
I search a class to parse mp3-files' id3 tag. I already found one at 
upperdesign.com but it seems not to be capable of parsing newer versions 
of the id3 tag :(
So does anyone know an already existing class doing that for me?

TIA
Stefan Rusterholz


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


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

Anyone out there familiar with Apache's .htaccess & running PHP scripts?

I'm using Apaches's mod_rewrite to route some virtual hosts which runs great
but is causing HTTP Error 403 - Access forbidden errors just for my .php
scripts. I assume there is some sort of .htaccess statement that will get my
php scripts back working but I haven't found it yet.

Any help would be sincerely appreciated!!
Andre


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

PHP fopen function opens URL using the HTTP GET method. But what if one 
could only open the web page using the HTTP POST method? In this case, fopen 
won't work. Is there a PHP function that is similar to fopen, but uses HTTP 
POST method to open URL instead? If not, then how do I work around this 
problem?

Thanks,

Zlu


_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com

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

"Zlutarch G." <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi everyone,
>
> PHP fopen function opens URL using the HTTP GET method. But what if one
> could only open the web page using the HTTP POST method? In this case,
fopen
> won't work. Is there a PHP function that is similar to fopen, but uses
HTTP
> POST method to open URL instead? If not, then how do I work around this
> problem?

Umm... you might have to open a socket and read/write directly.
To do this, you'd have to look up the appropriate RFCs and write
the headers manually.

Anyone got a better idea?


--- End Message ---
--- Begin Message ---
http://php.net/curl

> -----Original Message-----
> From: Hugh Bothwell [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, February 10, 2002 4:31 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Re: How can I open URL using HTTP POST instead of HTTP
> GET?
> 
> 
> 
> "Zlutarch G." <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Hi everyone,
> >
> > PHP fopen function opens URL using the HTTP GET method. But what if one
> > could only open the web page using the HTTP POST method? In this case,
> fopen
> > won't work. Is there a PHP function that is similar to fopen, but uses
> HTTP
> > POST method to open URL instead? If not, then how do I work around this
> > problem?
> 
> Umm... you might have to open a socket and read/write directly.
> To do this, you'd have to look up the appropriate RFCs and write
> the headers manually.
> 
> Anyone got a better idea?
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
--- End Message ---
--- Begin Message ---
Hi all,

Perhaps some one can help me.

If I send a cookie like 
setcookie(+ACI-cookie+AF8-agtpasswd+ACI-,+ACQ-form+AF8-agent+AF8-pass, time()+-1200, 
+ACI-/+ACI-)+ADs-

it does not work on the terminal which has a new version of windows 2000 and i use 
IE6. The browser does not store the cookie.

but if is use 
setcookie(+ACI-cookie+AF8-agtpasswd+ACI-,+ACQ-form+AF8-agent+AF8-pass)+ADs-
I can retrive the cookie variable.

This happens on a few terminal but for other with win 2000 it both cookie send works 
fine.

Has anyone come across this problem?
Has anyone got any suggestions. Is this a problem of the win 2000 or the browser 
setting.

thanks,
Hasan





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

I am trying to create an array from a text file that I will process and
rewrite in a new format.  My question is, is it possible to read the
file 
in one line at a time and then separate the tab-delimited fields and
finally rewrite the new file?

The fields are tab delimited and here is what I have attempted in code:

$lines = fopen("oldfile.txt", "r");
$newfields = explode("\t", $lines);
echo $newquotes[0];

I get a Resource ID #1 when I echo the line.  

Thanks,

-Scott

--- End Message ---
--- Begin Message ---
Nevermind, I was able to figure it out using:

$myfile = file("oldfile.txt");
for ($s=0; $s<=count($myfile)-1; $s++) {
    $fields = split("\t",$myfile[$s]);
    print("$fields[1]\n");
}

-----Original Message-----
From: Scott [mailto:[EMAIL PROTECTED]] 
Sent: Monday, February 11, 2002 12:33 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Creating an array with a file

Hi All,

I am trying to create an array from a text file that I will process and
rewrite in a new format.  My question is, is it possible to read the
file 
in one line at a time and then separate the tab-delimited fields and
finally rewrite the new file?

The fields are tab delimited and here is what I have attempted in code:

$lines = fopen("oldfile.txt", "r");
$newfields = explode("\t", $lines);
echo $newquotes[0];

I get a Resource ID #1 when I echo the line.  

Thanks,

-Scott


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

--- End Message ---
--- Begin Message ---
On 10 Feb 2002, at 14:30, Liam MacKenzie wrote:

> I have a form, with 196 fields that I need entered into a database.
> But the form and it's contents need to be changed every day, and I

That distracts me. Does the form change? I think not. It looks like 
a data entry form and the only thing that would change would be 
the DATE. I would think the form remains the same. I did not notice 
any hidden field to indicate the date though.

> need to store the old data in an archive so it can be accessed at a
> later date.

Me, in a hurry, I'd just store one more column in your table: DATE. 
I don't see it. I add that. When they want a previous date they just 
say select all where date = date they want.  

> That means that after a week, I'm going to have a tonne of data.

Umm ... this seems to indicate that maybe the form does change 
??? I'm thinking maybe you might have different users. If so I'd add 
a userid column. 

> Catch is, this form will be used every day for about 3 years.
> I'm pretty certain MySQL can handle it, but I need to know, what
> would be the best way to store this data?

There might be better ways to store the data but I don't usually 
think about those things. I'd ask some old fogey who worked in the 
days of 640K :) ... seriously  ... but I think you'll end up going to 
trouble for no reason. Memory, storage is cheap. A friend was 
moaning that his app was slow (plain cgi/perl so I suggested 
mod_perl/fastcgi) and they just threw a hardware upgrade and all 
was well (but imho should still do mod_perl/fascgi).

> I've set up a calendar, that will take the user to a different version
> of the form every day. Accesible here:

I don't see the reason for a "different version" of the form for every 
day. Isn't the date the only difference?

> http://www.fernwoodwhc.com/shit/calendar.php And the form I'm talking
> about is here: http://www.fernwoodwhc.com/tech.php

Well about how you would do it. It seems that PHP is in many 
ways like the old one form, one cgi method of development. Were I 
you I would not make my connection to the database in that script. 
I'd do that in only one place. Odd how things tend to evolve and 
before you know it you have 232 scripts all using 
username/password/db/host and then you want to change that.  I'd 
look at something like metabase were I you.

http://phpclasses.upperdesign.com/browse.html/package/20/

Peter



---------------------------
"Reality is that which, when you stop believing in it, doesn't go
away".
                -- Philip K. Dick
--- End Message ---
--- Begin Message ---
Liam Mackenzie wrote:
> Hi,
> 
> I was wondering what you would do in this situation...
> 
> I have a form, with 196 fields that I need entered into a database.
> But the form and it's contents need to be changed every day,
> and I need to store the old data in an archive so it can be accessed
> at a later date.
> 
> That means that after a week, I'm going to have a tonne of data.
> Catch is, this form will be used every day for about 3 years.
> I'm pretty certain MySQL can handle it, but I need to know, what
> would be the best way to store this data?
> 
> I've set up a calendar, that will take the user to a different version
> of the form every day.
> Accesible here:
> http://www.fernwoodwhc.com/shit/calendar.php
> And the form I'm talking about is here:
> http://www.fernwoodwhc.com/tech.php
> 
> Here's a copy (minus passwords) of my form...
> I'm sure that there's a better way to do it...
> 


I'm sure there is too... :)

Have you any experience with arrays?

PHP can accept data from the form in the form of an array, so you can
build your form and process it with many fewer lines than you have (and
modify things much easier).

If, for example, the club opened at 5:00 am in the future instead of 6,
you'd probably have to go change that big huge SQL statement, and add 
more lines to the code, right?  If you build with arrays, and smartly,
you can avoid much of the work you're doing.

BTW - the 'smartly' thing isn't to imply you're not smart.  I'm simply
saying there are techniques to make this stuff easier, and once you
know them, you won't go back, and you'll work faster.

I'd probably make each time/date a separate entry in a table, so each
day would have 196 entries, instead of one row having 196 columns, which
you seem to be doing.

<?
$startkey = 600;
$starttime = (5 * 3600); // EDT is 5 hours behind GMT, so we get 
ourselves to midnight
$starttime = $starttime + (3600 * 6) ; // start off at 6 hours into the 
morning
$endtime = $starttime + (3600 * 18) ; // end 18 hours in the future
?> <table> <?
while ($starttime < $endtime) {
$time = date("h:i A",$starttime);
$x = date("Hi",$starttime);
?>
  <td><b><font size="2"><?=$time;?></font></b></td>
        <td><input type="radio" name="fs[<?=$x;?>]" value="fw">
        <input type="radio" name="fs[<?=$x;?>]" value="sp"></td>
        <td><input type="text" name="num[<?=$x;?>]" size="4"></td>
        <td><input type="text" name="sur[<?=$x;?>]" size="8"></td>
        <td><input type="text" name="giv[<?=$x;?>]" size="8"></td>
        <td>
                <select size="1" name="apt[<?=$x;?>]">
                        <option selected value="1">1
                        <option value="2">2
                        <option value="re">Re
                </select>
        </td>
        <td><input type="text" name="ph[<?=$x;?>]" size="8"></td>
        <td><input type="checkbox" name="c[<?=$x;?>]" value="ON"></td>
</tr>
<?
$starttime = $starttime + 1800;
}
?>
<input type="hidden" name="date" value="<?=$dateValueYouPassIn;?>"
</table>

As an example, this seems more manageable to me.  the EDT is for me - 
that's my timezone.  You'd need to adjust yours to start with, but 
everything else should work OK.  You're left with arrays that will get
submitted to PHP like

$num[0600]
$sur[0600] etc.

if you did this...

<?
while (list($k,$v) = each($num)) {
        $n = $num[$k];
        $s = $sur[$k];
        $g = $giv[$k];
        $a = $apt[$k];
        $p = $ph[$k];
        $c = $c[$k];
        $f = $fs[$k];
$sql = "insert into info (date,time,num,sur,giv,apt,ph,c,fs) values (";
$sql .= "'$date','$k','$n','$s','$g$','$a','$p','$c','$f')";
// do SQL processing here
}
?>

Realize this isn't fully functioning code, but might give you a better 
idea on how to approach it.

Hope that helps...





--- End Message ---
--- Begin Message ---
Liam Mackenzie wrote:
> Hi,
> 
> I was wondering what you would do in this situation...
> 
> I have a form, with 196 fields that I need entered into a database.
> But the form and it's contents need to be changed every day,
> and I need to store the old data in an archive so it can be accessed
> at a later date.
> 
> That means that after a week, I'm going to have a tonne of data.
> Catch is, this form will be used every day for about 3 years.
> I'm pretty certain MySQL can handle it, but I need to know, what
> would be the best way to store this data?
> 
> I've set up a calendar, that will take the user to a different version
> of the form every day.
> Accesible here:
> http://www.fernwoodwhc.com/shit/calendar.php
> And the form I'm talking about is here:
> http://www.fernwoodwhc.com/tech.php
> 
> Here's a copy (minus passwords) of my form...
> I'm sure that there's a better way to do it...
> 


I'm sure there is too... :)

Have you any experience with arrays?

PHP can accept data from the form in the form of an array, so you can
build your form and process it with many fewer lines than you have (and
modify things much easier).

If, for example, the club opened at 5:00 am in the future instead of 6,
you'd probably have to go change that big huge SQL statement, and add 
more lines to the code, right?  If you build with arrays, and smartly,
you can avoid much of the work you're doing.

BTW - the 'smartly' thing isn't to imply you're not smart.  I'm simply
saying there are techniques to make this stuff easier, and once you
know them, you won't go back, and you'll work faster.

I'd probably make each time/date a separate entry in a table, so each
day would have 196 entries, instead of one row having 196 columns, which
you seem to be doing.

<?
$startkey = 600;
$starttime = (5 * 3600); // EDT is 5 hours behind GMT, so we get 
ourselves to midnight
$starttime = $starttime + (3600 * 6) ; // start off at 6 hours into the 
morning
$endtime = $starttime + (3600 * 18) ; // end 18 hours in the future
?> <table> <?
while ($starttime < $endtime) {
$time = date("h:i A",$starttime);
$x = date("Hi",$starttime);
?>
  <td><b><font size="2"><?=$time;?></font></b></td>
        <td><input type="radio" name="fs[<?=$x;?>]" value="fw">
        <input type="radio" name="fs[<?=$x;?>]" value="sp"></td>
        <td><input type="text" name="num[<?=$x;?>]" size="4"></td>
        <td><input type="text" name="sur[<?=$x;?>]" size="8"></td>
        <td><input type="text" name="giv[<?=$x;?>]" size="8"></td>
        <td>
                <select size="1" name="apt[<?=$x;?>]">
                        <option selected value="1">1
                        <option value="2">2
                        <option value="re">Re
                </select>
        </td>
        <td><input type="text" name="ph[<?=$x;?>]" size="8"></td>
        <td><input type="checkbox" name="c[<?=$x;?>]" value="ON"></td>
</tr>
<?
$starttime = $starttime + 1800;
}
?>
<input type="hidden" name="date" value="<?=$dateValueYouPassIn;?>"
</table>

As an example, this seems more manageable to me.  the EDT is for me - 
that's my timezone.  You'd need to adjust yours to start with, but 
everything else should work OK.  You're left with arrays that will get
submitted to PHP like

$num[0600]
$sur[0600] etc.

if you did this...

<?
while (list($k,$v) = each($num)) {
        $n = $num[$k];
        $s = $sur[$k];
        $g = $giv[$k];
        $a = $apt[$k];
        $p = $ph[$k];
        $c = $c[$k];
        $f = $fs[$k];
$sql = "insert into info (date,time,num,sur,giv,apt,ph,c,fs) values (";
$sql .= "'$date','$k','$n','$s','$g$','$a','$p','$c','$f')";
// do SQL processing here
}
?>

Realize this isn't fully functioning code, but might give you a better 
idea on how to approach it.

Hope that helps...






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

  How do i install expat on WinNt.  I have php-4.0.6.  

  Looking forward for yours response.

karthikeyan.
--- End Message ---
--- Begin Message ---
Kunal Jhunjhunwala wrote:
> hey..
> does anyone know of any good classes / functions for handling mime emails? i
> am writing a mail checker, and was wondering if there are any pre-written
> mime email handling classes out there...
> thanks!
> Regards,
> Kunal Jhunjhunwala
> 
> "Minds think with ideas, not information. No amount of data, bandwidth, or
> processing power can substitute for inspired thought." - Clifford Stoll
> 
> 

I believe there's something in PEAR, which should have come with your
distribution - look at pear.php.net also.  There's some mail handling 
classes, and one deals with not only sending MIME, but unencoding it as 
well.

--- End Message ---
--- Begin Message ---
Kunal Jhunjhunwala wrote:
> hey..
> does anyone know of any good classes / functions for handling mime emails? i
> am writing a mail checker, and was wondering if there are any pre-written
> mime email handling classes out there...
> thanks!
> Regards,
> Kunal Jhunjhunwala
> 
> "Minds think with ideas, not information. No amount of data, bandwidth, or
> processing power can substitute for inspired thought." - Clifford Stoll
> 
> 

I believe there's something in PEAR, which should have come with your
distribution - look at pear.php.net also.  There's some mail handling 
classes, and one deals with not only sending MIME, but unencoding it as 
well.


--- End Message ---
--- Begin Message ---
Hi All,
  This is the first time I have had to deal with math. I have gone 
through the manual and a few books and I think I am worse off then when 
I started. Can someone give me an example of the simple math below. I 
think If I see some in code I can move on from there.

I need to find out if $pa > $pb or $pb > $pa then subtract smallest from 
the largest and add $ca and then add $ps

TIA
Gary

--- End Message ---
--- Begin Message ---
On Sun, 2002-02-10 at 11:05, Gary wrote:
> Hi All,
>   This is the first time I have had to deal with math. I have gone 
> through the manual and a few books and I think I am worse off then when 
> I started. Can someone give me an example of the simple math below. I 
> think If I see some in code I can move on from there.
> 
> I need to find out if $pa > $pb or $pb > $pa then subtract smallest from 
> the largest and add $ca and then add $ps
> 
> TIA
> Gary

Break the problem down:

 I need to subtract the lesser (minimum) of $pa and $pb from the 
 greater (maximum) of $pa and $pb;
 Then just add $ca and $ps.

So something like this will do it:

  $result = (max($pa, $pb) - min($pa, $pb)) + $ca + $ps;


Hope this helps,

Torben

-- 
 Torben Wilson <[EMAIL PROTECTED]>
 http://www.thebuttlesschaps.com
 http://www.hybrid17.com
 http://www.inflatableeye.com
 +1.604.709.0506

--- End Message ---
--- Begin Message ---
On Monday 11 February 2002 03:05, Gary wrote:
> Hi All,
>   This is the first time I have had to deal with math. I have gone
> through the manual and a few books and I think I am worse off then when
> I started. Can someone give me an example of the simple math below. I
> think If I see some in code I can move on from there.
>
> I need to find out if $pa > $pb or $pb > $pa then subtract smallest from
> the largest and add $ca and then add $ps

Try:

  ABS($pa - $pb) + $ca + $ps;



-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk

/*
I want the presidency so bad I can already taste the hors d'oeuvres.
*/
--- End Message ---
--- Begin Message ---
$answer = abs($pa - $pb) + $ca +$ps;

No ifs :)
Maybe I'm lazy, but I like 1 line statements

Andrew

----- Original Message ----- 
From: "Gary" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, February 10, 2002 7:05 PM
Subject: [PHP] my math stinks


> Hi All,
>   This is the first time I have had to deal with math. I have gone 
> through the manual and a few books and I think I am worse off then when 
> I started. Can someone give me an example of the simple math below. I 
> think If I see some in code I can move on from there.
> 
> I need to find out if $pa > $pb or $pb > $pa then subtract smallest from 
> the largest and add $ca and then add $ps
> 
> TIA
> Gary
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

--- End Message ---
--- Begin Message ---
what about this?

$contents = str_replace('<?xml version="1.0"?'.'>', '', $contents);


-----Original Message-----
From: Steven Jarvis [mailto:[EMAIL PROTECTED]]
Sent: Saturday, February 09, 2002 8:46 AM
To: [EMAIL PROTECTED]
Subject: [PHP] escaping ?>


I'm trying to do some string replaces on XML files to import them into a 
prprietary db that doesn't understand XML.

I need to strip the XML tags out of the file.

However, when I use this line:

$contents = str_replace('<?xml version="1.0"?>', '', $contents);

The ?> in the string ends my php block.


I know there's an easy answer to this, and I'm probably just suffering 
from Friday afternoon burnout, but can someone let me know how to escape 
those so that I can search for them in the string?

thanks,

Steven


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

Reply via email to