[PHP] Location header does not work?

2004-08-03 Thread Bing Du
I've been struggling with this redirect thing for a while but still cannot
get it work.  I'm desperately needing help, please.

What I want to do is redirect
http://computing.eng.iastate.edu/mambo/index.php?option=content&task=view&id=159&Itemid=162
to
https://computing.eng.iastate.edu/mambo/index.php?option=content&task=view&id=159&Itemid=162.
The only difference between the above two URLs is one is http and the
other is https.

==
if ($option == 'content' and $task == 'view' and $id == 159 and $Itemid ==
162)
{
  session_write_close();
  header("Location:
https://computing.eng.iastate.edu/mambo/index.php?option=content&task=view&id=159&Itemid=162";);
  exit;
}
==

Am I doing anything wrong with the Location header?

Any help would be greatly appreciated.

Bing

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



Re: [PHP] Location header does not work?

2004-08-03 Thread Bing Du
The latest message I got was 'Redirection limit for this URL exceeded.
Unable to load the requested page.This may be caused by cookies that are
blocked.'.

Bing

> On Tuesday 03 August 2004 15:41, Bing Du offered up the following tid-bit
> of
> information :
>> I've been struggling with this redirect thing for a while but still
>> cannot get it work.  I'm desperately needing help, please.
>>
>> What I want to do is redirect
>> http://computing.eng.iastate.edu/mambo/index.php?option=content&task=view
>>&id=159&Itemid=162 to
>> https://computing.eng.iastate.edu/mambo/index.php?option=content&task=vie
>>w&id=159&Itemid=162. The only difference between the above two URLs is
>> one
>> is http and the other is https.
>>
>> => if ($option == 'content' and $task == 'view' and $id == 159
>> and $Itemid
>> == 162)
>> {
>>   session_write_close();
>>   header("Location:
>> https://computing.eng.iastate.edu/mambo/index.php?option=content&task=vie
>>w&id=159&Itemid=162"); exit;
>> }
>> =>
>> Am I doing anything wrong with the Location header?
>
> What's the error?  Is it just not forwarding?  Headers already sent?
>
> --
> John C. Nichel
> ÜberGeek
> KegWorks.com
> 716.856.9675
> [EMAIL PROTECTED]
>
>

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



Re: [PHP] Location header does not work?

2004-08-04 Thread Bing Du
Ok, now I'm confused and cannot understand the result of the following
code snippet.  After click the link that I want to redirect, the URL in
the Address box of the browser changed from http to https fine (that's
what I expected).  But 'hello my friend' was also displayed.  How come?

=
if ($option == 'content' and $task == 'view' and $id == 159 and $Itemid ==
162)
{
   session_write_close();

   if (!isset($_SERVER['HTTPS']))
   {
header("Location:
https://computing.eng.iastate.edu/mambo/index.php?option=content&task=view&id=159&Itemid=162";);
   } else {
 echo 'hello my friend';
      }


Bing
> On Tue, 3 Aug 2004 15:34:27 -0500 (CDT), Bing Du <[EMAIL PROTECTED]> wrote:
>> The latest message I got was 'Redirection limit for this URL exceeded.
>> Unable to load the requested page.This may be caused by cookies that are
>> blocked.'.
>>
>
> Your page is redirecting you over and over again. Your problem is that
> you're not checking for https before you redirect! If the user comes
> in with the https URL, you're still redirecting them. Try checking the
> value of $_SERVER['HTTPS'].
>
>> Bing
>>
>>
>>
>> > On Tuesday 03 August 2004 15:41, Bing Du offered up the following
>> tid-bit
>> > of
>> > information :
>> >> I've been struggling with this redirect thing for a while but still
>> >> cannot get it work.  I'm desperately needing help, please.
>> >>
>> >> What I want to do is redirect
>> >> http://computing.eng.iastate.edu/mambo/index.php?option=content&task=view
>> >>&id=159&Itemid=162 to
>> >> https://computing.eng.iastate.edu/mambo/index.php?option=content&task=vie
>> >>w&id=159&Itemid=162. The only difference between the above two URLs is
>> >> one
>> >> is http and the other is https.
>> >>
>> >> => if ($option == 'content' and $task == 'view' and $id ==
>> 159
>> >> and $Itemid
>> >> == 162)
>> >> {
>> >>   session_write_close();
>> >>   header("Location:
>> >> https://computing.eng.iastate.edu/mambo/index.php?option=content&task=vie
>> >>w&id=159&Itemid=162"); exit;
>> >> }
>> >> =>
>> >> Am I doing anything wrong with the Location header?
>> >
>> > What's the error?  Is it just not forwarding?  Headers already sent?
>> >
>> > --
>> > John C. Nichel
>> > ÜberGeek
>> > KegWorks.com
>> > 716.856.9675
>> > [EMAIL PROTECTED]
>> >
>> >
>>
>
> --
> DB_DataObject_FormBuilder - The database at your fingertips
> http://pear.php.net/package/DB_DataObject_FormBuilder
>
> paperCrane --Justin Patrin--
>

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



Re: [PHP] Location header does not work?

2004-08-05 Thread Bing Du
I really appreciate everyone who responded taking your valuable time
looking into my problem.

Now back to my problem.  Changing the condition to "if($_SERVER['HTTPS']
!= 'on')" did not make any difference unfortunately. So the result was
still the URL in the Address box of the browser changed to
https://computing.eng.iastate.edu/mambo/index.php?option=content&task=view&id=159&Itemid=162
fine.  But instead of showing the page that https address should point to,
'You are in HTTPS mode' was displayed as the else clause specified.

Bing

> On Wed, 4 Aug 2004 17:02:30 -0500 (CDT), Bing Du <[EMAIL PROTECTED]> wrote:
>> Ok, now I'm confused and cannot understand the result of the following
>> code snippet.  After click the link that I want to redirect, the URL in
>> the Address box of the browser changed from http to https fine (that's
>> what I expected).  But 'hello my friend' was also displayed.  How come?
>>
>> > if ($option == 'content' and $task == 'view' and $id ==
>> 159 and $Itemid => 162)
>> {
>>session_write_close();
>>
>>if (!isset($_SERVER['HTTPS']))
>>{
>> header("Location:
>> https://computing.eng.iastate.edu/mambo/index.php?option=content&task=view&id=159&Itemid=162";);
>>} else {
>>  echo 'hello my friend';
>>   }
>> =if ($option == 'content' and $task == 'view' and $id == 159
>> and
> $Itemid == 162) {
>   if($_SERVER['HTTPS'] != 'on') {
> header('Location: https://computing.eng.iastate.edu/mambo/index.php'.
>   '?option=content&task=view&id=159&Itemid=162');
>   } else {
> echo 'You are in HTTPS mode.';
> //do stuff
>   }
> }
>
>>
>> Bing
>>
>>
>> > On Tue, 3 Aug 2004 15:34:27 -0500 (CDT), Bing Du <[EMAIL PROTECTED]>
>> wrote:
>> >> The latest message I got was 'Redirection limit for this URL
>> exceeded.
>> >> Unable to load the requested page.This may be caused by cookies that
>> are
>> >> blocked.'.
>> >>
>> >
>> > Your page is redirecting you over and over again. Your problem is that
>> > you're not checking for https before you redirect! If the user comes
>> > in with the https URL, you're still redirecting them. Try checking the
>> > value of $_SERVER['HTTPS'].
>> >
>> >> Bing
>> >>
>> >>
>> >>
>> >> > On Tuesday 03 August 2004 15:41, Bing Du offered up the following
>> >> tid-bit
>> >> > of
>> >> > information :
>> >> >> I've been struggling with this redirect thing for a while but
>> still
>> >> >> cannot get it work.  I'm desperately needing help, please.
>> >> >>
>> >> >> What I want to do is redirect
>> >> >> http://computing.eng.iastate.edu/mambo/index.php?option=content&task=view
>> >> >>&id=159&Itemid=162 to
>> >> >> https://computing.eng.iastate.edu/mambo/index.php?option=content&task=vie
>> >> >>w&id=159&Itemid=162. The only difference between the above two URLs
>> is
>> >> >> one
>> >> >> is http and the other is https.
>> >> >>
>> >> >> => if ($option == 'content' and $task == 'view' and $id =>
>> >> 159
>> >> >> and $Itemid
>> >> >> == 162)
>> >> >> {
>> >> >>   session_write_close();
>> >> >>   header("Location:
>> >> >> https://computing.eng.iastate.edu/mambo/index.php?option=content&task=vie
>> >> >>w&id=159&Itemid=162"); exit;
>> >> >> }
>> >> >> =>
>> >> >> Am I doing anything wrong with the Location header?
>> >> >
>> >> > What's the error?  Is it just not forwarding?  Headers already
>> sent?
>> >> >
>> >> > --
>> >> > John C. Nichel
>> >> > ÜberGeek
>> >> > KegWorks.com
>> >> > 716.856.9675
>> >> > [EMAIL PROTECTED]
>> >> >
>> >> >
>> >>
>> >
>> > --
>> > DB_DataObject_FormBuilder - The database at your fingertips
>> > http://pear.php.net/package/DB_DataObject_FormBuilder
>> >
>> > paperCrane --Justin Patrin--
>> >
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>> !DSPAM:41115ae5170651561813149!
>>
>>
>
>
> --
> DB_DataObject_FormBuilder - The database at your fingertips
> http://pear.php.net/package/DB_DataObject_FormBuilder
>
> paperCrane --Justin Patrin--
>

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



[PHP] retrieve all the groups a user is memberOf from active directory?

2007-01-25 Thread Bing Du
Hi,

Sorry if the top is not closely PHP related.  But I need to accomplish it
using PHP.

I can query the attribute 'memberOf' of a user from the active directory
server with no problem.  The challenge I'm facing now is how to obtain all
the groups a user is member of.  In many cases, a user can be in many
groups which could be nested.  Say, user is a member of group B which is a
member of group A.  So user should be member of group A implicitly.  But
in active directory, user's account only has

memberOf:  CN=Group_B,OU=security groups,OU=Users,OU=Coll,DC=some,DC=edu

I can then check if Group_B's LDAP entry has any 'memberOf' attribute, so
on and so on.  If user's LDAP entry has multiple 'memberOf' attributes, I
have to check each one to see if each group has any parent groups. 
Anybody ever had to deal with such a kind of issue and would like to shed
some light (better with some code samples) how it should be done
effectively?  Any ideas would be greatly appreciated.

Thanks,

Bing

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



Re: [PHP] retrieve all the groups a user is memberOf from active directory?

2007-01-26 Thread Bing Du
> On Thu, January 25, 2007 3:07 pm, Bing Du wrote:
>> Sorry if the top is not closely PHP related.  But I need to accomplish
>> it
>> using PHP.
>>
>> I can query the attribute 'memberOf' of a user from the active
>> directory
>> server with no problem.  The challenge I'm facing now is how to obtain
>> all
>> the groups a user is member of.  In many cases, a user can be in many
>> groups which could be nested.  Say, user is a member of group B which
>> is a
>> member of group A.  So user should be member of group A implicitly.
>> But
>> in active directory, user's account only has
>>
>> memberOf:  CN=Group_B,OU=security
>> groups,OU=Users,OU=Coll,DC=some,DC=edu
>>
>> I can then check if Group_B's LDAP entry has any 'memberOf' attribute,
>> so
>> on and so on.  If user's LDAP entry has multiple 'memberOf'
>> attributes, I
>> have to check each one to see if each group has any parent groups.
>> Anybody ever had to deal with such a kind of issue and would like to
>> shed
>> some light (better with some code samples) how it should be done
>> effectively?  Any ideas would be greatly appreciated.
>
> I don't know hardly anything about LDAP, and even less about Active
> Directory, but if you can't find a built-in function to do this and
> have to write your own, it should end up looking something like:
>
> function groups($user, $groups = null){
>   //very first time, initialize $groups to empty array:
>   if (is_null($groups)) $groups = array();
>
>   //Find all the groups that his user/group is a memberOf:
>   $member_of = //do your LDAP here to find the memberOf:
>   //ex: "CN=Group_B,OU=security groups,OU=Users,OU=Coll,DC=some,DC=edu"
>
>   //Look at each group in turn
>   $member_of = explode(',', $member_of);
>   foreach($member_of as $group){
> //Skip any groups we have already seen:
> if (isset($groups[$group])) continue;
>
> //Add it to the list of groups:
> $groups[$group] = $group;
>
> //check for super-groups of this group:
> $groups = array_merge($groups, groups($group, $groups));
>   }
> }

Excellent!  Thanks much for the quick response.  Appreciate it.  I see the
general logic is right.

Bing

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



[PHP] advice on sql injection/XSS prevention

2007-04-05 Thread Bing Du
Hi,

I'm not an experienced PHP developer.  We're hosting a content management
system that allow authorized people to add PHP contents.  Their PHP coding
levels varies.  Some are very security sensitive, but some are not.  I
want to know if PHP has any ready-to-use funtion to validate form input to
help prevent SQL injection/XSS?  So each programmer doesn't have to write
their own form validation code.  I'd appreciate any advice or pointers.

Thanks in advance,

Bing

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



[PHP] how to verify PHP has been installed with ldap?

2004-04-29 Thread Bing Du
Greetings,

I've installed PHP with ldap.  But I got this error "Fatal error: Call to
undefined function: ldap_connect() in /home/me/public_html/test1.php on
line 5".  Why ldap_connect() is undefined?

This is what I did:

==
# ./configure --with-apxs=/usr/local/apache/bin/apxs
--with-config-file-path=/usr/local/apache/php.ini --with-mysql --with-zlib
--with-ldap
# make
# make install
==

It went through without obvious errors.

And this is the PHP script test1.php that generates the above error:





So my question is how to verify PHP has been installed with ldap support?

Thanks in advance for any help,

Bing

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



Re: [PHP] how to verify PHP has been installed with ldap?

2004-04-29 Thread Bing Du
I don't see a ldap section in the output of phpinfo().  I need to add a
bit more background information here...

This is not a fresh php install.  I've already installed PHP Version
4.3.4.  But now I want to add ldap support to it.  So I added --with-ldap
option in the configure command.  Then I did make and make install. 
However, phpinfo() still shows the old information.  For instance, Build
Date was Mar 3 2004 11:15:34, Configure Command was the one without
--with-ldap, etc..

I removed config.cache before doing configure/make/make install and also
restarted the apache server, but nothing helped.  Do I need to do anything
on the apache server?

What did I do wrong?

Bing

> From: "Bing Du" <[EMAIL PROTECTED]>
>
>> So my question is how to verify PHP has been installed with ldap
>> support?
>
> 
>
> And see if there is an ldap section.
>
> ---John Holmes...
>

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



Re: [PHP] how to verify PHP has been installed with ldap?

2004-04-30 Thread Bing Du
Yes, I did.  phpinfo() just does not reflect reinstall at all.  Here is
the sequence of my operations.

1. remove config.cache
2. ./configure --with-apxs=/usr/local/apache/bin/apxs
--with-config-file-path=/usr/local/apache --with-mysql --with-zlib
--with-ldap
3. make
4. make install
5. /usr/local/apache/bin//apachectl restart

Where else should I look?

Bing

> Or... did you restart apache after running your make install? If not, that
> might be a good idea... `/path/to/apachectl restart`
>
>
> On Thursday 29 April 2004 04:00 pm, Curt Zirzow wrote:
>> * Thus wrote Bing Du ([EMAIL PROTECTED]):
>> > I don't see a ldap section in the output of phpinfo().  I need to add
>> a
>> > bit more background information here...
>> >
>> > This is not a fresh php install.  I've already installed PHP Version
>> > 4.3.4.  But now I want to add ldap support to it.  So I added
>> --with-ldap
>> > option in the configure command.  Then I did make and make install.
>> > However, phpinfo() still shows the old information.  For instance,
>> Build
>> > Date was Mar 3 2004 11:15:34, Configure Command was the one without
>> > --with-ldap, etc..
>>
>> This usually means that either you have multiple installation's of
>> apache and php's "make install" isn't putting the the module in the
>> right place.
>>
>> Or, that your current apache config loads modules from a different
>> place than apxs told php it should go.
>>
>> If you issue:
>> ls -laF `apxs -q LIBEXECDIR`
>>
>> You should see your libphp5.so there with the latest timestamp. if
>> not, see if there are some errors issued with the 'make install'
>> (like are you issuing that as root?)
>>
>> Also, look in the 'apache' section from phpinfo() and look at the
>> value for 'Server root', php will usually be loaded relative to
>> that directory.
>>
>>
>> Curt
>> --
>> "I used to think I was indecisive, but now I'm not so sure."
>
> --
> Evan Nemerson
> [EMAIL PROTECTED]
> http://coeusgroup.com/en
>
> --
> "To think is to differ."
>
> -Clarence Darrow
>
>

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



[PHP] how does PHP handle kerberos authentication?

2004-05-05 Thread Bing Du
I need to code kerberos authentication in PHP.  Like in Perl, it has
Authen::Krb5 module.  How the similar tasks are done in PHP?  I've
searched (all site) 'kerberos' on www.php.net but did not find any
information that I need.

Thanks in advance for any help,

Bing

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



[PHP] mail sent but not received?!

2004-06-25 Thread Bing Du
Hi,

I've been pulling my hair out over this problem for a while...



--

Since the result of the mail() returned is 1, the message should have been
delivered fine.  but I did not get anything.  Where can I look for more
clues of what the problem might be, like possible log, or turn on some
debug level in php?  I've also tried mail($to,$sbj,$msg, "-f [EMAIL PROTECTED]"),
no workie either.

Any help would be greatly appreciated!

Bing

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



[PHP] call to undefined function which is defined

2007-06-11 Thread Bing Du
Hi,

RHEL 4
PHP 4.3.9
Apache 2.0.52

Without knowing much about the web application we use, can anybody tell me
what kind of situation could trigger the following 'call to undefined
function' error?

PHP Fatal error:  Call to undefined function:  encryptchar
code() in /data/www/html/typo3_src/typo3/sysext/cms/tslib/class.tslib_fe.p
hp on line 3439

Line 3439 is:

$out .= $this->encryptCharcode($charValue,0x61,0x7A,$offset);

Here is the function block that has line 3439.

function encryptEmail($string,$back=0)  {
$out = '';

if ($this->spamProtectEmailAddresses === 'ascii') {
for ($a=0; $aspamProtectEmailAddresses)*($back?-1:1);
for ($i=0; $i<$len; $i++)   {
$charValue = ord($string{$i});
if ($charValue >= 0x2B && $charValue <=
0x3A)   {   // 0-9 . , - + / :
$out .=
$this->encryptCharcode($charValue,0x2B,0x3A,$offset);
} elseif ($charValue >= 0x40 && $charValue
<= 0x5A) {   // A-Z @
$out .=
$this->encryptCharcode($charValue,0x40,0x5A,$offset);
} else if ($charValue >= 0x61 &&
$charValue <= 0x7A){   // a-z
$out .=
$this->encryptCharcode($charValue,0x61,0x7A,$offset);
} else {
$out .= $string{$i};
}
}
}
return $out;
}

And the encryptCharcode() function the fatal error complained about is
defined right before encrytEmail().

==
 function encryptCharcode($n,$start,$end,$offset){
$n = $n + $offset;
if ($offset > 0 && $n > $end)   {
$n = $start + ($n - $end - 1);
} else if ($offset < 0 && $n < $start)  {
$n = $end - ($start - $n - 1);
}
return chr($n);
}
==

I don't understand why the error is about a function that's defined fine??

Thanks in advance for any help,

Bing

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



[PHP] make global variables accessible to functions?

2006-04-07 Thread Bing Du
Hello,

We use PHP 4.3.9. 'register_globals = Off' is set in php.ini.  I've heard
using 'global' could cause security problems.  Is using $GLOBALS still not
more secure than using the 'global' keyword? How should function foo()
obtain the value of $a?



===

Thanks in advance,

Bing

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



Re: [PHP] Re: make global variables accessible to functions?

2006-04-07 Thread Bing Du
Thanks for the response.

> That way is secure and has nothing to do with register_globals ;)
>

Good.  That's what I wanted to hear.  I know by default some pre-defined
global variables can be accessed through $GLOBALS.  If I don't want end
users to add their own user defined variables in the superglobal area, how
should I do that?

> What you can do too is this:
>
>  function foo($a) {
> echo "a is $a";
> }
> ?>

Yeah, I know it works this way.  The reason I don't go this way is I have
quite a few variables that need to be passed to the function, it's not
feasible to pass all them as funtion parameters.

Bing

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



[PHP] help with multidimentional arrays

2006-04-11 Thread Bing Du
Hello,

What I intend to do is put the database query results in a
multidimentional array like this.

$sponsor_id['sponsor1'] = ('project1 title', 'project2 title', 'project3
title');
$sponsor_id['sponsor2'] = ('project1 title','project7 title');


Here is the code snippet for doing that:

==
while( ($rec = odbtp_fetch_array($qry)) ) {

   if (empty($sponsor_id[$rec[1]])) {
  $sponsor_id[$rec[1]] = array();
   } else {
   array_push($sponsor_id[$rec[1]], $rec[0]);
  }
 }
==

Now, when the following code is used to print the array $sponsor_id, it
only prints out the keys of the array which are:

sponsor1
sponsor2

Those project titles are not printed out.

==
foreach ($sponsor_id as $sponsor => $arr)
echo "$sponsor:";
foreach ($arr[$sponsor] as $project) {
echo "$project";
}
==

My expected output should be like:

sponsor1:
  project1 title
  project2 title
  project3 title

sponsor2
  project1 title
  project7 title

What is wrong?  I'd appreciate any help.

Thanks,

Bing

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



Re: [PHP] help with multidimentional arrays

2006-04-12 Thread Bing Du
> On 4/11/06, Bing Du <[EMAIL PROTECTED]> wrote:
>> => foreach ($sponsor_id as $sponsor => $arr)
>> echo "$sponsor:";
>> foreach ($arr[$sponsor] as $project) {
>> echo "$project";
>> }
>> =>
>
> It looks like you're building your array just fine.  Here though, your
> second foreach needs to look like this:
>
> [code]
> foreach ($arr as $project)
> {
>  echo "$project";
> }
> [/code]
>
> Your temprorary $arr variable contains only your array of titles, not
> an entire row of your 2-dimensional $sonsor_id array.  So you do not
> need to use the $sponsor key to get at that array.
>

Thanks so much for pointing out that error on $arr, John.  You are very
right.  Now I realize it's such an obvious error.  But I did not notice it
before I posted.

Bing

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



[PHP] how should MS Access DATETIME be handled in PHP?

2006-04-13 Thread Bing Du
Hello,

We have a website which pulls data from its MS Access backend database and
publishes the data using Cold Fusion.

The Cold Fusion code has '#DateFormat(end_date, "Mmmm d, ")#'.

'end_date' is a table column of type DATETIME in the Access DB.

Now, we need to use PHP instead of Cold Fusion to query the same Access
database and display the data on the web. Here are the related PHP code
snippets.

Query the Access DB:

 $qry = odbtp_query("SELECT end_date,title,projectID FROM projects ORDER
BY end_date DESC");

Get the query results:

while( ($rec = odbtp_fetch_array($qry)) ) {
  echo "end_date is $rec[0]";
}

The outputs of the above echo are:

end_date is Object
end_data is Object


The date format I want the output to be is like 'March 31, 2005'.  I've
tried PHP's date() function using format 'F j, Y'.  The format looks
correct.  But date() requires the time it's converting be a timestamp.  So
how should I output the 'end_date' in the 'F j, Y' format?

I'd appreciate any help.

Bing

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



Re: [PHP] how should MS Access DATETIME be handled in PHP?

2006-04-13 Thread Bing Du
> apparently $rec[0] is a php object - try the following lines to
> find out what's inside:
>
> echo '';
> print_r($rec[0]);
> echo '';
>
> that will probably give you a clue as to how to extract some
> useful info from the object.

Excellent!  Yes, it now does give me a clue to see what's actually in the
object.  print_r($rec[0]) shows:

stdClass Object ( [year] => 2005 [month] => 8 [day] => 31 [hour] => 0
[minute] => 0 [second] => 0 [fraction] => 0 )

I've never dealt with object in PHP.  Something new learnt today.  I'm now
able to use get_object_vars($rec[0]) to extract the info from the object. 
There is one thing I don't understand though.

Is there anything wrong with the follow code snippet?  The result of echo
is 'using list, year is" rather than 'using list, year is 2005'.

==
list($year,$month,$day,$hour,$minute,$second,$fraction) =
get_object_vars($rec[0]);
echo "using list, year is $year";
==

This one works.  But I prefer using list.

==
$arr = get_object_vars($rec[0]);
echo "year is $arr[year]";
==

Thanks,

Bing

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



Re: [PHP] how should MS Access DATETIME be handled in PHP?

2006-04-13 Thread Bing Du
> I hate list. each to his own :-)
>
> try this (untested):
>
> list($year,$month,$day,$hour,$minute,$second,$fraction) =
> array_values(get_object_vars($rec[0]));
>

Magic!  That works.  In this case, I'd like to use list because I can use
the vars directly (e.g. $year) rather than $arr['year'].  I need to use
the date as key to construct another associative array.  It's easier for
me to do $projects[$year] instead of $projects[$arr['year']].

Thanks also for your other advice.  I appreciated it.

Bing

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



Re: [PHP] how should MS Access DATETIME be handled in PHP?

2006-04-13 Thread Bing Du
> Hi!
>
> Bing Du wrote:
>> Excellent!  Yes, it now does give me a clue to see what's actually in
>> the
>> object.  print_r($rec[0]) shows:
>>
>> stdClass Object ( [year] => 2005 [month] => 8 [day] => 31 [hour] => 0
>> [minute] => 0 [second] => 0 [fraction] => 0 )
>>
>> I've never dealt with object in PHP.  Something new learnt today.  I'm
>> now
>> able to use get_object_vars($rec[0]) to extract the info from the
>> object.
>
> You don't need get_object_vars(), you can simply use
>
> $rec[0]->year;
>

Ah, great.  Thanks much for the tip and the pointers.  That's even better.

Another question.  It's not hard to do this mapping.  But if given a month
like '9', is there any PHP function that can convert it to a full text
month name 'September'?

Bing

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



RE: [PHP] how should MS Access DATETIME be handled in PHP?

2006-04-13 Thread Bing Du
> I expect there's actually several ways, although I'm thinking it's likely
> that none of them is blindingly obvious.  Personally, I think I'd be
> inclined to do it like this:
>
>$mth = 9;
>echo date('F', mktime(12,0,0, $mth));
>

Interesting.  Thanks a bunch for the tip, Mike.  Appreciate it.

Bing

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



Re: [PHP] how should MS Access DATETIME be handled in PHP?

2006-04-14 Thread Bing Du
> While all the data-munging in PHP is very interesting...
>
> Might I suggest that you just use MySQL's date_format() function to
> ask MySQL to give you the data you want in the first place?
>
> Some purists would claim that the database is not the place to put
> presentation logic, of course.
>
> And for a large-scale library where other users might want to skin a
> different format, I couldn't agree more.
>
> But, really, for a small project, K.I.S.S. wins out, and having MySQL
> just hand you what you want instead of cluttering up your code with
> several lines (or a long multi-operation line) of PHP, seems like a
> cleaner solution.
>
> Not to mention that you'll have a lot less headaches like this one.
>
> http://mysql.com and search for "date_format"

Thanks, Richard.  I agree with you.  Is date_format() a MySQL specific
funtion?  If so, we're out of luck because our backend DB is MS Access.

Bing

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



[PHP] make keys of a associative array DB field names?

2006-04-14 Thread Bing Du
Hi,

Would anybody remind me how this should be achieved?

This returns all the names of the fields.

while( ($f = odbtp_fetch_field( $qry )) ) {
echo $f->name . "\n";
}

This returns the query results:

while( ($rec = odbtp_fetch_array($qry)) ) {
   foreach ($rec as $var) {
echo "$var\n";
   }
}

How should I connect them together?  Say, the fields are 'name', 'age',
'score'.  I want to print out $rec['name'], $rec['age'] and $rec['score']
rather than using $rec[0], $rec[1] and $rec[2].

Thanks in advance for any ideas,

Bing

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



Re: [PHP] how should MS Access DATETIME be handled in PHP?

2006-04-19 Thread Bing Du
> Do the search as Richard suggested.
>
> MS Access might have a similar function you can use, but you'll need
> to do some searching yourself to find the answer.
>
Sure.  I always appreciate various opinions.  I've checked with an Access
expert.  It can be done for Access like Format([DateFieldName], " 
").  But if fields of date type should be formated as needed in the
query, there is one situation in which I'm not clear how that would work. 
Say, I need to query all the fields from a table which has quite a fields.
 Some of the fields are of some kind of date type.  Enumerating the fields
is not feasible.

SELECT * from table;

So in this case, how should the date fields be formated in the query?

Thanks,

Bing

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



Re: [PHP] how should MS Access DATETIME be handled in PHP?

2006-04-20 Thread Bing Du
> I don't know if MS Access will behave the same, but in MySQL you can
> have a query like so:
>
> SELECT *, DATE_FORMAT(end_date, '%d %m %Y') as end_date_formatted FROM
> projects;
>
> And it will retrieve all columns from your projects table, plus the
> extra one you've created on the fly, and it will be named
> "end_date_formatted".

Great.  Thanks, John.  Yes, it works for Access as well.

Bing

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



[PHP] how to keep spaces in parameters in URL?

2006-04-24 Thread Bing Du
Hello,

==
Foo Bar";
?>
==

Then the URL showed up at the bottom border of the browser has 'name=foo'.

What should I do to have 'name=foo bar' in the URL?  I tried
htmlspecialchars but did not see any difference.

I'd appreciate any help.

Bing

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



[PHP] how to get the absolute path of an included file?

2006-04-27 Thread Bing Du
Hello,

Here are the two scripts.  The result is 'var is' rather than 'var is
foo'.  My suspect is I did not set the file path right in 'include'.  So
in file2.php, how should I get the actual absolute path it really gets for
file1.php?  Is it stored in some environment variable or something?  I'd
appreciate any help.

file1.php

==

==

file2.php

==

==

Thanks,

Bing

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



Re: [PHP] how to get the absolute path of an included file?

2006-04-28 Thread Bing Du
Thanks all who replied. So the include path used in file2.php should be
relative to the working directory where file2.php is located.  Yes, I have
error_reporting=E_ALL in my php.ini.  The log shows include_path=.|. 
But in my situation, it took me a while to figure out what that '.' really
means because file2.php is not an actual file on the filesystem. 
file2.php is a PHP content element in a web application.  Anyway, I've
figured out.

Bing

> 2006/4/27, Bing Du <[EMAIL PROTECTED]>:
>>
>> Hello,
>>
>> Here are the two scripts.  The result is 'var is' rather than 'var is
>> foo'.  My suspect is I did not set the file path right in 'include'.  So
>> in file2.php, how should I get the actual absolute path it really gets
>> for
>> file1.php?  Is it stored in some environment variable or something?  I'd
>> appreciate any help.
>>
>> file1.php
>>
>> => > $var = 'foo';
>> ?>
>> =>
>> file2.php
>>
>> => >
>> include '/some/path/file1.php';
>> echo "var is $var";
>> ?>
>> =>
>> Thanks,
>>
>> Bing
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
> Activate reporting of all errors either through php.ini or
> error_reporting(E_ALL);
> Use include_once instead of include. That way the program will stop if it
> couldn't include the file.
> Try using a relative path to the file.
>

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



[PHP] remove html tags in text?

2006-05-11 Thread Bing Du
Hello everyone,

Say, if I have a paragraph like this:

==
John Smith

Dr. Smith is the directory of http://some.center.com";>Some
Center .  His research interests include Wireless Security
==

Any functions that can help remove all the HTML tags in it?  What about
just removing selected tags, like ?

Thanks in advance for any ideas,

Bing

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



[PHP] access multiple databases

2005-08-16 Thread Bing Du

Hi,

I need to access both MySQL and SQL server 2000 in a PHP script on RHEL 
3.  In phpinfo(), I noticed 'supported databases' shows 'MySQL ODBC 
PostgreSQL Microsoft SQL Server FrontBase Oracle 8 (oci8)'.   And 
'Configure Command' has '--with-unixODBC=shared' included.  Do I need to 
 install anything else, like iodbc?


Would anybody give me some guidance how I should start from here?

Thanks,

Bing

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



[PHP] why memory limit is still being complained about?

2005-09-21 Thread Bing Du

Hi,

I'm installing and configuring Gallery 2.0.  One system check is check 
memory limit.  The warning is:



 Warning: Your PHP is configured to limit the memory to 8Mb 
(memory_limit parameter in php.ini). You should raise this limit to at 
least 16MB for proper Gallery operation.



I've already changed it to 30M in /etc/php.ini and restarted the web 
server (Apache/2.0.48 on RHEL 3).  And phpinfo() shows /etc/php.ini is 
the right config file that php uses.


Anybody have any clue what I missed here?

Bing

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



[PHP] protect password?

2005-11-04 Thread Bing Du
Hello,

Some functions need you to provide username and password, for instance 
odbc_connect.  Even though the username/password just has minimum access 
privileges to the resource, putting it there in clear text in a script gives 
me heartburn.  How do people handle username/password in such kind of cases? 
I'm sure there must be some way to store critical information in some 
encrypted format but it's still readable to scripts for authentication 
purpose.  But don't know how.  Any ideas or pointer would be greatly 
appreciated.

Bing 

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



[PHP] add more features on working php?

2005-11-18 Thread Bing Du

Hello,

PHP has already been installed through RPM. phpinfo() shows 
'--with-ldap'.  That's the only information about ldap.  I think there 
should be more than that if php were installed with ldap support 
properly.  So what should I check and get ldap support added?  Do I have 
to download PHP source and go through configure, make and make install?


Thanks in advance,

Bing

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



Re: [PHP] add more features on working php?

2005-11-18 Thread Bing Du

David Grant wrote:


Bing,

Have you checked for a php-ldap RPM?

Cheers,

David Grant

Bing Du wrote:


Hello,

PHP has already been installed through RPM. phpinfo() shows
'--with-ldap'.  That's the only information about ldap.  I think there
should be more than that if php were installed with ldap support
properly.  So what should I check and get ldap support added?  Do I have
to download PHP source and go through configure, make and make install?

Thanks in advance,

Bing



Thanks much for the hints.  I've just installed php-ldap.  Now running 
the script from the command like works.


% php test.php

Content-type: text/html
X-Powered-By: PHP/4.3.2

LDAP query testConnecting ...
connect result is Resource id #1Binding ...LDAP bind 
successful...Searching for (sAMAccountName=user) ...Search result is 
Resource id #2Number of entires returned is 0Getting entries 
...Data for 0 items returned:Closing connection


But in a web browser, it shows:

LDAP query test
Connecting ...
Fatal error: Call to undefined function: ldap_connect() in 
/home/user/public_html/test.php on line 17


hmmm...

Bing

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



Re: [PHP] add more features on working php?

2005-11-18 Thread Bing Du

Bing Du wrote:


David Grant wrote:


Bing,

Have you checked for a php-ldap RPM?

Cheers,

David Grant

Bing Du wrote:


Hello,

PHP has already been installed through RPM. phpinfo() shows
'--with-ldap'.  That's the only information about ldap.  I think there
should be more than that if php were installed with ldap support
properly.  So what should I check and get ldap support added?  Do I have
to download PHP source and go through configure, make and make install?

Thanks in advance,

Bing



Thanks much for the hints.  I've just installed php-ldap.  Now running 
the script from the command like works.


% php test.php

Content-type: text/html
X-Powered-By: PHP/4.3.2

LDAP query testConnecting ...
connect result is Resource id #1Binding ...LDAP bind 
successful...Searching for (sAMAccountName=user) ...Search result is 
Resource id #2Number of entires returned is 0Getting entries 
...Data for 0 items returned:Closing connection


But in a web browser, it shows:

LDAP query test
Connecting ...
Fatal error: Call to undefined function: ldap_connect() in 
/home/user/public_html/test.php on line 17


hmmm...

Bing


Forgot to mention, no change about ldap on phpinfo() after php-ldap was 
installed.  So it still just has '--with-ldap=shared' only.


Bing

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



Re: [PHP] add more features on working php?

2005-11-18 Thread Bing Du

Bing Du wrote:


Bing Du wrote:


David Grant wrote:


Bing,

Have you checked for a php-ldap RPM?

Cheers,

David Grant

Bing Du wrote:


Hello,

PHP has already been installed through RPM. phpinfo() shows
'--with-ldap'.  That's the only information about ldap.  I think there
should be more than that if php were installed with ldap support
properly.  So what should I check and get ldap support added?  Do I 
have

to download PHP source and go through configure, make and make install?

Thanks in advance,

Bing



Thanks much for the hints.  I've just installed php-ldap.  Now running 
the script from the command like works.


% php test.php

Content-type: text/html
X-Powered-By: PHP/4.3.2

LDAP query testConnecting ...
connect result is Resource id #1Binding ...LDAP bind 
successful...Searching for (sAMAccountName=user) ...Search result is 
Resource id #2Number of entires returned is 0Getting 
entries ...Data for 0 items returned:Closing connection


But in a web browser, it shows:

LDAP query test
Connecting ...
Fatal error: Call to undefined function: ldap_connect() in 
/home/user/public_html/test.php on line 17


hmmm...

Bing



Forgot to mention, no change about ldap on phpinfo() after php-ldap was 
installed.  So it still just has '--with-ldap=shared' only.


Bing


Never mind.  Restarting the web server fixed the problem.

Bing

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



[PHP] username format when binding to Active Directory?

2005-11-21 Thread Bing Du

Hello,

The following script returns 'LDAP bind failed...'.

";

$ldaprdn = "[EMAIL PROTECTED]";
$ldappass = "jsmithpass";

$ds=ldap_connect("ad.dept.some.edu");

if ($ds) {
   echo "Binding ...";
   $r=ldap_bind($ds, $ldaprdn, $ldappass);

   if ($r) {
   echo "LDAP bind successful...";
   } else {
   echo "LDAP bind failed...";
   }
} else {
 echo "LDAP connection failed...";
   }

?>

If I change $ldaprdn to be "CN=John 
Smith,OU=Users,OU=DEPT,DC=some,DC=edu", then bind returns 'LDAP bind 
successful...'.


However AD supports username to be in [EMAIL PROTECTED] format 
because querying from the command line works:


% ldapsearch -h ad.dept.some.edu -s sub -b "dc=dept,dc=some,dc=edu" -x 
-D [EMAIL PROTECTED] -W "samaccountname=jsmith"


Our AD only allows authenicated bindings.  We don't know user's DN 
before binding.  So anybody know how to make PHP allow 
$ldaprdn="[EMAIL PROTECTED]"?


Thanks in advance,

Bing

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



[PHP] can bind but cannot search?

2005-11-22 Thread Bing Du

Hello all,

The following script returns 'search failed...' after 'LDAP bind 
successful...'.


==
";
   $r=ldap_bind($ds, $ldaprdn, $ldappass);

   if ($r) {
   echo "LDAP bind successful...";
   } else {
   echo "LDAP bind failed...";
   exit;
   }

   $filter = "(sAMAccountName=jsmith)";
   $base = "DC=Coll,DC=some,DC=edu";

   $sr=ldap_search($ds, $base, $filter);

   if ($sr)
   {
 echo "Search result is " . $sr . "";
   } else {
 echo "search failed...";
  }
}
?>
==

However, the following ldapsearch returns the result fine.

% ldapsearch -h ad.coll.some.edu -s sub -b "dc=coll,dc=some,dc=edu" -x 
-D 'CN=John Smith,OU=Users,DC=Coll,DC=some,DC=edu' -W 
"samaccountname=jsmith"


I'm in dark now and don't know where to look for more information on why 
  ldap_search did not work.  I'd appreciate any help.


Bing

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



[PHP] Re: can bind but cannot search?

2005-11-22 Thread Bing Du

Bing Du wrote:

Hello all,

The following script returns 'search failed...' after 'LDAP bind 
successful...'.


==
";
   $r=ldap_bind($ds, $ldaprdn, $ldappass);

   if ($r) {
   echo "LDAP bind successful...";
   } else {
   echo "LDAP bind failed...";
   exit;
   }

   $filter = "(sAMAccountName=jsmith)";
   $base = "DC=Coll,DC=some,DC=edu";

   $sr=ldap_search($ds, $base, $filter);

   if ($sr)
   {
 echo "Search result is " . $sr . "";
   } else {
 echo "search failed...";
  }
}
?>
==

However, the following ldapsearch returns the result fine.

% ldapsearch -h ad.coll.some.edu -s sub -b "dc=coll,dc=some,dc=edu" -x 
-D 'CN=John Smith,OU=Users,DC=Coll,DC=some,DC=edu' -W 
"samaccountname=jsmith"


I'm in dark now and don't know where to look for more information on why 
  ldap_search did not work.  I'd appreciate any help.


Bing


I've figured out.  Adding 'ldap_set_option($ds, 
LDAP_OPT_PROTOCOL_VERSION, 3);' right after ldap_connect fixed the problem.


Bing

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



[PHP] how to exist within the context?

2005-11-22 Thread Bing Du

Hi,

One webpage has its banner, left menu and footer ect that are controled 
by the template.  I want this php script to output the form and 
processing result within the page structure.  Without exit, if the 
'yourname' field is empty, the script would output 'Please enter your 
name!' fine within the page structure (that is, banner, menu and footer 
are all there).  But obviously the script does not terminate as it's 
supposed to.  With exit, the script terminates fine, but it outputs the 
result in a page without banner, menu and footer.  So what's the correct 
way to get the script stop and output its results always in the page 
structure.









Thanks in advance,

Bing

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



[PHP] Re: username format when binding to Active Directory?

2005-11-22 Thread Bing Du

Bing Du wrote:


Hello,

The following script returns 'LDAP bind failed...'.

";

$ldaprdn = "[EMAIL PROTECTED]";
$ldappass = "jsmithpass";

$ds=ldap_connect("ad.dept.some.edu");

if ($ds) {
   echo "Binding ...";
   $r=ldap_bind($ds, $ldaprdn, $ldappass);

   if ($r) {
   echo "LDAP bind successful...";
   } else {
   echo "LDAP bind failed...";
   }
} else {
 echo "LDAP connection failed...";
   }

?>

If I change $ldaprdn to be "CN=John 
Smith,OU=Users,OU=DEPT,DC=some,DC=edu", then bind returns 'LDAP bind 
successful...'.


However AD supports username to be in [EMAIL PROTECTED] format 
because querying from the command line works:


% ldapsearch -h ad.dept.some.edu -s sub -b "dc=dept,dc=some,dc=edu" -x 
-D [EMAIL PROTECTED] -W "samaccountname=jsmith"


Our AD only allows authenicated bindings.  We don't know user's DN 
before binding.  So anybody know how to make PHP allow 
$ldaprdn="[EMAIL PROTECTED]"?


Thanks in advance,

Bing


Ok, I've figured it out again.  Removing the '\' in 
$ldaprdn="[EMAIL PROTECTED]' fixed the problem.  I thought it should 
be escaped.  But looks like it's not necessary.


Bing

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



Re: [PHP] how to exist within the context?

2005-11-22 Thread Bing Du

Thanks for the help.  But I still got:

Please enter your name! Continue processing...

What I want is if no name is entered, only 'Please enter your name!' 
should be returned.


Bing

David Grant wrote:


Hi,

Try this:



It's a hack, but it works.

Cheers,

David Grant

Bing Du wrote:


Hi,

One webpage has its banner, left menu and footer ect that are controled
by the template.  I want this php script to output the form and
processing result within the page structure.  Without exit, if the
'yourname' field is empty, the script would output 'Please enter your
name!' fine within the page structure (that is, banner, menu and footer
are all there).  But obviously the script does not terminate as it's
supposed to.  With exit, the script terminates fine, but it outputs the
result in a page without banner, menu and footer.  So what's the correct
way to get the script stop and output its results always in the page
structure.








Thanks in advance,

Bing



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



Re: [PHP] how to exist within the context?

2005-11-22 Thread Bing Du
Ummm...  but I don't see how that is related to my exit problem.  Any 
pointers for me to learn more about it?  Thanks much for the help.


Bing

Jay Blanchard wrote:


[snip]






[/snip]

You have to POST the value back to the form. This is one of the harder
concepts to grasp when programming in a stateless environment;









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



[PHP] syntax checking?

2005-11-22 Thread Bing Du

Hi,

How should PHP syntax be checked before execution?  Anything similar to 
what option -c does in Perl?


% perl -c test.pl

Thanks,

Bing

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



Re: [PHP] syntax checking?

2005-11-22 Thread Bing Du

Jay Blanchard wrote:


[snip]
How should PHP syntax be checked before execution?  Anything similar to 
what option -c does in Perl?


% perl -c test.pl
[/snip]

from the command line

/usr/local/bin/php -i myScript.php
[/snip]

Ooops, sorry, should be an ell "l"

/usr/local/bin/php -l myScript.php


Too late :).  I've already tried -i.  Boy, that returns tons of 
information .  My machine was choked.


Bing

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



Re: [PHP] syntax checking?

2005-11-23 Thread Bing Du

Bing Du wrote:


Jay Blanchard wrote:


[snip]
How should PHP syntax be checked before execution?  Anything similar 
to what option -c does in Perl?


% perl -c test.pl
[/snip]

from the command line

/usr/local/bin/php -i myScript.php
[/snip]

Ooops, sorry, should be an ell "l"

/usr/local/bin/php -l myScript.php



Too late :).  I've already tried -i.  Boy, that returns tons of 
information .  My machine was choked.


Bing


Even with error_reporting set to E_ALL in php.ini, I still get 'Errors 
parsing file.php' using the php command with the -l option.  Anyway to 
see more than that?


Thanks,

Bing

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



Re: [PHP] syntax checking?

2005-11-23 Thread Bing Du

Jay Blanchard wrote:


[snip]
Even with error_reporting set to E_ALL in php.ini, I still get 'Errors 
parsing file.php' using the php command with the -l option.  Anyway to 
see more than that?

[/snip]

Here are some command line options http://us2.php.net/features.commandline

You could run it in a browser to get line numbers and more precise error
messages


Just found out this web based PHP syntax checking tool 
http://www.meandeviation.com/tutorials/learnphp/php-syntax-check/, it 
helped me find the problem.  Pretty nice.


Bing

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



[PHP] how to resolve this conflict?

2005-12-01 Thread Bing Du

Hello,

I've already posted it on the MySQL General Discussion list.  Thought I 
wanted to try this list as well in case somebody knows.


5.0.11-beta-standard is already running.  Now I need to install php-mysql
which requires mysql-3.23.58-15.RHEL3.1.i3.

Here is what I did and the errors I got:


$ sudo up2date -i php-mysql
Password:

Fetching Obsoletes list for channel: rhel-i386-ws-3...

Fetching Obsoletes list for channel: rhel-i386-ws-3-extras...

Fetching Obsoletes list for channel: dag-ws...

Fetching Obsoletes list for channel: isl-channel-ws...

Fetching Obsoletes list for channel: dag...

Fetching rpm headers...


NameVersionRel
--
php-mysql   4.3.2  26.ent 
 i386



Testing package set / solving RPM inter-dependencies...

Downloading headers to solve dependencies...

php-mysql-4.3.2-26.ent.i386 ## Done.
mysql-3.23.58-15.RHEL3.1.i3 ## Done.
Preparing  ### [100%]
An error has occurred:
Failed running transaction of  packages:
('file /usr/bin/comp_err from install of mysql-3.23.58-15.RHEL3.1
conflicts with file from package MySQL-devel-standard-5.0.11-0.rhel3', (7,
'/usr/bin/comp_err', 0L))
('file /usr/bin/mysql_config from install of mysql-3.23.58-15.RHEL3.1
conflicts with file from package MySQL-devel-standard-5.0.11-0.rhel3', (7,
'/usr/bin/mysql_config', 0L))

See /var/log/up2date for more information
///

More information I found in /var/log/up2date is:

//
[Thu Dec  1 12:50:02 2005] up2date updating login info
[Thu Dec  1 12:50:02 2005] up2date logging into up2date server
[Thu Dec  1 12:50:03 2005] up2date successfully retrieved authentication
token from up2date server
[Thu Dec  1 12:50:03 2005] up2date availablePackageList from network
[Thu Dec  1 12:50:03 2005] up2date Unable to import repomd support so
repomd support w
ill not be available
[Thu Dec  1 12:50:15 2005] up2date solving dep for: ['libmysqlclient.so.10']
[Thu Dec  1 12:50:19 2005] up2date solving dep for: ['libmysqlclient.so.10']
[Thu Dec  1 12:50:22 2005] up2date installing packages:
['php-mysql-4.3.2-26.ent', 'mysql-3.23.58-15.RHEL3.1']
[Thu Dec  1 12:50:25 2005] up2date Failed running transaction of  packages:
('file /usr/bin/comp_err from install of mysql-3.23.58-15.RHEL3.1
conflicts with file from package MySQL-devel-standard-5.0.11-0.rhel3', (7,
'/usr/bin/comp_err', 0L))
('file /usr/bin/mysql_config from install of mysql-3.23.58-15.RHEL3.1
conflicts with file from package MySQL-devel-standard-5.0.11-0.rhel3', (7,
'/usr/bin/mysql_config', 0L))

[Thu Dec  1 12:50:25 2005] up2date   File "/usr/sbin/up2date", line 1265,
in ?
sys.exit(main() or 0)
   File "/usr/sbin/up2date", line 800, in main
fullUpdate, dryRun=options.dry_run))
   File "/usr/sbin/up2date", line 1137, in batchRun
batch.run()
   File "/usr/share/rhn/up2date_client/up2dateBatch.py", line 90, in run
self.__installPackages()
   File "/usr/share/rhn/up2date_client/up2dateBatch.py", line 174, in
__installPackages
self.kernelsToInstall =
up2date.installPackages(self.packagesToInstall, self.rpmCallback)
   File "/usr/share/rhn/up2date_client/up2date.py", line 749, in
installPackages
runTransaction(ts, added, removed,rpmCallback, rollbacktrans =
rollbacktrans)
   File "/usr/share/rhn/up2date_client/up2date.py", line 634, in
runTransaction
rpmUtils.runTransaction(ts,rpmCallback, transdir)
   File "/usr/share/rhn/up2date_client/rpmUtils.py", line 520, in
runTransaction
"Failed running transaction of  packages: %s") % errors, deps=rc)
//

So any way to walk around this conflict?  Thanks in advance for any
suggestions.

Bing
Bing

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



[PHP] Re: how to resolve this conflict?

2005-12-01 Thread Bing Du

James Benson wrote:

You obviously need to remove the old package or compile your own from 
source




Bing Du wrote:


Hello,

I've already posted it on the MySQL General Discussion list.  Thought 
I wanted to try this list as well in case somebody knows.


5.0.11-beta-standard is already running.  Now I need to install php-mysql
which requires mysql-3.23.58-15.RHEL3.1.i3.

Here is what I did and the errors I got:


$ sudo up2date -i php-mysql
Password:

Fetching Obsoletes list for channel: rhel-i386-ws-3...

Fetching Obsoletes list for channel: rhel-i386-ws-3-extras...

Fetching Obsoletes list for channel: dag-ws...

Fetching Obsoletes list for channel: isl-channel-ws...

Fetching Obsoletes list for channel: dag...

Fetching rpm headers...


NameVersionRel
--
php-mysql   4.3.2  26.ent  i386


Testing package set / solving RPM inter-dependencies...

Downloading headers to solve dependencies...

php-mysql-4.3.2-26.ent.i386 ## Done.
mysql-3.23.58-15.RHEL3.1.i3 ## Done.
Preparing  ### [100%]
An error has occurred:
Failed running transaction of  packages:
('file /usr/bin/comp_err from install of mysql-3.23.58-15.RHEL3.1
conflicts with file from package MySQL-devel-standard-5.0.11-0.rhel3', 
(7,

'/usr/bin/comp_err', 0L))
('file /usr/bin/mysql_config from install of mysql-3.23.58-15.RHEL3.1
conflicts with file from package MySQL-devel-standard-5.0.11-0.rhel3', 
(7,

'/usr/bin/mysql_config', 0L))

See /var/log/up2date for more information
///

More information I found in /var/log/up2date is:

//
[Thu Dec  1 12:50:02 2005] up2date updating login info
[Thu Dec  1 12:50:02 2005] up2date logging into up2date server
[Thu Dec  1 12:50:03 2005] up2date successfully retrieved authentication
token from up2date server
[Thu Dec  1 12:50:03 2005] up2date availablePackageList from network
[Thu Dec  1 12:50:03 2005] up2date Unable to import repomd support so
repomd support w
ill not be available
[Thu Dec  1 12:50:15 2005] up2date solving dep for: 
['libmysqlclient.so.10']
[Thu Dec  1 12:50:19 2005] up2date solving dep for: 
['libmysqlclient.so.10']

[Thu Dec  1 12:50:22 2005] up2date installing packages:
['php-mysql-4.3.2-26.ent', 'mysql-3.23.58-15.RHEL3.1']
[Thu Dec  1 12:50:25 2005] up2date Failed running transaction of  
packages:

('file /usr/bin/comp_err from install of mysql-3.23.58-15.RHEL3.1
conflicts with file from package MySQL-devel-standard-5.0.11-0.rhel3', 
(7,

'/usr/bin/comp_err', 0L))
('file /usr/bin/mysql_config from install of mysql-3.23.58-15.RHEL3.1
conflicts with file from package MySQL-devel-standard-5.0.11-0.rhel3', 
(7,

'/usr/bin/mysql_config', 0L))

[Thu Dec  1 12:50:25 2005] up2date   File "/usr/sbin/up2date", line 1265,
in ?
sys.exit(main() or 0)
   File "/usr/sbin/up2date", line 800, in main
fullUpdate, dryRun=options.dry_run))
   File "/usr/sbin/up2date", line 1137, in batchRun
batch.run()
   File "/usr/share/rhn/up2date_client/up2dateBatch.py", line 90, in run
self.__installPackages()
   File "/usr/share/rhn/up2date_client/up2dateBatch.py", line 174, in
__installPackages
self.kernelsToInstall =
up2date.installPackages(self.packagesToInstall, self.rpmCallback)
   File "/usr/share/rhn/up2date_client/up2date.py", line 749, in
installPackages
runTransaction(ts, added, removed,rpmCallback, rollbacktrans =
rollbacktrans)
   File "/usr/share/rhn/up2date_client/up2date.py", line 634, in
runTransaction
rpmUtils.runTransaction(ts,rpmCallback, transdir)
   File "/usr/share/rhn/up2date_client/rpmUtils.py", line 520, in
runTransaction
"Failed running transaction of  packages: %s") % errors, deps=rc)
//

So any way to walk around this conflict?  Thanks in advance for any
suggestions.

Bing


I remember it's possible to install several versions of MySQL and pick 
one depending on your need, but I cannot find where I saw it anymore. 
Anybody know where that information is?


Thanks,

Bing

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



[PHP] generate database driven web pages

2006-01-17 Thread Bing Du

Hello everyone,

Here is what I want to accomplish.  Query the backend database and 
generate a page listing all the staff members in table format that has 
name, title, phone and office address.  Staff name should be a link. 
Clicking the link should query the database again and use the 
information retrieved (e.g. projects, educations, etc.) to generate a 
page for each staff member.  A staff list page can be generated pretty 
easily.


Now my question is how to keep the staffID (although it is not shown on 
the staff list page, but is queried along with name, title, etc.) so 
that when a staff name is clicked, his/her staffID will then be used to 
query the DB for personal information.


Anybody have any handy working examples to give me some hints?

Thanks in advance for any help.

Bing

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