RE: [PHP] Re: Tom-Re: [PHP] session hijacking

2003-10-20 Thread Ow Mun Heng
Hi Tom,

I've got a question for you regarding this encrypt class of yours.. Just
wanted to understand how well it would work against a guy with a sniffer
such as ethereal. (presuming he's on the LAN/wifi to access the app)

How does the encryption happen?? Client side or server side? How does it get
transmitted? I'm curious as to how to prevent ppl from sniffing out the
username/pass combo for these sort of sites that need memberships.

In some instances.. I can see the user/pass combo being passed in plain text


eg : user=someuserpass=somepassid=232..

or in hashed form

eg :eg :
user=someuserpass=*(^$[EMAIL 
PROTECTED](J83%#396asjjuwo273314koopu83jsklid=232.
.

How does the hash happen???


snip
Save it in encrypt_class.inc
?
class encrypt_class{
var $secret;
function encrypt_class(){
$this-secret = 'you should change this to something else';
}
/snip

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



RE: Re[2]: [PHP] Re: Tom-Re: [PHP] session hijacking

2003-10-20 Thread Ow Mun Heng
The encryption happens server side and is really only intended to encrypt
variables that are passed to web client such as product id and stuff. The
only
way to do secure login and prevent sniffing is to use ssl which will
encrypt the
traffic to and from the client. I suppose javascript could be used to
fudge
encryption but that would be extremely weak way to do it. To protect
hidden
variables you will still need to use some form of server side encryption.
If you
have more than one hidden variable a good way is to put them in an array,
serialize it and encrypt the result and put that in a single hidden field.
It
would almost be impossible to interfere with those. Something like this:

Hmm.. Thanks for the answer.. This question was mainly asked because I was
paranoid about using Wifi to access my Yahoo Webmail. 

No more accessing _anything_ private over wifi or rather.. I'll have to
re-think my password/privacy policy with regard to ssl/non ssl (http vs
https) sites..

Better be paranoid.. 

One other thing.. What's the difference in $$ for a site to be https rather
than http?? Cos you need  to get a verisign cert or something?? Just
asking..


Cheers, .^.
Mun Heng, Ow/V\
H/M Engineering   /(   )\
Western Digital M'sia  ^^-^^
DID : 03-7870 5168  The Linux Advocate



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



[PHP] Why Redirection works on 1 machine but not on another

2003-08-11 Thread Ow Mun Heng
Hi,

I have this peculiar problem, my header

header( Refresh:2;url=$g_prog_path/$l_refresh_url );

is set up correctly to be the FULL pathname. It works on some PC but now on
some others. I'm using IE on win98/2000. The offending one is IE6 (128bit)
on Win98. (IE5.5/win98 works but I've yet to try it on another win98/ie6)

Any ideas?

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


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



RE: [PHP] session header issue

2003-07-31 Thread Ow Mun Heng
snip
The Location: header requires a correctly formed URL, ie http://...
/snip

I'm running fine using only Location:home.php on Mozilla  IE 6

maybe I should change.
Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Jason Wong [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 31, 2003 11:13 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] session header issue


On Thursday 31 July 2003 06:39, Sam Folk-Williams wrote:
 I've got a site with a login authentication script in a file called
 login.php. Every page has a simple session check on top of it, as well
 as line that captures the name of the file the user is trying to view.
 The idea is that if the user tries to go straight to an inside page
 without logging in, they get sent to the login page (index.php) with the

Don't you mean they get sent to login.php?

 variable $file marking the page they wanted to view. When they log in,
 the $file variable is sent to login.php and (if $file is set) login.php
 returns them to the page they were trying to view using a simple header
 redirect: header(Location: $file);

The Location: header requires a correctly formed URL, ie http://...

 Problem: instead of sending them to the page they wanted to view, they
 get sent to this URL: login.php?file=/dir/file_name.php?v=123

 What's going on here? Why doesn't Location: $file return the contents
 of $file?

What do you mean? Have you checked that $file contains what you expect it to

contain? Putting $file inside double-quotes doesn't magically transform its 
contents.

-- 
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
--
/*
QOTD:
Unlucky?  If I bought a pumpkin farm, they'd cancel Halloween.
*/


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



RE: [PHP] session header issue

2003-07-31 Thread Ow Mun Heng
I changed it so that it's not an ABS URL. I had it working so.. I thought,
if it aint' broken, don't  fix it...

Well, I fixed it anyway, who knows it might cause problems somewhere..

Thank All.

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Sam Folk-Williams [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 31, 2003 11:41 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] session header issue


 That doesn't justify it. This is no different than writing screwed up HTML
 tables that happen to appear as you want in the browser you're testing
with.

GREAT point! Sorry, I didn't realize it was bad form. Just ignorant here -- 
I tried it with an absolule URL and it now works fine. Thanks for the help.

Sam

Chris Shiflett [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 --- Sam Folk-Williams [EMAIL PROTECTED] wrote:
   The Location: header requires a correctly formed URL
 
  It works fine having Location: main.php

 That doesn't justify it. This is no different than writing screwed up HTML
 tables that happen to appear as you want in the browser you're testing
with.
 You never know when your broken code is going to cause problems somewhere,
and
 you've no one to blame but yourself when they do.

 It's much better for everyone just to do things the right way. The
Location
 header  should be an absolute URL.

 Chris

 =
 Become a better Web developer with the HTTP Developer's Handbook
 http://httphandbook.org/



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



RE: [PHP] Script Execution Time

2003-07-29 Thread Ow Mun Heng
This is what I use.. simple.. (someone from this list contributed it)

function stopwatch_init()
{
list($usec, $sec) = explode( , microtime());
return ( (float)$usec + (float)$sec );
}



Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Jeff Harris [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 29, 2003 9:17 AM
To: Petya A Shushpanov
Cc: Radek Zajkowski; PHP GENERAL
Subject: Re: [PHP] Script Execution Time


On Jul 29, 2003, Petya A Shushpanov claimed that:

|?
|class  jTimer  {
|[snip]
|
|$timer-stop();
|echo round($timer-elapsed(),5);
|?
|
|--
|Petya A Shushpanov
|

Or, you could use http://pear.php.net/package-info.php?package=Benchmark
-- 
Registered Linux user #304026.
lynx -source http://jharris.rallycentral.us/jharris.asc | gpg --import
Key fingerprint = 52FC 20BD 025A 8C13 5FC6  68C6 9CF9 46C2 B089 0FED
Responses to this message should conform to RFC 1855.




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



[PHP] $_GET['sort'] argument separator

2003-07-28 Thread Ow Mun Heng
Hi,

I have this problem, which could easily be solved through a name
change but I would like to learn more.

There's a table set up from a MySQL query like this

row1)   Eval #  Title   # Heads My Findings
row2)   P1000   Title16 This is my findings
row3)   P1223   Eg 2  3 2nd findings

row1 is the header columns, the title names are derived from sql statement
executed as SELECT eval_no as Eval # etc..

row1 is also set up such that if the user clicks the link, it will trigger a
SQL comand to sort it.

The problem here is the '#' sign/key. spaces are no problem. the
$_GET['sort'] is not able to get the whole field, as such Eval # can only
be recognised as Eval and thus sql is not able to sort it.

I've looked at the php.ini file and tried setting these 2 configs

snip from php manual
arg_separator.output string
The separator used in PHP generated URLs to separate arguments. 

arg_separator.input string
List of separator(s) used by PHP to parse input URLs into variables. 
Note: Every character in this directive is considered as separator! 
/snip

but it still does not work..

snip
This is how the link looks like
http://10.0.0.1/trackit/trackit-2003-07-28/view_set_tracker.php?sort=Eval%20
#dir=ASC


Help... Please...

==view_tracker.php==
$l_column_header = nl2br(mysql_field_name($l_results,$k));

echo nl2br(sql_sort_by_header($l_column_header, $l_column_header,
sql_sort_cat, $sql_sort_dir) );

=sql_functions===
function sql_sort_by_header( $p_string, $p_sort_field, $p_sort, $p_dir ) {
if ( $p_sort_field == $p_sort ) {
# we toggle between ASC and DESC if the user clicks the same
sort order
if ( 'ASC' == $p_dir ) {
$p_dir = 'DESC';
} else {
$p_dir = 'ASC';
}
}
echo 'a href=view_set_tracker.php?sort=' . $p_sort_field . 'amp;dir=' .
$p_dir . ''. $p_string .'/a';
}
=view_set_tracker.php
$_SESSION['sql_sort_cat']   = '';
$_SESSION['sql_sort_dir']   =
$GLOBALS['g_default_sql_sort_dir'];
$_SESSION['sql_sort_cat']   = $_GET['sort'];

if (!empty( $_GET['dir'] ))
{
$sql_sort_dir = $_GET['dir'];
}

header_redirect_html(view_tracker.php);
}

?

=

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168

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



[PHP] using SESSIONS to store page 2 page variables

2003-07-28 Thread Ow Mun Heng
Hi,

Is it advisable to use SESSIONS to store variable from one page to
another page instead of using something like a hidden field?

eg: 
$_SESSION['sql_sort_cat']
$_SESSIOn['sql_sort_dir']

instead of

input type=hidden value=?php $sql_sort_cat? 


Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168

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



RE: [PHP] using SESSIONS to store page 2 page variables

2003-07-28 Thread Ow Mun Heng
I think it's OK since users needs to be authenticated.

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Marek Kilimajer [mailto:[EMAIL PROTECTED]
Sent: Monday, July 28, 2003 4:46 PM
To: Ow Mun Heng
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] using SESSIONS to store page 2 page variables


No problem, but remember the user might want to bookmark the page.

Ow Mun Heng wrote:
 Hi,
 
   Is it advisable to use SESSIONS to store variable from one page to
 another page instead of using something like a hidden field?
 
 eg: 
 $_SESSION['sql_sort_cat']
 $_SESSIOn['sql_sort_dir']
 
 instead of
 
 input type=hidden value=?php $sql_sort_cat? 
 
 
 Cheers,
 Mun Heng, Ow
 H/M Engineering
 Western Digital M'sia 
 DID : 03-7870 5168
 


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



RE: [PHP] $_GET['sort'] argument separator

2003-07-28 Thread Ow Mun Heng
Nope.. Still does not work..


Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Nicholas Robinson [mailto:[EMAIL PROTECTED]
Sent: Monday, July 28, 2003 4:53 PM
To: Ow Mun Heng; [EMAIL PROTECTED]
Subject: Re: [PHP] $_GET['sort']  argument separator


What happens if you use a non-breaking html space instead? I.e Evalnbsp#

HTH

Nick
On Monday 28 Jul 2003 9:06 am, Ow Mun Heng wrote:
 Hi,

   I have this problem, which could easily be solved through a name
 change but I would like to learn more.

 There's a table set up from a MySQL query like this

 row1) Eval #  Title   # Heads My Findings
 row2) P1000   Title16 This is my findings
 row3) P1223   Eg 2  3 2nd findings

 row1 is the header columns, the title names are derived from sql statement
 executed as SELECT eval_no as Eval # etc..

 row1 is also set up such that if the user clicks the link, it will trigger
 a SQL comand to sort it.

 The problem here is the '#' sign/key. spaces are no problem. the
 $_GET['sort'] is not able to get the whole field, as such Eval # can
only
 be recognised as Eval and thus sql is not able to sort it.

 I've looked at the php.ini file and tried setting these 2 configs

 snip from php manual
 arg_separator.output string
 The separator used in PHP generated URLs to separate arguments.

 arg_separator.input string
 List of separator(s) used by PHP to parse input URLs into variables.
 Note: Every character in this directive is considered as separator!
 /snip

 but it still does not work..

 snip
 This is how the link looks like

http://10.0.0.1/trackit/trackit-2003-07-28/view_set_tracker.php?sort=Eval%2
0 #dir=ASC


 Help... Please...

 ==view_tracker.php==
 $l_column_header = nl2br(mysql_field_name($l_results,$k));

 echo nl2br(sql_sort_by_header($l_column_header, $l_column_header,
 sql_sort_cat, $sql_sort_dir) );

 =sql_functions===
 function sql_sort_by_header( $p_string, $p_sort_field, $p_sort, $p_dir ) {
 if ( $p_sort_field == $p_sort ) {
 # we toggle between ASC and DESC if the user clicks the same
 sort order
 if ( 'ASC' == $p_dir ) {
 $p_dir = 'DESC';
 } else {
 $p_dir = 'ASC';
 }
 }
 echo 'a href=view_set_tracker.php?sort=' . $p_sort_field . 'amp;dir=' .
 $p_dir . ''. $p_string .'/a';
 }
 =view_set_tracker.php
   $_SESSION['sql_sort_cat']   = '';
   $_SESSION['sql_sort_dir']   =
 $GLOBALS['g_default_sql_sort_dir'];
   $_SESSION['sql_sort_cat']   = $_GET['sort'];

   if (!empty( $_GET['dir'] ))
   {
   $sql_sort_dir = $_GET['dir'];
   }

   header_redirect_html(view_tracker.php);
 }

 ?

 =

 Cheers,
 Mun Heng, Ow
 H/M Engineering
 Western Digital M'sia
 DID : 03-7870 5168


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



RE: [PHP] $_GET['sort'] argument separator

2003-07-28 Thread Ow Mun Heng
It worked!!! Thanks VERY much. Now if someone could explain to me the
difference between urlencode and rawurlencode. In the manual, it states that
both are similar (but not the same), urlencode will encode spaces into '+'
wherelse rawurlencode does not.

Hence, in my below purposes, which should I be using?
snip
It would probably be better to pass the actual column names instead of 
the alias.
/snip

As for the above comment, I don't believe that I can as I'm actually using
the SQL statement to put the alias and getting the alias to be spitted out
using mysql_field_result.

But I'm open to how to make the code better.. ideas?..


Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: John W. Holmes [mailto:[EMAIL PROTECTED]
Sent: Monday, July 28, 2003 7:17 PM
To: Ow Mun Heng
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] $_GET['sort']  argument separator


Ow Mun Heng wrote:
 Hi,
 
   I have this problem, which could easily be solved through a name
 change but I would like to learn more.
 
 There's a table set up from a MySQL query like this
 
 row1) Eval #  Title   # Heads My Findings
 row2) P1000   Title16 This is my findings
 row3) P1223   Eg 2  3 2nd findings
 
 row1 is the header columns, the title names are derived from sql statement
 executed as SELECT eval_no as Eval # etc..
 
 row1 is also set up such that if the user clicks the link, it will trigger
a
 SQL comand to sort it.
 
 The problem here is the '#' sign/key. spaces are no problem. the
 $_GET['sort'] is not able to get the whole field, as such Eval # can
only
 be recognised as Eval and thus sql is not able to sort it.
[snip]
 This is how the link looks like

http://10.0.0.1/trackit/trackit-2003-07-28/view_set_tracker.php?sort=Eval%20
 #dir=ASC

The string with the # character needs to be run through urlencode() or 
rawurlencode(). The # character is making your browser look for a 
bookmark named dir=ASC on the view_set_tracker.php page.

It would probably be better to pass the actual column names instead of 
the alias.

-- 
---John Holmes...

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

PHP|Architect: A 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] I'm really getting annoyed with PHP

2003-07-24 Thread Ow Mun Heng
This is taken from mantis.. NOt sure if it'll help but take a look at the
t_use_iis field


function print_header_redirect( $p_url, $p_die=true ) {
$t_use_iis = config_get( 'use_iis');

if ( ON == config_get( 'stop_on_errors' )  error_handled()
) {
return false;
}

if ( OFF == $t_use_iis ) {
header( 'Status: 302' );
}
header( 'Content-Type: text/html' );
header( 'Pragma: no-cache' );
header( 'Expires: Fri, 01 Jan 1999 00:00:00 GMT' );
header( 'Cache-control: no-cache, no-cache=Set-Cookie,
private' );
if ( ON == $t_use_iis ) {
header( Refresh: 0;url=$p_url );
} else {
header( Location: $p_url );
}

if ( $p_die ) {
die; # additional output can cause problems so let's
just stop output here
}

return true;
}

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Beauford.2005 [mailto:[EMAIL PROTECTED]
Sent: Friday, July 25, 2003 6:13 AM
To: [EMAIL PROTECTED]; PHP
Subject: RE: [PHP] I'm really getting annoyed with PHP


FYI. I did this login page for another website last month and I used the
code from it to do this one. The other one works perfectly. I checked
that code again today and there is ABSOLUTELY no differnce. I even used
the same variables and session names. The only difference between the
two sites is that the one that works is running IIS on Windows 2000
Server. The broken one is on a Linux box running Apache. Both PHP and
MySQL are the same versions. Remember also that the Header redirect is
working in the redirect.inc page, which is even more confusing.

I have really given up on it. It just ain't gonna work - no matter what
I do. I thought I finally had it working again, but of course - another
f*** up.

Can you explain this? Along with my other code I used a little piece of
javascript to do the redirect, and lo and behold it worked. But now my
paths are all screwed up. I just don't get it.

In the example I tried, the page I am redirected to has a form on it.
When I click submit it should go to the page specified in the action,
which is season_write.php.

FORM onSubmit=return checkrequired(this) ACTION=season_write.php
action=post name=seasons

But for some reason it tries to go to /setup/season_write.php. This is
not specified anywhere in any of my code. So where the hell it getting
this from. 

The more I use PHP the more I am becoming convinced I should be using
something else. This is just ridiculous.

SCRIPT LANGUAGE=JavaScript
!-- Begin
window.location=? echo $_SESSION['goto']; ?;
// End --
/script

-Original Message-
From: Ray Hunter [mailto:[EMAIL PROTECTED] 
Sent: July 23, 2003 5:44 PM
To: Beauford.2005
Subject: Re: [PHP] I'm really getting annoyed with PHP


Questions:

1. What verion of php are you running?
2. What version of apache are you running? Or other web server? 3. What
is your configuration for php? check phpinfo() 4. Is php built from
source or a binary (rpm, exe)? 5. What OS are you running on and what
version?


--
BigDog



On Thu, 2003-07-24 at 13:41, Beauford.2005 wrote:
 Yes, I'm still screwing around with this stupid redirection thing, and

 either I'm just a total idiot or there are some serious problems with 
 PHP. I have now tried to do it another way and - yes - you guessed it.

 It does not work.
 
 I mean really, it can not be this hard to redirect a user to another 
 page. If it is, then I must look into using something else as I just 
 can't be wasting days and days on one minor detail that should take 30

 seconds to complete.
 
 If anyone has some concrete suggestion on how to get this to work It 
 would be greatly appreciated. In the mean time I have given up on it 
 as I am just totally pissed off at it.
 
 TIA
 
 


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



RE: [PHP] I'm really getting annoyed with PHP

2003-07-24 Thread Ow Mun Heng
This thread's too long. I'm getting confused on who exactly asked the
question..

My Take on thi 

/snip
what if the code logic requires that there is some output sent to the 
browser. 
/snip

In my case I use a Refresh-redirect. I've posted my code on this on this
thread. The way I'm doing it is like this.. (logic)

The header_refresh_html will redirect to home.php if user is already
logged in but not before issuing a warning to the user to logout before
logging in again.

The Error msg will be display WAY.. before the refresh/redirect takes place.
(2 seconds) Maybe if through the internet it's not so great,but on my
intranet, 2 secs is long enough for the user to view the message.

login.php
if ( check_if_authenticated() )
{
header_refresh_html(home.php);
trigger_error(ERROR_USER_ALREADY_AUTHENTICATED, WARNING);
exit;
}
else
{
//display login form/msg
}

=
Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Pushpinder Singh Garcha [mailto:[EMAIL PROTECTED]
Sent: Friday, July 25, 2003 2:10 AM
To: Curt Zirzow
Cc: PHP
Subject: Re: [PHP] I'm really getting annoyed with PHP


hello everyone,

Can somebody tell me why meta-refresh is not preferred to do re-directs 
?
I know Javascript is browser dependent, so its undependable.

using headers in php requires that no output is sent to the browser, 
what if the code logic requires that there is some output sent to the 
browser. I am sorry if this is a repeat question because someone 
earlier did mention abt output buffering as a way around.

TIA
--Pushpinder


On Thursday, July 24, 2003, at 12:11 PM, Curt Zirzow wrote:

 * Thus wrote Pushpinder Singh Garcha ([EMAIL PROTECTED]):
 try this,


 use a meta-refresh ...

 echo META HTTP-EQUIV=\refresh\
 content=\3;URL=http://wherever_u_wana_go.com/hello.html\;;

 This has already been discussed, and is not the preferred method of
 doing redirects. PHP can handle what he is doing just fine.



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

2003-07-23 Thread Ow Mun Heng
Hi,

I'm not sure if this is going to help or not.. Since I understand
your issue only barely.. If I understand correctly, regardless of whether
the user comes from a.php, b.php or z.php, if they're not authenticated on
the system (via sessions or cookies) then the only place for them to go is
login.php. RIGHT???

Here's my 2 cents. (part of code I'm working on)


=login.php===
if ( check_if_authenticated() )   --- I have this fucntion located at the
top of a.php,b.php,c.php
{
header_refresh_html(home.php);  --- Function call - back to
Home.php if logged in
exit;
}
else--- display login form is not already logged in
{
top_html(); 
display_welcome_msg_html();
}
==

===html_functions.php ==
# ===
# This is where I print headers to redirect pages
# Default wait time is 2 seconds
# NOTE : WE MUST PRINT THE REDIRECTION BEFORE WE OUTPUT ANYTHING!
#Just put the redirection BEFORE the outputs!
# ===
function header_refresh_html($l_refresh_url) --- the page to redirect to is
given as an argument
{
// This is taken from php-manual
header(Expires: Mon, 26 Jul 1997 05:00:00 GMT);
// Date in the past
header(Last-Modified:  . gmdate(D, d M Y H:i:s) .  GMT);  //
always modified
header(Cache-Control: no-store, no-cache, must-revalidate);   //
HTTP/1.1
header(Cache-Control: post-check=0, pre-check=0, false);
header(Pragma: no-cache);
// HTTP/1.0

header( Refresh:2;url=$l_refresh_url );   // Wait
default of 2 seconds
}

function header_redirect_html($l_redirect_url)
{
header( Location:$l_redirect_url);// Instant
Redirection
}

=




Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Beauford.2005 [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 24, 2003 8:55 AM
To: 'PHP'
Subject: RE: [PHP] Redirection Question


Thanks to all, I got it working - sort of. It works perfectly on
Windows, but will not work on Linux. I am using the same versions of
PHP, Apache and MySQL on both. I have asked this before and have been
told they are interchangeable, but more times than not I have to make a
bunch of changes to get it to work on Linux - and this is just another
example. I use Windows to do all the coding and design as it has all the
tools. Linux is just a bare bones box with no gui or tools. The php.ini
and httpd.conf are the same on both platforms (other than what is needed
for the specific platform). This makes it a real pain.

Oh well, back to my debugging.


-Original Message-
From: Curt Zirzow [mailto:[EMAIL PROTECTED] 
Sent: July 22, 2003 7:04 PM
To: PHP
Subject: Re: [PHP] Redirection Question


* Thus wrote Beauford.2005 ([EMAIL PROTECTED]):
 Maybe I didn't explain enough. What if they come from b.php or c.php. 
 How do I automatically log what page they tried to access. So hard 
 coding login.php?next=a.php would only work for one page.

Use the code that Grant Rutherford posted earlier, its the same concept
just a whole lot more flexible than mine. Not to mention a bit more
secured.

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] Some SESSION Vars not Registering

2003-07-23 Thread Ow Mun Heng
I'm new but.. aren't you also supposed to register the session??

My code ..

session_start();
session_register('username'); 
$_SESSION['username'] = $row['username'];
session_register('user_id');
$_SESSION['user_id'] = $row['user_id'];
session_register('access_level');
$_SESSION['access_level'] = $row['access_level'];



Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Jeff Stillwall [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 23, 2003 12:02 PM
To: Tom Rogers; Warren Vail
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Some SESSION Vars not Registering


Tom Rogers wrote:

 I am sure they do not but
 I just tried reading the docs and it is as clear as mud so its back to
 the suck it and see method

From the on-line docs, regarding $_SESSION (at
http://us3.php.net/manual/en/reserved.variables.php#reserved.variables.sessi
on):

This is a 'superglobal', or automatic global, variable. This simply means
that it is available in all scopes throughout a script. You don't need to do
a global $_SESSION; to access it within functions or methods, as you do with
$HTTP_SESSION_VARS.

So, this gets more perplexing.

I should also note that I did try to use the global keyword, and it didn't
help.  Also, I tried setting the $_SESSION variables in question to
something else ($_SESSION[fname] =  ) before calling the function.
Didn't help either.

I have just never had a problem with sessions before.  But I'm guessing it's
my code, as I can replicate the behavior on three different installations of
PHP/Apache.
-- 
Jeff Stillwall


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



RE: [PHP] Re: Redirection Question (I spoke to soon)

2003-07-23 Thread Ow Mun Heng
Hi Curt,

I'm confused..

quote
 With $_SESSION, there is no need to use the session_register(),
 session_unregister(), session_is_registered() functions. Session
 variables are accessible like any other variables. 
/quote

I'm using

session_start();
session_register('username');
$_SESSION['username'] = $row['username'];
session_register('user_id');
$_SESSION['user_id'] = $row['user_id'];
session_register('access_level');
$_SESSION['access_level'] = $row['access_level'];

and checking if user is authenticated using

if ( session_is_registered('user_id') ) 
{
return true;
}
else
{   
return false;
}


Am I in error? (I'm trying to code using register_globals=off)

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Curt Zirzow [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 23, 2003 12:20 PM
To: PHP
Subject: Re: [PHP] Re: Redirection Question (I spoke to soon)


* Thus wrote Beauford.2005 ([EMAIL PROTECTED]):
 Sorry all, apparently this doesn't work on either Windows or Linux.
 Again, I thought it was working and once I got farther along I see that
 it really wasn't. Basically what I get after I login is an empty screen.
 Here is what I have :
 
 This is the script that runs to see if the user is logged in.
 
 session_start();
 if(!$_SESSION['logged']) {  
 
   session_register('goto');
   $_SESSION['goto'] = http://; . $_SERVER['SERVER_NAME'] .
 $_SERVER['REQUEST_URI'];
 
   $url = http://www.mysite.org/login/login.php;;
   header(Location: $url); 
 }
 
 The above works and redirects me to the login page and has the right
 referring page as shown below.
 
 goto|s:59:http://www.mysite.org/setup/inputs.php;;
 
 This is in my login.php script. After I verify the user login is
 correct, this piece of code is executed.
 
   session_start();
 session_register('logged');
 session_register('user');  

You don't need those two lines, they are only needed if ini.register_globals
is on and you want the variables $logged and $user to automatically be
sessioned as:
  $_SESSION['logged'] 
  $_SESSION['user'] 

quote
 With $_SESSION, there is no need to use the session_register(),
 session_unregister(), session_is_registered() functions. Session
 variables are accessible like any other variables. 
/quote

I think this is were your problem is.

Also what php version?
quote CAUTION
If you are using $_SESSION and disable register_globals, do not use
session_register(), session_is_registered() and session_unregister(), if
your scripts shall work in PHP 4.2 and earlier. You can use these
functions in 4.3 and later. 
/quote


Hmm.. After looking at the session_* documentation there are CAUTIONS
all over the place..  The all seem to say dont use sesion_register,
unregister, and is_registered when your using $_SESSION;


 
 $_SESSION['logged'] = True;
 $_SESSION['user'] = $row['user'];
 
 $target = Location:  . $_SESSION['goto'];
 
 session_unregister('goto');

Use: unset($_SESSION['goto']);

 
 header($target);
what does echo($target) yeild?

 
 What I get after this is a blank page. The user has been logged in and
 shows in the session file, but it just isn't redirecting.
 

HTH,

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] Re: Redirection Question (I spoke to soon)

2003-07-23 Thread Ow Mun Heng
Thanks Mike.. You've been a GREAT help..

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Ford, Mike [LSS] [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 23, 2003 7:01 PM
To: Ow Mun Heng; PHP
Subject: RE: [PHP] Re: Redirection Question (I spoke to soon)


 -Original Message-
 From: Ow Mun Heng [mailto:[EMAIL PROTECTED]
 Sent: 23 July 2003 11:37
 
   I'm confused..
 
 quote
  With $_SESSION, there is no need to use the session_register(),
  session_unregister(), session_is_registered() functions. Session
  variables are accessible like any other variables. 
 /quote
 
   I'm using
 
 session_start();
 session_register('username');
 $_SESSION['username'] = $row['username'];
 session_register('user_id');
 $_SESSION['user_id'] = $row['user_id'];
 session_register('access_level');
 $_SESSION['access_level'] = $row['access_level'];
 
 and checking if user is authenticated using
 
 if ( session_is_registered('user_id') ) 
   {
   return true;
   }
   else
   {   
   return false;
   }
 
 
 Am I in error? (I'm trying to code using register_globals=off)

Yes.

If you use only the $_SESSION array to set/get the values of your session
variables, you do not need (and, in some versions of PHP, MUST NOT use)
session_register() or any of its friends.

The proper coding for what you are doing above is:

  session_start();
  $_SESSION['username'] = $row['username'];
  $_SESSION['user_id'] = $row['user_id'];
  $_SESSION['access_level'] = $row['access_level'];

and

  if (isset($_SESSION['user_id']) ) 
{
return true;
}
else
{   
return false;
}

(or even just

return isset($_SESSION['user_id']);

! ;)

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] Re: Redirection Question (I spoke to soon)

2003-07-23 Thread Ow Mun Heng
Are you outputting BLANK LINES???

eg.. if you have blank lines after your last ? (closing PHP tag) in
ANY one of the require/include/script files, you're outputting something and
this cannot be the case.

eg. if in VI

echo $someecho
function dosomethig()
{
// whatever
}
?
- THIS blank line will be regarded as Output. Hence You can't
redirect!
~   -- These sort of tidle marks are vi's way of saying.. no blank line
below this.
~
~
~
~
`

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Beauford.2005 [mailto:[EMAIL PROTECTED]
Sent: Friday, July 25, 2003 3:06 AM
To: [EMAIL PROTECTED]
Subject: RE: [PHP] Re: Redirection Question (I spoke to soon)


Errors are on and I get nothing, it won't even direct if I hard code
header(Location: www.microsoft.com);


-Original Message-
From: Jason Wong [mailto:[EMAIL PROTECTED] 
Sent: July 23, 2003 12:48 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Re: Redirection Question (I spoke to soon)


On Thursday 24 July 2003 11:37, Beauford.2005 wrote:

 I found one of my problems and also implemented your suggestions, and 
 still the same thing. It will not redirect.

 The problem I found is that $_SERVER['SERVER_NAME'] does not include 
 the port number. On my Win PC I am using port 800. So I changed this 
 line
 to:

 $_SESSION['goto'] = http://; . $_SERVER['SERVER_NAME'] .:800 . 
 $_SERVER['REQUEST_URI'];

 If I take the output from that and put it into my browser is works 
 just fine, but it will not work in the script.

[snip]

 header(Location:  . $_SESSION['goto']);

 If I echo $_SESSION['goto'] right after session_start() it shows 
 exactly what it should be. So I am at a loss.

Have you checked your error logs? You should always, ALWAYS have error 
reporting on full, and check for errors. It could be that you're getting
an 
headers already sent sent error.

Does it work if you have a single line script:

  header(Location: whatever_$_SESSION['goto']_is_supposed_to_be);


-- 
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
--
/*
But Officer, I stopped for the last one, and it was green!
*/


-- 
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] Howto list Mysql Table Headers using PHP

2003-07-20 Thread Ow Mun Heng
Hi,

Got a quick question.. How do I get the table headers also
printed/retrieved by PHP for 'echo'??

eg :
1   +--+--+-++
2   | Drive SN | HSA DCM  | Family  | Media Supplier |
3   +--+--+-++
4   | WMACK001 | GD223213JHHS | PIONEER | KOMAG  |
5   | WMACK002 | GH37489284HH | PIONEER | FUJI   |
6   | WMACK003 | F023213JHHS  | XBOX| KOMAG  |
7   | WMACK004 | FV23213JHHS  | XBOX||
8   +--+--+-++

The coding can get rows 4-7 printed out but I would like to get row2 printed
out as well. The table's all set up for it already.

I'm using 

$result = mysql_query($sql);
$num_results = mysql_num_rows($result);
for ($i = 0; $i  $num_results ; $i++)
{
echo tr\n  ;
$row = mysql_fetch_row($result);
for ($j = 0; $j  sizeof($row) ; $j++)
{
echo \t . 'td'; 
echo  $row[$j] ;
echo /td \n;
}
echo /tr\n;
}


Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


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



RE: [PHP] Howto list Mysql Table Headers using PHP

2003-07-20 Thread Ow Mun Heng
Whoops.. Missed that..

Thanks.. ( sorry..)

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: John W. Holmes [mailto:[EMAIL PROTECTED]
Sent: Monday, July 21, 2003 9:45 AM
To: Ow Mun Heng
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Howto list Mysql Table Headers using PHP


Ow Mun Heng wrote:

 Hi,
 
   Got a quick question.. How do I get the table headers also
 printed/retrieved by PHP for 'echo'??

mysql_field_name()

Next time, check the manual. :)

-- 
---John Holmes...

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

PHP|Architect: A 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] redirecting to a url..

2003-07-20 Thread Ow Mun Heng
Me, 

I have 2 functions. 1 I call - immediate and other refresh.. the
difference is one as the name implies is immediate - (like chris pointed out
below ) - 

header('Location: http://yoursite.org/us/index.php');

The other is more of a refresh kind, waits a default of 2 secs (for me so
that I can show a warning message before it redirects..

function header_refresh_html($l_refresh_url)
{
// This is taken from php-manual
header(Expires: Mon, 26 Jul 1997 05:00:00 GMT);
// Date in the past
header(Last-Modified:  . gmdate(D, d M Y H:i:s) .  GMT);  //
always modified
header(Cache-Control: no-store, no-cache, must-revalidate);   //
HTTP/1.1
header(Cache-Control: post-check=0, pre-check=0, false);
header(Pragma: no-cache);
// HTTP/1.0
header( Refresh:2;url=$l_refresh_url );   // Wait
default of 2 seconds
}
Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Chris Shiflett [mailto:[EMAIL PROTECTED]
Sent: Friday, July 18, 2003 11:46 PM
To: Louie Miranda; [EMAIL PROTECTED]
Subject: Re: [PHP] redirecting to a url..


--- Louie Miranda [EMAIL PROTECTED] wrote:
 echo meta http-equiv=\REFRESH\ CONTENT=\0; URL=us/index.php\;
 
 Or you may have other more advance alternatives?

You can use a protocol redirect rather than relying on HTML:

header('Location: http://yoursite.org/us/index.php');

Chris

=
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/

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



[PHP] RE: Something to watch look for when getting HEADER Warnings

2003-07-20 Thread Ow Mun Heng
Been There.. 

Was a REAL pain to figure that out one.. 

Have a look through PhpMyAdmin's (source) scripts, I see there's a bash
shell code that actually searches through some of it's php files for
sanitation for the exact same purpose. (Haven't played with it yet though)

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: John Manko [mailto:[EMAIL PROTECTED]
Sent: Saturday, July 19, 2003 12:49 PM
Cc: [EMAIL PROTECTED]
Subject: Something to watch look for when getting HEADER Warnings


Recently, I ran into a problem where I continually got a Header already 
sent message.
I took me a while to figure out because the file that was included 
only contained function definitions, or so I thought.
After the closing php tag, I had a new line with a single space on it.  
This space was, in turn, sent to the browser.

 file.php begin (blah, not working) -
?php
function seomthing()
{ //do something
}
?[enter]
[space]
 file.php end --

It wasn't until I removed the single space and any additional newlines 
that all worked fine.
Any non-null lines outside of the php tags will results in voiding all
rights to send any header or cache information, and this includes
space or newline characters.
Just an FYI.

 file.php begin (cool, it works now) -
?php
function seomthing()
{ //do something
}
?[no newline]
 file.php end --

Actually, you can have a newline after the clsoing php tab, but if you 
have a
non-null string following that (this includes newline characters), bad 
bad stuff can happen.




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



RE: [PHP] Too much of $GLOBALS[] a problem??

2003-07-18 Thread Ow Mun Heng
Very Well Explained.. now I know how to use the code which I saw in
phpMyAdmin or Tiki.. Much better way to do it and a lot less conflicts to as
you say,variable names.

Thanks.

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Lars Torben Wilson [mailto:[EMAIL PROTECTED]
Sent: Friday, July 18, 2003 12:26 PM
To: Ow Mun Heng
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP] Too much of $GLOBALS[] a problem??


On Thu, 2003-07-17 at 21:10, Ow Mun Heng wrote:
  'Loosely-coupled' code relied much less on the environment around it.
  It would typically receive its values through an argument list, array
  of values it needs, or perhaps by being a method in a class which has
  attribute values for all of the necessary stuff.
 
 The $GLOBALS['parameter'] is actually defined in ONE(a config file that
 houses all the parameters and another a language file) place where it can
be
 changed. So, i would say that's an argument list, is it not?

No, it's a configuration file. An argument list is the bit between the 
parentheses when you write a function call:

   $retval = some_func($this, $is, $the, $argument, $list);

If your config file had all of those variables in an array or something,
and you passed that array to your function, *that* would be an argument
list.

See below:

config.php:
?php
$config = array('logout' = 1,
'overall_summary' = 'Here is the summary',
etc);
?

script.php:
?php
include('config.php');
display_menu_html($config);
?

Problem solved. The only thing left which can conflict is the name
$config, and you could solve that by calling it something you're sure
nobody else will be using (maybe $_omh_config or something). Now, you
can lift your config file and display_menu_html() function and drop
them into pretty much any script and be much more sure that you won't
have to crawl through all the code making sure there are no variable
name conflicts.

 The other way would be to write a function that obtains that from the
 argument list. But as I see it, it's basically the same thing? NO?

No, because say you want to use this function in another script. First
you need to make sure that this new script isn't already using any
globals with any of the names you want to use--otherwise, you'll have
variable clashes--where you expect one thing to be in $logout, for
instance, but the script is using the name $logout for something else,
and the value isn't what you expect. 

 Class.. That's not somewhere I would want to venture, not right now
anyway.
 Just starting out.
 
 Cheers,
 Mun Heng, Ow
 H/M Engineering
 Western Digital M'sia 
 DID : 03-7870 5168

There was a discussion on this list about programming practices and 
books about programming--I think last week or the week before. Try a
search on the archives. Anyway, there are lot of great books on
programming which should help--and excellent and easy-to-read book which
covers a lot of things which you *don't* want to have to figure out
yourself is 'Code Complete', by Steve McConnell.


-- 
 Torben Wilson [EMAIL PROTECTED]+1.604.709.0506
 http://www.thebuttlesschaps.com  http://www.inflatableeye.com
 http://www.hybrid17.com  http://www.themainonmain.com
 - Boycott Starbucks!  http://www.haidabuckscafe.com -




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



[PHP] Too much of $GLOBALS[] a problem??

2003-07-17 Thread Ow Mun Heng
Hi All,

Just a quick question on this. In my scripts, I'm using A LOT Of
$GLOBALS['my_parameter'] to get the declared values/string. 1 example  below
:

function display_menu_html()
{
echo 'table class=width100 cellspacing=0'.\n;
echo 'tr'.\n;
echo \t.'td class=menu'.\n;
echo \t.'a href=home.php' . $GLOBALS['home'] . /a
nbsp|\n;
echo \t.'a href=view_tracker.php' . $GLOBALS['view_tracker'] .
/a nbsp|\n;
echo \t.'a href=initialise_fa.php' . $GLOBALS['initialise_fa']
. /a nbsp|\n;
echo \t.'a href=mass_initialiase_fa.php' .
$GLOBALS['mass_initialiase_fa'] . /a nbsp|\n;
echo \t.'a href=Summary.php' . $GLOBALS['overall_summary'] .
/a nbsp|\n;
echo \t.'a href=account.php' . $GLOBALS['edit_account'] .
/a nbsp|\n;
echo \t.'a href=logout.php' . $GLOBALS['logout'] . /a
nbsp|\n;
echo \t/td\n;
echo \t.'td class=right style=white-space: nowrap'.\n; 
echo \t.'form input=post action=jump_to_fa.php'.\n;
echo \t.'input type=text name=fa_id size=12
class=bold-small /'.\n;
echo \t.'input type=submit value=' . $GLOBALS['goto_fa'] . '
class=small / '.\n;
echo /form\n;
echo \t/td\n;
echo /tr\n;
echo /table\n;

 
}

This isn't really a Problem but.. is it bad programming practice?? Or I
should just write another function that can return the values/string?

Any thots?

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168

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



RE: [PHP] Too much of $GLOBALS[] a problem??

2003-07-17 Thread Ow Mun Heng
 'Loosely-coupled' code relied much less on the environment around it.
 It would typically receive its values through an argument list, array
 of values it needs, or perhaps by being a method in a class which has
 attribute values for all of the necessary stuff.

The $GLOBALS['parameter'] is actually defined in ONE(a config file that
houses all the parameters and another a language file) place where it can be
changed. So, i would say that's an argument list, is it not?

The other way would be to write a function that obtains that from the
argument list. But as I see it, it's basically the same thing? NO?

Class.. That's not somewhere I would want to venture, not right now anyway.
Just starting out.

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Lars Torben Wilson [mailto:[EMAIL PROTECTED]
Sent: Friday, July 18, 2003 12:05 PM
To: Ow Mun Heng
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Too much of $GLOBALS[] a problem??


On Thu, 2003-07-17 at 18:35, Ow Mun Heng wrote:
 Hi All,
 
   Just a quick question on this. In my scripts, I'm using A LOT Of
 $GLOBALS['my_parameter'] to get the declared values/string. 1 example
below
 :

The only real problem is if you ever want to use that code in anything
else. Using lots of globals will make that harder, since it will mean
that you cannot simply lift that function out and drop it into some
other chunk of code without making sure that the new global space
contains all those globals, and that they contain what you expect.

This is called 'tightly-coupled' code. It's just harder to reuse.

Other than that, it's not a huge issue.


-- 
 Torben Wilson [EMAIL PROTECTED]+1.604.709.0506
 http://www.thebuttlesschaps.com  http://www.inflatableeye.com
 http://www.hybrid17.com  http://www.themainonmain.com
 - Boycott Starbucks!  http://www.haidabuckscafe.com -




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



RE: [PHP] Grabbing info from other Sites

2003-07-15 Thread Ow Mun Heng
Thanks for the info. It's a lot to digest for someone's who's just starting
out. I always thought Pear was only a Fruit.. now I know better.

I'll look through it and IF ( that's a big IF) i come up with
something, of course I'll share it.

Open Source all the way...

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Joel Rees [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 15, 2003 4:36 PM
To: Ow Mun Heng; [EMAIL PROTECTED]
Subject: Re: [PHP] Grabbing info from other Sites


  The site really does
 need Login.

 The thing is this, I'm developing for an internal site, (My dept) but I
need
 to access other dept's site to get info but unfortunately They won't give
me
 access to query the db directly. Prefering me to go through the site and
 input accordingly to grab the data. 

   I just find this to be SO troublesome as I need to get this data
 for every week. Week In.. Week Out and for a lot of items..

Screen scraping for fun and profit! Anything you can type into a form in
a web browser, you can throw at the server with a program (if you have
enough time to write the program).

In perl, there are LWP::UserAgent, HTTP::Request, HTTP::Cookies,
HTTP::Response, URI, etc.

In php, I don't see anything right offhand. But, there's always Pear,
which is becoming php's CPAN, and pear has at least these two:

http://www.pear.php.net/package-info.php?package=HTTP_Request
http://www.pear.php.net/package-info.php?package=HTTP_Client

and they look somewhat promising.

You'll probably need ssl related classes for the https stuff; it looks
like there's some support in Pear's encryption stuff. I'm sure the php
community would appreciate it if you would build and share anything
that's missing. ;-

   But I will take a look at SNOOPY. (hey.. isn't the name snoopy
 copyrighted??)

Trademarked, but only in relation to a cartoon character of a beagle and
products based on the character, I think.

-- 
Joel Rees, programmer, Kansai Systems Group
Altech Corporation (Alpsgiken), Osaka, Japan
http://www.alpsgiken.co.jp


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



RE: [PHP] Grabbing info from other Sites

2003-07-14 Thread Ow Mun Heng
Hi,

Mind my ignorance but what is webservices??

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Monday, July 14, 2003 3:28 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Grabbing info from other Sites


Hello
The only way I can imageine is using curl and doing standard post get 
requests. But this will put you at the mercy of the other dep. since a 
change in design may force a change in your logic. 
If you can, try to build a separate interface for your app which you can 
use to interface the backend of the other deps. You might even consider 
Webservices. This way you are independend of the design of the site.


Regards
Stefan Langer


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



[PHP] Grabbing info from other Sites

2003-07-13 Thread Ow Mun Heng
Hi,

I have this need/want to grab information from sites for my own
usage and wondering how to do it.

Here's an example.

1. Log into finance.yahoo.com (assuming I need to log on)
2. Type the list of shares I want
3. Let Yahoo process it 
4. Use PHP or some other scripting language to pull the data and put it into
my database.

Is this possible at all?



Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Sent: Sunday, July 13, 2003 10:58 PM
To: [EMAIL PROTECTED]
Subject: php-general Digest 13 Jul 2003 14:58:27 - Issue 2173



php-general Digest 13 Jul 2003 14:58:27 - Issue 2173

Topics (messages 154985 through 155003):

Re: touch file on shared web server?
154985 by: Paul O'Neil
154991 by: Jason Wong

Re: Code and Good Design Methods
154986 by: zbranigan
154987 by: zbranigan
154988 by: Dan J. Rychlik
154994 by: Ray Hunter
154995 by: Robert Cummings

Re: OK, So I am new to these List. Win2000 help!
154989 by: John Nichel
155002 by: John Nichel

Re: Newbie Directory question
154990 by: olinux

Re: Mailing list server with PHP frontend
154992 by: Juan Nin
154993 by: Manuel Lemos
154996 by: Paul Chvostek

How does PHP interact when using Java?
154997 by: Jan Bro

Weird Date problem driving me crazy...
154998 by: Boaz Yahav

php script billing receipt
154999 by: Duncan

Re: Need PHP on Win2000 Pro
155000 by: Burhan Khalid
155001 by: John A. Thomason

Re: dump $_POST into variables
155003 by: Marek Kilimajer

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]


--

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



RE: [PHP] Grabbing info from other Sites

2003-07-13 Thread Ow Mun Heng
Hi,

Unfortunately, Yahoo.com is just an example.. The site really does
need Login.

The thing is this, I'm developing for an internal site, (My dept) but I need
to access other dept's site to get info but unfortunately They won't give me
access to query the db directly. Prefering me to go through the site and
input accordingly to grab the data. 

I just find this to be SO troublesome as I need to get this data
for every week. Week In.. Week Out and for a lot of items..

But I will take a look at SNOOPY. (hey.. isn't the name snoopy
copyrighted??)

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Michael Geier [mailto:[EMAIL PROTECTED]
Sent: Monday, July 14, 2003 9:47 AM
To: Ow Mun Heng
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Grabbing info from other Sites


assuming the login isn't necessary (which it probably is), you could use 
something like Snoopy (http://sourceforge.net/projects/snoopy/) to POST/GET
the 
required web page and process as required.

Quoting Ow Mun Heng [EMAIL PROTECTED]:

 Hi,
 
   I have this need/want to grab information from sites for my own
 usage and wondering how to do it.
 
   Here's an example.
 
 1. Log into finance.yahoo.com (assuming I need to log on)
 2. Type the list of shares I want
 3. Let Yahoo process it 
 4. Use PHP or some other scripting language to pull the data and put it
into
 my database.
 
 Is this possible at all?
 
 
 
 Cheers,
 Mun Heng, Ow
 H/M Engineering
 Western Digital M'sia 
 DID : 03-7870 5168
 
 
 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED]
 Sent: Sunday, July 13, 2003 10:58 PM
 To: [EMAIL PROTECTED]
 Subject: php-general Digest 13 Jul 2003 14:58:27 - Issue 2173
 
 
 
 php-general Digest 13 Jul 2003 14:58:27 - Issue 2173
 
 Topics (messages 154985 through 155003):
 
 Re: touch file on shared web server?
   154985 by: Paul O'Neil
   154991 by: Jason Wong
 
 Re: Code and Good Design Methods
   154986 by: zbranigan
   154987 by: zbranigan
   154988 by: Dan J. Rychlik
   154994 by: Ray Hunter
   154995 by: Robert Cummings
 
 Re: OK, So I am new to these List. Win2000 help!
   154989 by: John Nichel
   155002 by: John Nichel
 
 Re: Newbie Directory question
   154990 by: olinux
 
 Re: Mailing list server with PHP frontend
   154992 by: Juan Nin
   154993 by: Manuel Lemos
   154996 by: Paul Chvostek
 
 How does PHP interact when using Java?
   154997 by: Jan Bro
 
 Weird Date problem driving me crazy...
   154998 by: Boaz Yahav
 
 php script billing receipt
   154999 by: Duncan
 
 Re: Need PHP on Win2000 Pro
   155000 by: Burhan Khalid
   155001 by: John A. Thomason
 
 Re: dump $_POST into variables
   155003 by: Marek Kilimajer
 
 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]
 
 
 --
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


===
Michael Geier
CDM Sports, Inc. Systems Administration
   email: [EMAIL PROTECTED]
   phone: 314.692.3540

---
 This email sent using CDM Sports Webmail v3.1
  [ http://webmail.cdmsports.com ]

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



[PHP] RE: Blatant newbie question - killing a session

2003-07-10 Thread Ow Mun Heng
session_destroy()??

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Bruce Bruen [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 10, 2003 2:48 PM
To: [EMAIL PROTECTED]
Subject: Blatant newbie question - killing a session


Hi, this is my first question to the list and ... Yes I'm a newbie,
verrry wet behind the ears.

I am trying to set up a secured site under IIS.  I have done pretty well
by my standard to get to where I have.  Authoursed users can access the
site, unauthorised ones get sent elsewhere.  So, I am now up to testing
the various security combinations and its driving me mad that the
session persists when I'm testing bad logins.

How or where does one set up a session extuinguisher?  After one two
or n attempts I want to kill the entire session and start afresh - note
this is in testig only, the way it works now is great for live.

Tia
Bruce


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



RE: [PHP] download php

2003-07-10 Thread Ow Mun Heng
I'm not sure about FreeBSD but on Redhat, the /etc/passwd 'IS' meant to be
world readable. But fortunately it's only stores usernames and Real names
and etc.. whereas /etc/shadow is only root readable and it's the file that
stores user's passwords.

I think that's pretty secure.

Why are you parsing through /etc/passwd anyway?

Anyway, I might have gotten your question wrongly or something. I still need
to figure out how to JAIL apache or 'ensure that you put files like
/etc/passwd OUTSIDE your web root.' That;s something which I've not know how
to do YET.

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Daniel J. Rychlik [mailto:[EMAIL PROTECTED]
Sent: Friday, July 11, 2003 1:46 AM
To: Marek Kilimajer; Mantas Kriauciunas
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] download php


You should also store passwords in a non-readable to the world directory.  

-Dan

- Original Message - 
From: Marek Kilimajer [EMAIL PROTECTED]
To: Mantas Kriauciunas [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Thursday, July 10, 2003 5:01 AM
Subject: Re: [PHP] download php


 Do you use secure connection? Well, you should.
 
 Mantas Kriauciunas wrote:
 
  Hello php-general,
  
some hacker just tries his luck everyday to get me pissed, is it
possible to make php files not downloadable? or coded? or something?
because some dude knows my passwords every time, and with them
passes the shity security to main user, thank god not root.
  
So is there any way?
  
if anyone knows any links or resources, please reply, i'll check
them, i need to put this to end
  
P.S system is freebsd.
  
Thank you!!!
  
there are even more and more kids that want to be named haker,
lookin at their age, could be even my son:)
  
 
 
 -- 
 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] New to PHP

2003-07-09 Thread Ow Mun Heng
This is Way Kewl... I'm a part of a team!

Long Live Open Source..

I believe that if it were closed sourced, I would need a least 2x the amount
of time to learn how to code for someone not from an IT/Programming
background.



Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Ralph Guzman [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 10, 2003 3:23 AM
To: Ow Mun Heng; 'PHP'
Subject: RE: [PHP] New to PHP


Yes, and also the same Rasmus founder of PHP. From time to time he may
even respond to one of you questions. :-)

And you're right one of the best ways to learn is to look at other open
source code. I've learned how to write efficient code and also learned
programming tricks by studying other code.

Welcome to the team,

-Original Message-
From: Ow Mun Heng [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 08, 2003 7:52 PM
To: PHP
Subject: RE: [PHP] New to PHP

Wow.. There's a guy named Rasmus here. Is here(or u) the same person who
wrote that book? this is way cool..

Oh.. BTW, PHP  Mysql Web Development is GOOD.

Also, since a lot of codes are open sourced, Read through them as well.
I'm
learning through that too. ( this list)

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Ralph [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 08, 2003 9:01 AM
To: 'Hiren Mehta'; 'PHP'
Subject: RE: [PHP] New to PHP


Here are some sites for you to get started:

http://www.zend.com/developers.php
http://www.phpcomplete.com/tutorials.php
http://www.evilwalrus.com/articles.php

And for books, here are some excellent books I've come across:

Programming PHP
By Rasmus Lerdorf

Web Application Development with PHP 4.0
by Tobias Ratschiller

Professional PHP4 Programming
By Deepak Thomas





-Original Message-
From: Hiren Mehta [mailto:[EMAIL PROTECTED] 
Sent: Monday, July 07, 2003 2:28 PM
To: PHP
Subject: [PHP] New to PHP

Hi I am new to PHP and would like to learn more about it. Which would be
the best place to start with besides the manual and what would you
suggest is a pre-requiste for learning PHP.

Thanks

Regards,

Hiren



-- 
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] include/require inside of function

2003-07-09 Thread Ow Mun Heng
Hi Mike,

I realise that last night. I'm now using $GLOBALS['page_title']

In what situation would create_global() be useful then?

Thanks.

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Ford, Mike [LSS] [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 09, 2003 6:20 PM
To: Ow Mun Heng; Ford, Mike [LSS]
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP] include/require inside of function


 -Original Message-
 From: Ow Mun Heng [mailto:[EMAIL PROTECTED]
 Sent: 09 July 2003 03:44
 
   I finally got it. Thanks. All I needed to do was just 
 define global
 $page_title inside the function to denote that I wanted to use that
 variable.
 
 One other quick question, in my original code (per below) the function
 create_global() was used to create_globals on demand. But 
 this involved a
 lot of jumping, from one function to another just to create 
 the globals on
 demand. Is this efficient (more?? less??) compared to just 
 stating global
 $page_title inside the function?

I don't think create_global() is of any use to you in this situation --
you're just wasting the time taken to do the function call and return. Just
do either:

 function org_display_title_code()
 {
global $page_title;
 
echo 'This is title1 - ' . $page_title;
 }

Or:
 
 function org_display_title_code()
 {
echo 'This is title1 - ' . $GLOBALS['page_title'];
 }

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] include/require inside of function

2003-07-08 Thread Ow Mun Heng
Hi Mike,

Here's the thing.. I declared $page_title = My Page Title in a
file called config.php which is included in the index.php page. when I tried
to - echo $page_title - Nothing comes out. 

If I declared it as global $page_title , then My Page Title would
be echoed out.

That I think is the simplest way to explain it.

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Ford, Mike [LSS] [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 08, 2003 7:11 PM
To: Ow Mun Heng
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP] include/require inside of function


 -Original Message-
 From: Ow Mun Heng [mailto:[EMAIL PROTECTED]
 Sent: 07 July 2003 04:34
 
   Here's My question, a variable is not actually global is not
 actually global until I make it global through global 
 $make_this_global
 and then I can assess it using $GLOBAL[$make_this_global].

Not correct.

Variables used in the global scope are global, and appear in the $GLOBALS
array as soon as they come into existence.  A global statement is used
within a function merely to declare that you wish to use one of those
variables in that function, where it would otherwise not be available.  It's
sort of equivalent to saying when I use variable $x in this function, I
actually want it to be $GLOBALS['x'] -- or, in PHP terms, $x =
$GLOBALS['x'].
 
 
   Another method would be to globalise it on demand by writing a
 little function. (like Rasmus)
 
 I did it like this -- 
 
 
 ---create_globals.php
 function create_global($passed_variable)
 if (isset ($GLOBALS[$passed_variable]))
 {
   return $GLOBALS[$passed_variable];
 }
 ---end-
 
 config.php--
 $page_title = Page Title of Web Page
 -end
 
 --index.html
 require_once ('create_globals.php');
 
 $local_variable = create_global( 'main_title')
 echo My Page Title is.$local_variable;
 --end-
 
 
 Hence This way I can make it global-on-demand. 
 
 Maybe a better way to do it would be to 
 
 ---config.php---
 global $page_title = Alternative Way
 end-

I'm really not sure what you're getting at here, but I think it may be based
on a misunderstanding.  If you could explain exactly what it is you're
trying to do, someone might be able to offer some better help.

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] include/require inside of function

2003-07-08 Thread Ow Mun Heng
Hi Mike,

I finally got it. Thanks. All I needed to do was just define global
$page_title inside the function to denote that I wanted to use that
variable.

One other quick question, in my original code (per below) the function
create_global() was used to create_globals on demand. But this involved a
lot of jumping, from one function to another just to create the globals on
demand. Is this efficient (more?? less??) compared to just stating global
$page_title inside the function?


Please enlighten me.


---config---
$page_title = Main Page Title;
--

---functions-
function display_title()
{
global $page_title;   This was what I missed
echo $page_title;
}

function org_display_title_code()  --- That was what I used originally
{
$l_main_title = create_globals( 'page_title' );

echo 'This is (create global) title1 - ' . $l_main_title  ;
}

function create_globals( $passed_option )
{
if ( isset( $GLOBALS[$passed_option] ) )
{
return  $GLOBALS[$passed_option];
}
}

---

--index.php--
?php
display_title();
?



Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Ford, Mike [LSS] [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 08, 2003 11:34 PM
To: Ow Mun Heng
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP] include/require inside of function


 -Original Message-
 From: Ow Mun Heng [mailto:[EMAIL PROTECTED]
 Sent: 08 July 2003 15:53
 
   Here's the thing.. I declared $page_title = My Page Title in a
 file called config.php which is included in the index.php 
 page. when I tried
 to - echo $page_title - Nothing comes out. 
 
   If I declared it as global $page_title , then My Page 
 Title would
 be echoed out.

And is the assignment in the included file inside a function?  If so, the
usual rules about variables within functions apply.  If not, please post the
relevant code from both files so we can try to figure out your problem.

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] New to PHP

2003-07-08 Thread Ow Mun Heng
Wow.. There's a guy named Rasmus here. Is here(or u) the same person who
wrote that book? this is way cool..

Oh.. BTW, PHP  Mysql Web Development is GOOD.

Also, since a lot of codes are open sourced, Read through them as well. I'm
learning through that too. ( this list)

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Ralph [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 08, 2003 9:01 AM
To: 'Hiren Mehta'; 'PHP'
Subject: RE: [PHP] New to PHP


Here are some sites for you to get started:

http://www.zend.com/developers.php
http://www.phpcomplete.com/tutorials.php
http://www.evilwalrus.com/articles.php

And for books, here are some excellent books I've come across:

Programming PHP
By Rasmus Lerdorf

Web Application Development with PHP 4.0
by Tobias Ratschiller

Professional PHP4 Programming
By Deepak Thomas





-Original Message-
From: Hiren Mehta [mailto:[EMAIL PROTECTED] 
Sent: Monday, July 07, 2003 2:28 PM
To: PHP
Subject: [PHP] New to PHP

Hi I am new to PHP and would like to learn more about it. Which would be
the best place to start with besides the manual and what would you
suggest is a pre-requiste for learning PHP.

Thanks

Regards,

Hiren



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



RE: [PHP] include/require inside of function

2003-07-06 Thread Ow Mun Heng
Hmm..

Funny I was having this same problem yesterday and wanted to post.

Here's My question, a variable is not actually global is not
actually global until I make it global through global $make_this_global
and then I can assess it using $GLOBAL[$make_this_global]. 

Another method would be to globalise it on demand by writing a
little function. (like Rasmus)

I did it like this -- 


---create_globals.php
function create_global($passed_variable)
if (isset ($GLOBALS[$passed_variable]))
{
return $GLOBALS[$passed_variable];
}
---end-

config.php--
$page_title = Page Title of Web Page
-end

--index.html
require_once ('create_globals.php');

$local_variable = create_global( 'main_title')
echo My Page Title is.$local_variable;
--end-


Hence This way I can make it global-on-demand. 

Maybe a better way to do it would be to 

---config.php---
global $page_title = Alternative Way
end-

then I can -echo This is an .$page_title; and it'll come out as - This
is an alternative way

The only problem here would be the EXTRA typing involved. The other
problem/question is, will there be a speed tradeoff? If I were to global'ise
everything at the 1st place, would it be faster than jumping in and out of
create_global() and going through $page_title  whatever other variables? (I
want to make all global configurations in this file so it'll be easy to
change)

Any help is appreciated.


Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Greg Beaver [mailto:[EMAIL PROTECTED]
Sent: Saturday, July 05, 2003 12:39 AM
To: Rasmus Lerdorf
Cc: Aric Caley; [EMAIL PROTECTED]
Subject: Re: [PHP] include/require inside of function


Hi,

If the file you are including is of your own authorage (I know that 
isn't a word, but whatever :), just refer to global variables always as 
an index of the $GLOBALS array.  This is good practice anyways for any 
file that might be included by another user, for exactly this issue.

I have a file that could be a global include or not in my project, and 
making sure every global variable is referenced as $GLOBALS['varname'] 
fixed it for me without any fancy code (although Rasmus's code is very nice)

Regards,
Greg
--
phpDocumentor
http://www.phpdoc.org

Rasmus Lerdorf wrote:
 On Fri, 4 Jul 2003, Aric Caley wrote:
 
Is there anyway to include a file inside of a function and have the
included
stuff be global?  For instance if I defined a class or a function in that
include file, I want to be able to use that class outside of the function.

On the documentation for include() a poster commented that it did indeed
work like this, but my testing indicates it does not.  Everything stays
local to the function and goes away when the function ends.

Is there a way?
 
 
 Functions defined in included files are always global.  So I guess it is
 just the variable you want to put out into the global symbol table.  It's
 a little bit tricky, but you can do it like this:
 
 function foo($filename) {
 extract($GLOBALS, EXTR_REFS);
 include $filename;
 $arr = array_diff(get_defined_vars(),$GLOBALS);
 foreach($arr as $var=$val) $GLOBALS[$var] = $val;
 }
 
 -Rasmus



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



RE: [PHP] Re: Red Hat 9, Apache 2, and PHP

2003-07-04 Thread Ow Mun Heng
Does anyone have any idea or could give me an idea why php  apache 2.0 is
not 'good' together?



Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Mark Charette [mailto:[EMAIL PROTECTED]
Sent: Friday, July 04, 2003 9:02 AM
To: [EMAIL PROTECTED]; Shena Delian O'Brien
Subject: Re: [PHP] Re: Red Hat 9, Apache 2, and PHP


Apache 2.x.x IS a production quality server, just not with PHP. Works great
with Tomcat, mod_jk2, Struts, etc.

- Original Message - 
From: Shena Delian O'Brien [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, July 03, 2003 8:04 PM
Subject: Re: [PHP] Re: Red Hat 9, Apache 2, and PHP


 Does anyone know why Red Hat would switch to Apache 2.x.x when it is
 well known that 2.x.x is NOT a production version?

 Brad Pauly wrote:
  Just thought I would share my experience with RH9. I have been running
  Apache 1.3.27 and PHP 4.3.2 on RH9 for a couple weeks (since 4.3.2 came
  out anyway, and 4.3.1 prior to that) on a test server. All are compiled
  from source. The only problem I have had was a bug with the version of
  mogrify that is bundled with RH9. That was fixed by 'upgrading' to an
  older version. Other than that it has been fine.
 
  Brad
 
 
 
 


 -- 
 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] Re: Red Hat 9, Apache 2, and PHP

2003-07-04 Thread Ow Mun Heng
Thanks for the Explanation. I guess I need to take another look at apache or
try to get apache 1 installed for my server.

I'm currently trying to get linux+apache+mysql+php up. (If i can ever figure
out how to properly design my database)


Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]
Sent: Friday, July 04, 2003 2:48 PM
To: Ow Mun Heng
Cc: Mark Charette; [EMAIL PROTECTED]; Shena Delian O'Brien
Subject: RE: [PHP] Re: Red Hat 9, Apache 2, and PHP


Apache2 has a number of different modes it can work in.  These modes are
called MPM's.  The default MPM is called Worker which is a multithreaded
model.  PHP, mod_perl, mod_python, and any other similar technology which
links directly into the httpd processes will need to be perfectly
threadsafe and reentrant to work effectively with a threaded Apache2 mpm.
This is doable for the core of PHP, but there are literally hundreds of
3rd party libraries that can be linked into PHP and nobody whether or not
these libraries are threadsafe.  And figuring out if a specific library is
threadsafe or not is non-trivial and it can very from one platform to
another.  And just to make it even harder, this stuff will appear to work
fine until you put it under load or hit very specific race conditions
which makes it nearly impossible to debug.

So, since we can't tell you for sure that a threaded Apache2 mpm + PHP
will work we do not suggest you use it for a production server.  And since
we can't know for sure, none of the main PHP developers use this
combination for our own servers which compounds the problem because it is
not receiving anywhere near the amount of realworld testing required to
work out all the little issues above and beyond this threading unknown.

There is an Apache2 mpm, called prefork, which isn't threaded and
basically makes Apache2 look like Apache1.  But hey, we have a very good
server already that looks like Apache1.

In the end I don't see Apache2+PHP ever becoming a production platform
with the current architecture.  The only way I see it ever working is to
pull PHP out of Apache and use a fastcgi approach.  Or, with time, perhaps
we will learn how to make sure a library is perfectly threadsafe and safe
to use in a multithreaded Apache2.

For now, I really see no reason not to simply use Apache1 if you want a
robust, fast and stable web server.

-Rasmus

On Fri, 4 Jul 2003, Ow Mun Heng wrote:

 Does anyone have any idea or could give me an idea why php  apache 2.0 is
 not 'good' together?



 Cheers,
 Mun Heng, Ow
 H/M Engineering
 Western Digital M'sia
 DID : 03-7870 5168


 -Original Message-
 From: Mark Charette [mailto:[EMAIL PROTECTED]
 Sent: Friday, July 04, 2003 9:02 AM
 To: [EMAIL PROTECTED]; Shena Delian O'Brien
 Subject: Re: [PHP] Re: Red Hat 9, Apache 2, and PHP


 Apache 2.x.x IS a production quality server, just not with PHP. Works
great
 with Tomcat, mod_jk2, Struts, etc.

 - Original Message -
 From: Shena Delian O'Brien [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Thursday, July 03, 2003 8:04 PM
 Subject: Re: [PHP] Re: Red Hat 9, Apache 2, and PHP


  Does anyone know why Red Hat would switch to Apache 2.x.x when it is
  well known that 2.x.x is NOT a production version?
 
  Brad Pauly wrote:
   Just thought I would share my experience with RH9. I have been running
   Apache 1.3.27 and PHP 4.3.2 on RH9 for a couple weeks (since 4.3.2
came
   out anyway, and 4.3.1 prior to that) on a test server. All are
compiled
   from source. The only problem I have had was a bug with the version of
   mogrify that is bundled with RH9. That was fixed by 'upgrading' to an
   older version. Other than that it has been fine.
  
   Brad
  
  
  
  
 
 
  --
  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] Session vs Cookie Issues

2003-07-01 Thread Ow Mun Heng
Hi All,

I know this topic has been talked about a LOT but all the info I've
managed to get from google is that there is no center / best option to
choose between using sessions or cookies.

Pros of Sessions
1. PHP does it all automatically
2. Can also be defined but I don't know how(yet)


   
Cons
1. saves it in /tmp - world viewable
2. Session ID may be easy to guess unless I md5 the sessionID before sending
it out

Pros of Cookies 
1. can be generated via functions   
2. Can be stored in mysql  looked up each time user comes to the site (this
i found out from mantis-bugtracker)
3. can be set using PHP setcookie function 

Cons
1. cookies can be rejected by users
2. if rejected, means session can't be preserved across pages?? (this I'm
not sure)
3. cookie is stored in user's hard drive. What is user using public PC?

Can anyone please help explain which is better in terms of performance 
security? For cookies and the way that mantis does it(I looked through the
code to learn - newb), each time a page is accessed, php will query the
database for the cookie string and compare it as a means of identification.
Doesn't this affects performance if I were to need to query the database A
LOT? (presuming that my site generates a lot of traffic.)

I'm assuming here that accessing the /tmp is faster than accessing the
database. Is there a way to put the /tmp location somewhere secure and not
world viewable?

Please Don't flame me.. I'm just asking.



Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168

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



RE: [PHP] Session vs Cookie Issues

2003-07-01 Thread Ow Mun Heng
Hi Mike,

based on what you're saying, I gather that if I were to choose to
use cookies, and if cookies were rejected by the user, PHP will default to
using sessions?

: quote :---
The only major flaw I've found with PHP's
session support is that it doesn't appear to be possible to force the data
to be written without also closing the session.

: End Quote :

Is the above a serious flaw which I need to be aware of?

Thanks

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Mike Migurski [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 02, 2003 11:47 AM
To: Ow Mun Heng
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Session vs Cookie Issues


   I know this topic has been talked about a LOT but all the info
I've managed to get from google is that there is no center / best option
to choose between using sessions or cookies.

You're comparing apples and oranges -- cookies are one of the mechanisms
by which PHP implements sessions. The other is URL-munging. So if you use
sessions, odds are cookies are coming along for the ride. What you
definitely /don't/ want to do is to store application data in the cookie
itself, due to various security (public machines) and technical (4k size
limit) concerns. PHP's built-in session support uses the cookie data as an
identifier, to match a user to the data stored in a session file, and in
general this is the way to go. The only major flaw I've found with PHP's
session support is that it doesn't appear to be possible to force the data
to be written without also closing the session. In general, PHP's session
features are pretty complete, and easily modifiable.

To clear up a few items below:


Cons of Sessions
1. saves it in /tmp - world viewable

not necessarily so, see php.net/session_save_path

2. Session ID may be easy to guess unless I md5 the sessionID before
sending it out

you can define your own session id if you'd like, see php.net/session_id
for example, to help deter session fixation, you might require that the
session be a hash of certain environment variables, such as remote IP or
user-agent string.


Cons of cookies
1. cookies can be rejected by users
2. if rejected, means session can't be preserved across pages?? (this I'm
not sure)

this is where URL-munging will come into play; PHP will resort to this if
cookies are rejected.


3. cookie is stored in user's hard drive. What is user using public PC?

don't use the cookie to store application data - use it to determine the
user's identity. This is the behavior that PHP's session features
encapsulate.


-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html


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



[PHP] RE: PHP Mysql Error Code 1062 - Duplicates found

2003-06-26 Thread Ow Mun Heng
Hi All,

I found out how to do it already. Thanks for the help.

mysql_error() was the key..

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Ow Mun Heng 
Sent: Wednesday, June 25, 2003 10:03 AM
To: [EMAIL PROTECTED]
Subject: PHP  Mysql Error Code 1062 - Duplicates found


Hi PHP'ers,

I've got a question regarding the input of (multiple) data into
mysql through PHP. 

If there is already an entry in the database, then an mysql will generate an
error 1062 stating that the entry is a duplicate. (This will happen only if
I input the data through mySQL using xterm, if I use PHP, then I only get
the 'duplicate entry found', partly cause I don't know how to get the error
code as well as the duplicate entry returned to PHP to be output'ed to the
browser.

Below is my code. $my_query is concatenated from an array.

$my_query = $my_query.
\n('.$SN[$i].','.$DCM[$i].','.$Supp[$i].','.$time_now.'),;
$query = INSERT INTO pioneer(serial_no,dcm,supplier,fa_timestamp) VALUES
$my_query;; 
$result = mysql_db_query('tracker',$query);

if ($result)
echo brbr.mysql_affected_rows(). Drives  DCM combo inserted into
database.;
else
echo \nbrbrDuplicate entry found. Data not inserted.;


Can anyone help me out?


Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168

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



[PHP] RE: defect tracking systems

2003-06-26 Thread Ow Mun Heng
I'm looking at mantis..Nice System but not sure if it's what you want. I'm
gonna mod it a bit for my usage in a Drive (FA) Environment.

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Martin Balcar [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 26, 2003 5:43 PM
To: [EMAIL PROTECTED]
Subject: defect tracking systems


Hi,
I want to begin to use some of bug tracking systems. I think it can help me
with developing more robust applications and make an easier communication
with my clients. I have tried to use Bugzilla, but It was a little bit
complicated system.

Please help me to choose some

Regards
Martin



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



[PHP] PHP Mysql Error Code 1062 - Duplicates found

2003-06-24 Thread Ow Mun Heng
Hi PHP'ers,

I've got a question regarding the input of (multiple) data into
mysql through PHP. 

If there is already an entry in the database, then an mysql will generate an
error 1062 stating that the entry is a duplicate. (This will happen only if
I input the data through mySQL using xterm, if I use PHP, then I only get
the 'duplicate entry found', partly cause I don't know how to get the error
code as well as the duplicate entry returned to PHP to be output'ed to the
browser.

Below is my code. $my_query is concatenated from an array.

$my_query = $my_query.
\n('.$SN[$i].','.$DCM[$i].','.$Supp[$i].','.$time_now.'),;
$query = INSERT INTO pioneer(serial_no,dcm,supplier,fa_timestamp) VALUES
$my_query;; 
$result = mysql_db_query('tracker',$query);

if ($result)
echo brbr.mysql_affected_rows(). Drives  DCM combo inserted into
database.;
else
echo \nbrbrDuplicate entry found. Data not inserted.;


Can anyone help me out?


Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168

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



[PHP] PHP cached data when using browser back button

2003-06-24 Thread Ow Mun Heng
Hi All,

How can I prevent the browser from sending in cached data after the
user pressed the 'back' button and re-inputted data.

Eg: Originall I enter 3 isbn numbers, submitted it, then the user presses
the 'back' button to re-input 1 new data and then re-submits the data,
instead of only having the 1 new data, I get the 1 new data + 3 old data.

Can anyone help explain this? (if I were to clear the browser's cache, then
there's no problem.)

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168

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



RE: [PHP] Performance question

2003-06-24 Thread Ow Mun Heng
Can someone help explain how I can perform a benchmark on the queries or
whatever?


Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Boaz Yahav [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 24, 2003 1:41 AM
To: Hardik Doshi; [EMAIL PROTECTED]
Subject: RE: [PHP] Performance question


It depends on your HW / Application / number of visitors.
If you are planning to have many visitors and plan this number to
constantly
grow than you should avoid going to the DB as much as possible.

Sincerely

berber

Visit http://www.weberdev.com/ Today!!!
To see where PHP might take you tomorrow.


-Original Message-
From: Hardik Doshi [mailto:[EMAIL PROTECTED] 
Sent: Monday, June 23, 2003 5:10 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Performance question


Hi Group,

I have a question regarding retrieving the
information. I have the functionlity in which on every
user click, system needs to retrieve information for
particular user and display the page according to the
retrieved information. Now question is which is the
scalable solution? (1) Retrieve information from the
database on each user click. (2) Retrieve information
from the session (here information is retrieved once
and stored in the session file on the server, when
user logs into the system)

Please let me know

Thanks

Hardik

__
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com

-- 
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] Q : HELP HTML forms parsed into an array for PHP

2003-06-18 Thread Ow Mun Heng
Hi Jason,

Sorry but your code doesn't work. I tried fiddling with it but since
I'm a newbie, I'm a bit lost.


for lines that has '$isbn - should it read '$isbn'?

After submitting the form to itself, I tried to echo the $status, $newisdn
but nothing comes out. 

For The Javascript, can I ask you if it's possible for the focus to go from
Input1 to input2 consequtively? eg:

|-| |-| 
| ISBN Box| | SKU number|  SUBMIT
|-| |-|

Scan at 'ISBN Box', focus goes to 'SKU number' and then subsequently it
submits the data into the server.

Okay.. here's what I'm trying to prove.

I have a bunch of books, which I need to scan in the ISBN  the
corresponding SKU number and then submit it to mySQL.

@ 1st i was thinking I can just scan in the list of ISBN numbers and then go
to another box and scan in the SKU numbers and then input them into MySQL
together(but then I'll be opening up another can of worms to match ISBN to
SKU for each line!). If I do that, I won't be able to determine if there's
duplicate entries before I submit it.

John Holmes solution worked but needed a few tweaks for the \n and \r the
scanner puts in automatically.

If anyone can point me in the right direction, please help. 


Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Jason Paschal [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 17, 2003 11:54 AM
To: Ow Mun Heng
Subject: Re: [PHP] Q : HELP HTML forms parsed into an array for PHP


from what i've experienced w/ bar code scanners, they send a carriage return

after inputting the numbers, so why not just have a page w/ a single input 
text field and a submit button that submits to itself? i threw in some 
javascript, also, that should set focus to the text field when the page 
loads, so if you are scanning in a bunch of items, you scan, it 
automatically submits, and is ready for the next one.
that's the idea, anyway, assuming your bar code scanner is setup to send a 
carriage return signal.

name of page is form.php:

?php
$cn = mysql_connect(localhost,username,password);
$db = mysql_select_db(mydatabase);

if ($status==newisbn) {
  $isbn= trim($isbn);
  $sql = select * from table where isbn = '$isbn;
  $q = mysq_query($sql);
  $nr = mysql_num_rows($q);
  if ($nr  1) {
 $sql = insert into table (isbn) values ('$isbn);
 $q = mysql_query($sql);
 echo Successful insert.br;
  } else {
 echo ISBN already exists.  $newisbnbr;
  }
}
?

html
body onLoad=document.getElementById('isbn').focus()
form name=myform method=post action=form.php
Input:input type=text id=isbn name=isbn
input type=hidden name=status value=newisbn
input type=submit name=submit value=Submit
/form
/body
/html

-Original Message-
From: John W. Holmes [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 17, 2003 10:34 AM
To: Ow Mun Heng
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Q : HELP HTML forms parsed into an array for PHP

$isbn_string = (' . str_replace(\n,'),\n(',$_POST['isbn']) . ');
$query = INSERT INTO table VALUES $isbn_string;

-- 
---John Holmes...

From: Ow Mun Heng [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: [PHP] Q : HELP HTML forms parsed into an array for PHP
Date: Tue, 17 Jun 2003 10:27:46 +0800

Hi all,

   Really hope someone can help me out.

What I would like to do is to input multiple isbn numbers into a form, get
PHP to parse it into an array so that I can build the SQL query for 
multiple
insert. Currently I'm able to perform single inputs, one at a time, which 
is
time consuming.

I want to have a formtextarea name=isbn row=10 col=13 set up to get user
input (multiline, each line separated by a carriage return - actually it's
barcode is scanned in)
   eg : ISBN - 1-111-2-1
   1-111-2-2
   1-111-2-3

I would like to parse this data into PHP and get PHP to use a foreach loop
(or a for loop) so that I can build up the $query to form ('isbn1')
('isbn2') ('isbn3').

I'm trying to insert into mySQL a multiple value insert sort of like

$query =   insert into table values
   ('isbn1')
   ('isbn2')
   ('isbn3');


Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia
DID : 03-7870 5168


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


_
The new MSN 8: advanced junk mail protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail


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



[PHP] Q : HELP HTML forms parsed into an array for PHP

2003-06-16 Thread Ow Mun Heng
Hi all,

Really hope someone can help me out.

What I would like to do is to input multiple isbn numbers into a form, get
PHP to parse it into an array so that I can build the SQL query for multiple
insert. Currently I'm able to perform single inputs, one at a time, which is
time consuming. 

I want to have a formtextarea name=isbn row=10 col=13 set up to get user
input (multiline, each line separated by a carriage return - actually it's
barcode is scanned in)
eg : ISBN - 1-111-2-1
1-111-2-2
1-111-2-3

I would like to parse this data into PHP and get PHP to use a foreach loop
(or a for loop) so that I can build up the $query to form ('isbn1')
('isbn2') ('isbn3').

I'm trying to insert into mySQL a multiple value insert sort of like 

$query =insert into table values
('isbn1')
('isbn2')
('isbn3');


Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


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



RE: [PHP] Q : HELP HTML forms parsed into an array for PHP

2003-06-16 Thread Ow Mun Heng
Thanks VERY VERY much. I was tearing my hair out.

Thanks for helping this newbie.

VERY much appreciated.

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: John W. Holmes [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 17, 2003 10:34 AM
To: Ow Mun Heng
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Q : HELP HTML forms parsed into an array for PHP


Ow Mun Heng wrote:

 What I would like to do is to input multiple isbn numbers into a form, get
 PHP to parse it into an array so that I can build the SQL query for
multiple
 insert. Currently I'm able to perform single inputs, one at a time, which
is
 time consuming. 
 
 I want to have a formtextarea name=isbn row=10 col=13 set up to get user
 input (multiline, each line separated by a carriage return - actually it's
 barcode is scanned in)
   eg : ISBN - 1-111-2-1
   1-111-2-2
   1-111-2-3
 
 I would like to parse this data into PHP and get PHP to use a foreach loop
 (or a for loop) so that I can build up the $query to form ('isbn1')
 ('isbn2') ('isbn3').
 
 I'm trying to insert into mySQL a multiple value insert sort of like 
 
 $query =  insert into table values
   ('isbn1')
   ('isbn2')
   ('isbn3');

$isbn_string = (' . str_replace(\n,'),\n(',$_POST['isbn']) . ');
$query = INSERT INTO table VALUES $isbn_string;

-- 
---John Holmes...

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

PHP|Architect: A magazine for PHP Professionals  www.phparch.com





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