RE: [PHP] Confused

2008-09-02 Thread Simcha
This does not seem to be an installation problem -

Your test [(!$connect_id = ] fails, since the connect returns false, so it
does not run the condition.

Compare:
?php

if($a = false){echo no good;}else{echo condition true;}

?



-Original Message-
From: Dan Shirah [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, September 02, 2008 7:31 PM
To: PHP List
Subject: [PHP] Confused

All,

Okay, I am a bit confused.   I'm setting up another server to host PHP
pages.  I followed everything in the Manual for installing PHP.  I'm running
Windows Server 2003, IIS6.0 and PHP 5.2.6.

And...it kind of works...

If I do: ?php echo Test; ? it prints fine.
If I do: Today is: ?php echo date(l, F j, Y); ? it prints fine.

If I do: You are recognized as: ?php echo substr($_SERVER['AUTH_USER'],
13); ? I get no output.
If I do:
 if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) { //
THE ACTUAL CONNECTION
 echo Unable to connect to Informix Database\n; // DISPLAY IF
CONNECTION FAILS
 exit();
  }

I don't get a connection to the database and the Unable to connect to
Informix Database\n; does not even display.

I get no errors output to the screen and I have display_errors = On
And I have error_reporting = E_ALL  ~E_NOTICE

Any ideas?

No virus found in this incoming message.
Checked by AVG - http://www.avg.com 
Version: 8.0.169 / Virus Database: 270.6.14/1646 - Release Date: 02/09/2008
06:02


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



Re: [PHP] Confused

2008-09-02 Thread Robert Cummings
On Tue, 2008-09-02 at 13:31 -0400, Dan Shirah wrote:
 All,
 
 Okay, I am a bit confused.   I'm setting up another server to host PHP
 pages.  I followed everything in the Manual for installing PHP.  I'm running
 Windows Server 2003, IIS6.0 and PHP 5.2.6.
 
 And...it kind of works...
 
 If I do: ?php echo Test; ? it prints fine.
 If I do: Today is: ?php echo date(l, F j, Y); ? it prints fine.
 
 If I do: You are recognized as: ?php echo substr($_SERVER['AUTH_USER'],
 13); ? I get no output.

Add the following:

?php

echo 'pre'.\n
print_r( $_SERVER );
echo '/pre'.\n;

?

See if the AUTH_USER entry is in there.

 If I do:
  if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) { //
 THE ACTUAL CONNECTION
  echo Unable to connect to Informix Database\n; // DISPLAY IF
 CONNECTION FAILS
  exit();
   }
 
 I don't get a connection to the database and the Unable to connect to
 Informix Database\n; does not even display.

Shouldn't that be:

if( !($connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) )

I think PHP may support the style you've used, but I sure as heck
wouldn't use it.

How do you know you don't get a connection to the database? What is the
value of $connect_id? Use var_dump( $connect_id ) to find out.

 I get no errors output to the screen and I have display_errors = On
 And I have error_reporting = E_ALL  ~E_NOTICE

Maybe turn on notices as well. That will probably generate a notice for
the missing AUTH_USER index.

 
 Any ideas?
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Confused

2008-09-02 Thread Dan Shirah
If it was that simple then the second line: echo Unable to connect to
Informix Database\n;  would execute upon the connection failing and that
message would be output to my screen.  I get Nothing.

Just as a simple call to ?php echo substr($_SERVER['AUTH_USER'], 13); ?
returns nothing as well.


On 9/2/08, Simcha [EMAIL PROTECTED] wrote:

 This does not seem to be an installation problem -

 Your test [(!$connect_id = ] fails, since the connect returns false, so it
 does not run the condition.

 Compare:
 ?php

 if($a = false){echo no good;}else{echo condition true;}

 ?



 -Original Message-
 From: Dan Shirah [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, September 02, 2008 7:31 PM
 To: PHP List
 Subject: [PHP] Confused

 All,

 Okay, I am a bit confused.   I'm setting up another server to host PHP
 pages.  I followed everything in the Manual for installing PHP.  I'm
 running
 Windows Server 2003, IIS6.0 and PHP 5.2.6.

 And...it kind of works...

 If I do: ?php echo Test; ? it prints fine.
 If I do: Today is: ?php echo date(l, F j, Y); ? it prints fine.

 If I do: You are recognized as: ?php echo substr($_SERVER['AUTH_USER'],
 13); ? I get no output.
 If I do:
 if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) { //
 THE ACTUAL CONNECTION
 echo Unable to connect to Informix Database\n; // DISPLAY IF
 CONNECTION FAILS
 exit();
 }

 I don't get a connection to the database and the Unable to connect to
 Informix Database\n; does not even display.

 I get no errors output to the screen and I have display_errors = On
 And I have error_reporting = E_ALL  ~E_NOTICE

 Any ideas?

 No virus found in this incoming message.
 Checked by AVG - http://www.avg.com
 Version: 8.0.169 / Virus Database: 270.6.14/1646 - Release Date: 02/09/2008
 06:02




RE: [PHP] Confused

2008-09-02 Thread Simcha

Ignore my previous email - 
It was sloppy. I was not focusing on the email.

SY
-Original Message-
From: Simcha [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, September 02, 2008 8:41 PM
To: 'Dan Shirah'; 'PHP List'
Subject: RE: [PHP] Confused

This does not seem to be an installation problem -

Your test [(!$connect_id = ] fails, since the connect returns false, so it
does not run the condition.

Compare:
?php

if($a = false){echo no good;}else{echo condition true;}

?



-Original Message-
From: Dan Shirah [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, September 02, 2008 7:31 PM
To: PHP List
Subject: [PHP] Confused

All,

Okay, I am a bit confused.   I'm setting up another server to host PHP
pages.  I followed everything in the Manual for installing PHP.  I'm running
Windows Server 2003, IIS6.0 and PHP 5.2.6.

And...it kind of works...

If I do: ?php echo Test; ? it prints fine.
If I do: Today is: ?php echo date(l, F j, Y); ? it prints fine.

If I do: You are recognized as: ?php echo substr($_SERVER['AUTH_USER'],
13); ? I get no output.
If I do:
 if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) { //
THE ACTUAL CONNECTION
 echo Unable to connect to Informix Database\n; // DISPLAY IF
CONNECTION FAILS
 exit();
  }

I don't get a connection to the database and the Unable to connect to
Informix Database\n; does not even display.

I get no errors output to the screen and I have display_errors = On
And I have error_reporting = E_ALL  ~E_NOTICE

Any ideas?

No virus found in this incoming message.
Checked by AVG - http://www.avg.com 
Version: 8.0.169 / Virus Database: 270.6.14/1646 - Release Date: 02/09/2008
06:02


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

No virus found in this incoming message.
Checked by AVG - http://www.avg.com 
Version: 8.0.169 / Virus Database: 270.6.14/1646 - Release Date: 02/09/2008
06:02


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



Re: [PHP] Confused

2008-09-02 Thread brian

Dan Shirah wrote:

All,

Okay, I am a bit confused.   I'm setting up another server to host PHP
pages.  I followed everything in the Manual for installing PHP.  I'm running
Windows Server 2003, IIS6.0 and PHP 5.2.6.

And...it kind of works...

If I do: ?php echo Test; ? it prints fine.
If I do: Today is: ?php echo date(l, F j, Y); ? it prints fine.

If I do: You are recognized as: ?php echo substr($_SERVER['AUTH_USER'],
13); ? I get no output.


AUTH_USER will be empty unless the user has logged in (using whatever 
Microsoft's equivalent of htpasswd/htdigest is). As suggested 
previously, print $_SERVER to ensure it's set.



If I do:
 if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) { //
THE ACTUAL CONNECTION
 echo Unable to connect to Informix Database\n; // DISPLAY IF
CONNECTION FAILS
 exit();
  }

I don't get a connection to the database and the Unable to connect to
Informix Database\n; does not even display.

I get no errors output to the screen and I have display_errors = On
And I have error_reporting = E_ALL  ~E_NOTICE

Any ideas?




$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass);

var_dump($connect_id);

And, to be sure, maybe echo $database, $host, $user, and $pass.

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



Re: [PHP] Confused

2008-09-02 Thread Dan Shirah

 Add the following:

 ?php

 echo 'pre'.\n
 print_r( $_SERVER );
 echo '/pre'.\n;

 ?

 See if the AUTH_USER entry is in there.


AUTH_USER shows up, but does not have a value. From the output of phpinfo()
it says, No value

How do you know you don't get a connection to the database? What is the
 value of $connect_id? Use var_dump( $connect_id ) to find out.


I know it isn't connecting because I can go to the database and see that
there is no active connections to it.


Re: [PHP] Confused

2008-09-02 Thread Robert Cummings
On Tue, 2008-09-02 at 14:27 -0400, Dan Shirah wrote:
 
  Add the following:
 
  ?php
 
  echo 'pre'.\n
  print_r( $_SERVER );
  echo '/pre'.\n;
 
  ?
 
  See if the AUTH_USER entry is in there.
 
 
 AUTH_USER shows up, but does not have a value. From the output of phpinfo()
 it says, No value
 
 How do you know you don't get a connection to the database? What is the
  value of $connect_id? Use var_dump( $connect_id ) to find out.
 
 
 I know it isn't connecting because I can go to the database and see that
 there is no active connections to it.

So you're script runs long enough for you to check?

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Confused

2008-09-02 Thread Eric Butera
On Tue, Sep 2, 2008 at 1:46 PM, Dan Shirah [EMAIL PROTECTED] wrote:
 If it was that simple then the second line: echo Unable to connect to
 Informix Database\n;  would execute upon the connection failing and that
 message would be output to my screen.  I get Nothing.

 Just as a simple call to ?php echo substr($_SERVER['AUTH_USER'], 13); ?
 returns nothing as well.


 On 9/2/08, Simcha [EMAIL PROTECTED] wrote:

 This does not seem to be an installation problem -

 Your test [(!$connect_id = ] fails, since the connect returns false, so it
 does not run the condition.

 Compare:
 ?php

 if($a = false){echo no good;}else{echo condition true;}

 ?



 -Original Message-
 From: Dan Shirah [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, September 02, 2008 7:31 PM
 To: PHP List
 Subject: [PHP] Confused

 All,

 Okay, I am a bit confused.   I'm setting up another server to host PHP
 pages.  I followed everything in the Manual for installing PHP.  I'm
 running
 Windows Server 2003, IIS6.0 and PHP 5.2.6.

 And...it kind of works...

 If I do: ?php echo Test; ? it prints fine.
 If I do: Today is: ?php echo date(l, F j, Y); ? it prints fine.

 If I do: You are recognized as: ?php echo substr($_SERVER['AUTH_USER'],
 13); ? I get no output.
 If I do:
 if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) { //
 THE ACTUAL CONNECTION
 echo Unable to connect to Informix Database\n; // DISPLAY IF
 CONNECTION FAILS
 exit();
 }

 I don't get a connection to the database and the Unable to connect to
 Informix Database\n; does not even display.

 I get no errors output to the screen and I have display_errors = On
 And I have error_reporting = E_ALL  ~E_NOTICE

 Any ideas?

 No virus found in this incoming message.
 Checked by AVG - http://www.avg.com
 Version: 8.0.169 / Virus Database: 270.6.14/1646 - Release Date: 02/09/2008
 06:02




Look at your server error log.  Maybe you have a parse error or
something that prevents it from getting to the screen.

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



Re: [PHP] Confused

2008-09-02 Thread Dan Shirah

 So you're script runs long enough for you to check?

 Cheers,
 Rob.


if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) {

Checks to see if it doesn't connect.  If it does connect the page continues
to process.  If it doesn't connect the error is displayed.
echo Unable to connect to Informix Database\n;

If I put in the following:

echo Point 1;
if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) { // THE
ACTUAL CONNECTION
echo Point 2;
 echo Unable to connect to Informix Database\n; // DISPLAY IF
CONNECTION FAILS
echo Point 3;
 exit();
  }
echo Point 4;

The only thing that is output to my screen is Point 1


Re: [PHP] Confused

2008-09-02 Thread Robert Cummings
On Tue, 2008-09-02 at 14:43 -0400, Dan Shirah wrote:
 So you're script runs long enough for you to check?
 
 Cheers,
 Rob.
  
 if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) {
  
 Checks to see if it doesn't connect.  If it does connect the page
 continues to process.  If it doesn't connect the error is displayed.
 echo Unable to connect to Informix Database\n; 
  
 If I put in the following:
  
 echo Point 1;
 if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) { //
 THE ACTUAL CONNECTION
 echo Point 2;
  echo Unable to connect to Informix Database\n; // DISPLAY IF
 CONNECTION FAILS
 echo Point 3;
  exit();
   }
 echo Point 4;
  
 The only thing that is output to my screen is Point 1

Your script is dying then. What does the error log say? Are you sure PHP
is using the php.ini you think it's using? Double check by using
phpinfo().

Cheers,
Rob.

-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Confused

2008-09-02 Thread Robert Cummings
On Tue, 2008-09-02 at 14:46 -0400, Robert Cummings wrote:
 On Tue, 2008-09-02 at 14:43 -0400, Dan Shirah wrote:
  So you're script runs long enough for you to check?
  
  Cheers,
  Rob.
   
  if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) {
   
  Checks to see if it doesn't connect.  If it does connect the page
  continues to process.  If it doesn't connect the error is displayed.
  echo Unable to connect to Informix Database\n; 
   
  If I put in the following:
   
  echo Point 1;
  if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) { //
  THE ACTUAL CONNECTION
  echo Point 2;
   echo Unable to connect to Informix Database\n; // DISPLAY IF
  CONNECTION FAILS
  echo Point 3;
   exit();
}
  echo Point 4;
   
  The only thing that is output to my screen is Point 1
 
 Your script is dying then. What does the error log say? Are you sure PHP
 is using the php.ini you think it's using? Double check by using
 phpinfo().

BTW, my guess is that ifx_connect() doesn't exist. Possibly you don't
have ifx support.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Confused

2008-09-02 Thread Dan Shirah

 Your script is dying then. What does the error log say? Are you sure PHP
 is using the php.ini you think it's using? Double check by using
 phpinfo().

 Cheers,
 Rob.


It is VERY strange!  phpinfo() shows that it is using C:\Windows\php.ini

phpinfo() also shows display_errors = Off but when I go to the
C:\Windows\php.ini file it says display_errors = On...


Re: [PHP] Confused

2008-09-02 Thread Robert Cummings
On Tue, 2008-09-02 at 14:58 -0400, Dan Shirah wrote:
 Your script is dying then. What does the error log say? Are
 you sure PHP
 is using the php.ini you think it's using? Double check by
 using
 phpinfo().
 
 Cheers,
 Rob.
  
 It is VERY strange!  phpinfo() shows that it is using C:\Windows
 \php.ini
  
 phpinfo() also shows display_errors = Off but when I go to the C:
 \Windows\php.ini file it says display_errors = On...

Does your script, the apache conf, virtual host conf, or a .htaccess
conf modify this setting? perhaps php.ini has more than one
display_errors entries?

Cheers,
Rob.

-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Confused

2008-09-02 Thread Diogo Neves
On Tue, Sep 2, 2008 at 7:58 PM, Dan Shirah [EMAIL PROTECTED] wrote:

 
  Your script is dying then. What does the error log say? Are you sure PHP
  is using the php.ini you think it's using? Double check by using
  phpinfo().
 
  Cheers,
  Rob.


 It is VERY strange!  phpinfo() shows that it is using C:\Windows\php.ini

 phpinfo() also shows display_errors = Off but when I go to the
 C:\Windows\php.ini file it says display_errors = On...


You can be rewriting it on your vistualhost or in a script somewhere...

-- 
Thanks for your attention,

Diogo Neves
Web Developer @ SAPO.pt by PrimeIT.pt


Re: [PHP] Confused

2008-09-02 Thread Diogo Neves
On Tue, Sep 2, 2008 at 8:04 PM, Robert Cummings [EMAIL PROTECTED]wrote:

 On Tue, 2008-09-02 at 14:58 -0400, Dan Shirah wrote:
  Your script is dying then. What does the error log say? Are
  you sure PHP
  is using the php.ini you think it's using? Double check by
  using
  phpinfo().
 
  Cheers,
  Rob.
 
  It is VERY strange!  phpinfo() shows that it is using C:\Windows
  \php.ini
 
  phpinfo() also shows display_errors = Off but when I go to the C:
  \Windows\php.ini file it says display_errors = On...

 Does your script, the apache conf, virtual host conf, or a .htaccess
 conf modify this setting? perhaps php.ini has more than one
 display_errors entries?

 Cheers,
 Rob.

 --
 http://www.interjinn.com
 Application and Templating Framework for PHP


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

 And all other possible places :)


-- 
Thanks for your attention,

Diogo Neves
Web Developer @ SAPO.pt by PrimeIT.pt


Re: [PHP] Confused

2008-09-02 Thread David Giragosian
On 9/2/08, Dan Shirah [EMAIL PROTECTED] wrote:

 
  Your script is dying then. What does the error log say? Are you sure PHP
  is using the php.ini you think it's using? Double check by using
  phpinfo().
 
  Cheers,
  Rob.


 It is VERY strange!  phpinfo() shows that it is using C:\Windows\php.ini

 phpinfo() also shows display_errors = Off but when I go to the
 C:\Windows\php.ini file it says display_errors = On...


Have you restarted the server since changes were made?

David


Re: [PHP] Confused

2008-09-02 Thread Dan Shirah
 Does your script, the apache conf, virtual host conf, or a .htaccess
 conf modify this setting? perhaps php.ini has more than one
 display_errors entries?

 Cheers,
 Rob.


PROGRESS!  It just clicked!

About 3 years ago when I setup my first PHP server on Windows I saw someone
mention that certain versions of ntwdblib.dll were causing all kinds of
problems.

I copied the ntwdblib.dll from one of my current servers and now I am at
least getting the connection errors!  YAY!

So now my connection error is probably in my ODBC mapping.

But I still need to figure out why AUTH_USER is still No Value


Re: [PHP] Confused

2008-09-02 Thread Eric Butera
On Tue, Sep 2, 2008 at 2:49 PM, Robert Cummings [EMAIL PROTECTED] wrote:
 On Tue, 2008-09-02 at 14:46 -0400, Robert Cummings wrote:
 On Tue, 2008-09-02 at 14:43 -0400, Dan Shirah wrote:
  So you're script runs long enough for you to check?
 
  Cheers,
  Rob.
 
  if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) {
 
  Checks to see if it doesn't connect.  If it does connect the page
  continues to process.  If it doesn't connect the error is displayed.
  echo Unable to connect to Informix Database\n;
 
  If I put in the following:
 
  echo Point 1;
  if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) { //
  THE ACTUAL CONNECTION
  echo Point 2;
   echo Unable to connect to Informix Database\n; // DISPLAY IF
  CONNECTION FAILS
  echo Point 3;
   exit();
}
  echo Point 4;
 
  The only thing that is output to my screen is Point 1

 Your script is dying then. What does the error log say? Are you sure PHP
 is using the php.ini you think it's using? Double check by using
 phpinfo().

 BTW, my guess is that ifx_connect() doesn't exist. Possibly you don't
 have ifx support.

 Cheers,
 Rob.
 --
 http://www.interjinn.com
 Application and Templating Framework for PHP


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



Yea I thought the same that is why I recommended the looking at logs idea.

Perhaps maybe just running form cli will do it:

[EMAIL PROTECTED]:~/Sites$ php5 blah.php
Point 1
Fatal error: Call to undefined function ifx_connect() in
/home/eric/Sites/blah.php on line 3

Call Stack:
0.0002  60252   1. {main}() /home/eric/Sites/blah.php:0

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



Re: [PHP] Confused

2008-09-02 Thread Dan Shirah

 Yea I thought the same that is why I recommended the looking at logs idea.

 Perhaps maybe just running form cli will do it:

 [EMAIL PROTECTED]:~/Sites$ php5 blah.php
 Point 1
 Fatal error: Call to undefined function ifx_connect() in
 /home/eric/Sites/blah.php on line 3



You probably don't have extension=php_ifx.dll uncommented? Or you don't have
php_ifx.dll in your ext folder?


Re: [PHP] Confused

2008-09-02 Thread Eric Butera
On Tue, Sep 2, 2008 at 3:15 PM, Dan Shirah [EMAIL PROTECTED] wrote:
 Yea I thought the same that is why I recommended the looking at logs idea.

 Perhaps maybe just running form cli will do it:

 [EMAIL PROTECTED]:~/Sites$ php5 blah.php
 Point 1
 Fatal error: Call to undefined function ifx_connect() in
 /home/eric/Sites/blah.php on line 3



 You probably don't have extension=php_ifx.dll uncommented? Or you don't have
 php_ifx.dll in your ext folder?



I don't use windows.  I knew I didn't have it enabled. :)

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



Re: [PHP] Confused

2008-09-02 Thread Dan Shirah
[SOLVED]

Just wanted to let you all know I resolved all my problems.

AUTH_USER holds a value once I go into IIS/Default Website and go tot he
properties of my application folder.  Deselect the Anonymous Access and
check Intergrated Windows Authentication.

For my connection issue I needed version 2000.2.8.0 of the ntwdblib.dll
file.  The newer version causes issues and will not allow you to connect to
an informix database.

Thanks to everyone that helped.

Dan


Re: [PHP] Confused about handling bytes

2007-05-20 Thread Tom Rogers
Hi,

Monday, May 21, 2007, 10:50:27 AM, you wrote:
JV While I'm sure this is a stupid question and the solution will be 
JV obvious to everyone here, this is confusing me.

JV I'm trying to control a device over a serial port using a PHP script, 
JV and one of the things I need to do is read a 26-byte string from an 
JV EEPROM, using a command that returns two bytes at a time, and write 
JV similar strings using a similar command. For example, to read the first
JV two bytes of one such string beginning at address 0x484, I would send:

JV 04 84 00 00 BB

JV Here's the code I've written so far:

JV $string = 1; //which of 200 strings I want to read
JV $base = pack(H*,dechex((($string-1)*hexdec(0x1a))+hexdec(0x484))); 
JV //calculate the base address of the string (the first starts at 0x484)
JV for($i=0;$i  13;$i++) { //iterate 13 times (26 bytes / 2 bytes at a time)
JV dio_write($serial,$base.\x00\x00\xbb,5); //send the command
JV $output[] = dio_read($serial,1);  // read first byte
JV $output[] = dio_read($serial,1); // read second byte
JV $base = pack(H*,dechex(hexdec(bin2hex($base))+2)); //increment address
JV }

JV There are two things wrong with this. First, the final line isn't doing
JV what it's supposed to. Instead of adding 2 to the value of $base each 
JV time, It's producing a pattern like this:

JV 0x484, 0x486, 0x73, 0x73, 0x73, 0x488, 0x48a, 0x48c, 0x48e, 0x490, 0x74,
JV 0x74, 0x74

JV Second, the format of $base doesn't seem to be handled correctly in line
JV 4 of the above code. Given a value of 0x484, this line should write the
JV bytes 04 84, but it is obviously not doing so, given the response I 
JV get from the device (it sends FF FF instead of the expected value at
JV that address, which I get when I remove the variable and manually 
JV specify the address).

JV What are the solutions to these problems?

JV Thanks,
JV -Joe Veldhuis


Do your packing after all the calculations:

?php
$output = array();
$string = 1;
for(
  $i=0, $base = (($string-1) * 26) + 0x484; 
  $i  26;
  $i++, $base += 2)
{
$binarydata = pack(nc*, $base, 0, 0, 0xBB);
dio_write($serial,$k=strlen($binarydata),5); //send the command
$output[] = dio_read($serial,1);  // read first byte
$output[] = dio_read($serial,1); // read second byte
}

-- 
regards,
Tom

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



Re: [PHP] Confused about how exactly to output image using imagepng function

2007-05-17 Thread Tijnema !

On 5/17/07, Dave M G [EMAIL PROTECTED] wrote:

PHP list,

I've looked at the manual entries for imagepng() and
imagecreatetruecolor() functions for helping me to create a temporary
image for a CAPTCHA system.

However, I'm clearly messing up, as what I'm outputting is a bunch of
ASCII gibberish to the screen.

What I think I need to do in principle is first create the image with
imagecreatetruecolor(), then define it as a PNG (?), then display it.

So I've got something like this:

$image = ImageCreate($width, $height);
ImageFill($image, 0, 0, $black);
echo 'img  src=' . Imagepng($image) . ' height=' . $height . '
width=' . $width .' alt=captcha /' . \n;
ImageDestroy($image);

As mentioned, this isn't working, so there's a fundamental concept about
how PHP creates and displays images that I'm not getting.

I'm trying to output an image that, ideally, won't be stored as a file.
Or, if it has to be a temporary file, to delete it immediately after
displaying it.

What part am I not understanding?

Thank you for any advice or information.



It's quite simple, a second PHP script should generate the image, not
the same as that isn't gonna work.

as src expects an url where the source is located, and what you are
doing is that you're giving the source right there.

so you should have a second script called image.php or such with code:
$image = ImageCreate($width, $height);
ImageFill($image, 0, 0, $black);
Imagepng($image);
ImageDestroy($image);

and then in your first page like
echo 'img  src=image.php height=' . $height . '
width=' . $width .' alt=captcha /' . \n;


Tijnema

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



Re: [PHP] Confused about how exactly to output image using imagepng function

2007-05-17 Thread Stephen
Save the image as a file. Then html src=filename

Dave M G [EMAIL PROTECTED] wrote:  PHP list,

I've looked at the manual entries for imagepng() and 
imagecreatetruecolor() functions for helping me to create a temporary 
image for a CAPTCHA system.

However, I'm clearly messing up, as what I'm outputting is a bunch of 
ASCII gibberish to the screen.

What I think I need to do in principle is first create the image with 
imagecreatetruecolor(), then define it as a PNG (?), then display it.

So I've got something like this:

$image = ImageCreate($width, $height);
ImageFill($image, 0, 0, $black);
echo '' . \n;
ImageDestroy($image);

As mentioned, this isn't working, so there's a fundamental concept about 
how PHP creates and displays images that I'm not getting.

I'm trying to output an image that, ideally, won't be stored as a file. 
Or, if it has to be a temporary file, to delete it immediately after 
displaying it.

What part am I not understanding?

Thank you for any advice or information.

-- 
Dave M G
Ubuntu Feisty 7.04
Kernel 2.6.20-15-386

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




Re: [PHP] Confused about how exactly to output image using imagepng function

2007-05-17 Thread Zoltán Németh
2007. 05. 17, csütörtök keltezéssel 14.49-kor Tijnema ! ezt írta:
 On 5/17/07, Dave M G [EMAIL PROTECTED] wrote:
  PHP list,
 
  I've looked at the manual entries for imagepng() and
  imagecreatetruecolor() functions for helping me to create a temporary
  image for a CAPTCHA system.
 
  However, I'm clearly messing up, as what I'm outputting is a bunch of
  ASCII gibberish to the screen.
 
  What I think I need to do in principle is first create the image with
  imagecreatetruecolor(), then define it as a PNG (?), then display it.
 
  So I've got something like this:
 
  $image = ImageCreate($width, $height);
  ImageFill($image, 0, 0, $black);
  echo 'img  src=' . Imagepng($image) . ' height=' . $height . '
  width=' . $width .' alt=captcha /' . \n;
  ImageDestroy($image);
 
  As mentioned, this isn't working, so there's a fundamental concept about
  how PHP creates and displays images that I'm not getting.
 
  I'm trying to output an image that, ideally, won't be stored as a file.
  Or, if it has to be a temporary file, to delete it immediately after
  displaying it.
 
  What part am I not understanding?
 
  Thank you for any advice or information.
 
 
 It's quite simple, a second PHP script should generate the image, not
 the same as that isn't gonna work.
 
 as src expects an url where the source is located, and what you are
 doing is that you're giving the source right there.
 
 so you should have a second script called image.php or such with code:
 $image = ImageCreate($width, $height);
 ImageFill($image, 0, 0, $black);
 Imagepng($image);
 ImageDestroy($image);

don't forget to send proper content-type header before the image data

header(content-type: image/png);

or something like that

greets
Zoltán Németh

 
 and then in your first page like
 echo 'img  src=image.php height=' . $height . '
 width=' . $width .' alt=captcha /' . \n;
 
 
 Tijnema
 

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



Re: [PHP] Confused on the status of a bogus bug report

2007-01-08 Thread Jochem Maas
Bill Moran wrote:
 With reference to:
 http://bugs.php.net/bug.php?id=40067
 
 I'm confused as to why this was marked bogus, and the message that
 marked as such doesn't give much insight.
 
 It would seem to me that infinite recursion within PHP is a bug.
 Shouldn't the interpreter catch this sort of thing before it
 coredumps?  Or is the design philosophy for PHP different than
 that?

the way I understand it is that there is no decent way for the engine to
tell the difference between a piece of recursive code that will complete
and a piece of recursive code that will never complete ... so the only
sane solution is to leave it up to user land code to make sure the recursive
loop is not infinite.

put another way if the engine catches/stops what it *thinks* is an infinite loop
then how would stopping the loop at an arbitrary location be any better
than dumping core?

I believe this is why the bug was marked as bogus - sorry I can't explain it
any better.

 
 If anyone can point me to a online explanation for this or other
 resource, I'd be happy to read up a bit.  More than happy to understand
 why I'm wrong, but right now I feel as if this problem is getting the
 brush-off.
 

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



Re: [PHP] Confused on the status of a bogus bug report

2007-01-08 Thread Chris

Bill Moran wrote:

With reference to:
http://bugs.php.net/bug.php?id=40067

I'm confused as to why this was marked bogus, and the message that
marked as such doesn't give much insight.

It would seem to me that infinite recursion within PHP is a bug.
Shouldn't the interpreter catch this sort of thing before it
coredumps?  Or is the design philosophy for PHP different than
that?

If anyone can point me to a online explanation for this or other
resource, I'd be happy to read up a bit.  More than happy to understand
why I'm wrong, but right now I feel as if this problem is getting the
brush-off.


Getting the interpreter to catch infinite recursion would be bad (imo).

It can actually come in handy if you handle it properly:

while (true) {
  ... do stuff
  if ($conditions_are_met) {
break;
  }
}

I use this type of idea in some scripts and it works quite well 
(sometimes I forget the break out part and yeh it causes me some 
confusion :P).


I think the bug report is too complicated.. there are lots of variables 
involved in what you posted there and for one of the php c developers 
it's too time consuming to try and replicate - both your environment 
(php version, how you have it set up and so on) and your script.


Pear itself is a complicated beast.

If you can narrow it down to a really really simple test case then try 
again.


--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] Confused on the status of a bogus bug report

2007-01-08 Thread Robert Cummings
On Mon, 2007-01-08 at 23:59 +0100, Jochem Maas wrote:
 Bill Moran wrote:
  With reference to:
  http://bugs.php.net/bug.php?id=40067
  
  I'm confused as to why this was marked bogus, and the message that
  marked as such doesn't give much insight.
  
  It would seem to me that infinite recursion within PHP is a bug.
  Shouldn't the interpreter catch this sort of thing before it
  coredumps?  Or is the design philosophy for PHP different than
  that?
 
 the way I understand it is that there is no decent way for the engine to
 tell the difference between a piece of recursive code that will complete
 and a piece of recursive code that will never complete ... so the only
 sane solution is to leave it up to user land code to make sure the recursive
 loop is not infinite.
 
 put another way if the engine catches/stops what it *thinks* is an infinite 
 loop
 then how would stopping the loop at an arbitrary location be any better
 than dumping core?

Ummm, on many systems you end up with a core dump with the following
name: core.pid. Now multiply that by 1000 at 16 to 32 megs a piece.
Not fun :)

Anyways, the core dump happens because memory is exhausted and the
engine is unable to allocate anymore. It should be possible for PHP to
exit gracefully upon finding itself out of memory... Possibly it could
allocate another 1k and write to the error logfile on which line it was
running when it ran out of memory. Or better yet, maybe a
debug_backtrace() output *drool*.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] Confused on the status of a bogus bug report

2007-01-08 Thread Robert Cummings
On Tue, 2007-01-09 at 10:01 +1100, Chris wrote:
 Bill Moran wrote:
  With reference to:
  http://bugs.php.net/bug.php?id=40067
  
  I'm confused as to why this was marked bogus, and the message that
  marked as such doesn't give much insight.
  
  It would seem to me that infinite recursion within PHP is a bug.
  Shouldn't the interpreter catch this sort of thing before it
  coredumps?  Or is the design philosophy for PHP different than
  that?
  
  If anyone can point me to a online explanation for this or other
  resource, I'd be happy to read up a bit.  More than happy to understand
  why I'm wrong, but right now I feel as if this problem is getting the
  brush-off.
 
 Getting the interpreter to catch infinite recursion would be bad (imo).
 
 It can actually come in handy if you handle it properly:
 
 while (true) {
... do stuff
if ($conditions_are_met) {
  break;
}
 }

Determining infinite recursion pre-emptively is too much work. But it
should be able to catch too much recursion causing memory exhaustion.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] Confused on the status of a bogus bug report

2007-01-08 Thread Chris

Robert Cummings wrote:

On Tue, 2007-01-09 at 10:01 +1100, Chris wrote:

Bill Moran wrote:

With reference to:
http://bugs.php.net/bug.php?id=40067

I'm confused as to why this was marked bogus, and the message that
marked as such doesn't give much insight.

It would seem to me that infinite recursion within PHP is a bug.
Shouldn't the interpreter catch this sort of thing before it
coredumps?  Or is the design philosophy for PHP different than
that?

If anyone can point me to a online explanation for this or other
resource, I'd be happy to read up a bit.  More than happy to understand
why I'm wrong, but right now I feel as if this problem is getting the
brush-off.

Getting the interpreter to catch infinite recursion would be bad (imo).

It can actually come in handy if you handle it properly:

while (true) {
   ... do stuff
   if ($conditions_are_met) {
 break;
   }
}


Determining infinite recursion pre-emptively is too much work. But it
should be able to catch too much recursion causing memory exhaustion.


True.. my point was more that just finding  disabling infinite 
recursion would be a bad decision, but of course that's just my opinion :)


--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] Confused on the status of a bogus bug report

2007-01-08 Thread Jochem Maas
Robert Cummings wrote:
 On Mon, 2007-01-08 at 23:59 +0100, Jochem Maas wrote:
 Bill Moran wrote:
 With reference to:
 http://bugs.php.net/bug.php?id=40067

 I'm confused as to why this was marked bogus, and the message that
 marked as such doesn't give much insight.

 It would seem to me that infinite recursion within PHP is a bug.
 Shouldn't the interpreter catch this sort of thing before it
 coredumps?  Or is the design philosophy for PHP different than
 that?
 the way I understand it is that there is no decent way for the engine to
 tell the difference between a piece of recursive code that will complete
 and a piece of recursive code that will never complete ... so the only
 sane solution is to leave it up to user land code to make sure the recursive
 loop is not infinite.

 put another way if the engine catches/stops what it *thinks* is an infinite 
 loop
 then how would stopping the loop at an arbitrary location be any better
 than dumping core?
 
 Ummm, on many systems you end up with a core dump with the following
 name: core.pid. Now multiply that by 1000 at 16 to 32 megs a piece.
 Not fun :)

core dump files are only generated in debug builds I thought. I may well be
completely wrong though :-)

 
 Anyways, the core dump happens because memory is exhausted and the
 engine is unable to allocate anymore. It should be possible for PHP to
 exit gracefully upon finding itself out of memory... Possibly it could
 allocate another 1k and write to the error logfile on which line it was
 running when it ran out of memory. 

that does sound sane.

 Or better yet, maybe a
 debug_backtrace() output *drool*.

wouldn't the backtrace be massive, leaving you with the same problem as
indicated by your point regarding the core dump files?


 
 Cheers,
 Rob.

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



Re: [PHP] Confused on the status of a bogus bug report

2007-01-08 Thread Robert Cummings
On Tue, 2007-01-09 at 01:11 +0100, Jochem Maas wrote:
 Robert Cummings wrote:
  On Mon, 2007-01-08 at 23:59 +0100, Jochem Maas wrote:
  Bill Moran wrote:
  With reference to:
  http://bugs.php.net/bug.php?id=40067
 
  I'm confused as to why this was marked bogus, and the message that
  marked as such doesn't give much insight.
 
  It would seem to me that infinite recursion within PHP is a bug.
  Shouldn't the interpreter catch this sort of thing before it
  coredumps?  Or is the design philosophy for PHP different than
  that?
  the way I understand it is that there is no decent way for the engine to
  tell the difference between a piece of recursive code that will complete
  and a piece of recursive code that will never complete ... so the only
  sane solution is to leave it up to user land code to make sure the 
  recursive
  loop is not infinite.
 
  put another way if the engine catches/stops what it *thinks* is an 
  infinite loop
  then how would stopping the loop at an arbitrary location be any better
  than dumping core?
  
  Ummm, on many systems you end up with a core dump with the following
  name: core.pid. Now multiply that by 1000 at 16 to 32 megs a piece.
  Not fun :)
 
 core dump files are only generated in debug builds I thought. I may well be
 completely wrong though :-)

It is configurable, but often forgotten :)

  Anyways, the core dump happens because memory is exhausted and the
  engine is unable to allocate anymore. It should be possible for PHP to
  exit gracefully upon finding itself out of memory... Possibly it could
  allocate another 1k and write to the error logfile on which line it was
  running when it ran out of memory. 
 
 that does sound sane.
 
  Or better yet, maybe a
  debug_backtrace() output *drool*.
 
 wouldn't the backtrace be massive, leaving you with the same problem as
 indicated by your point regarding the core dump files?

Good point... maybe just the last 10 to 20 calls... Quite likely the
recursion will be seen then :) Admittedly, one can usually grab the same
info from the core dump.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] confused about where to load images

2006-10-05 Thread Richard Lynch
On Thu, October 5, 2006 5:15 am, Meline Martirossian wrote:
 I have just made my first php mini website. I have my header, footer,
 navigation and main pages.
 The header, footer and navigation appear as includes in my main
 page.

 When I click on my navigation links, I get a new blank browser window
 with the image on it. This is not what I want.

 Can you help me with instructing the server to load the image on my
 main page and in the designated area instead of a new blank page?

 http://www.squareinch.net/portfolio2.php

?php
  require 'header.inc';
  require 'navbar.inc'; //probably should be folded into header.inc...
  if (isset($_REQUEST['logo'])){
$logo = $_REQUEST['logo'];

/ everything between these marks is about input validity
/ You don't need it to understand how to do what you want
/ You need it to understand how not to get hacked
$logo = basename($logo); //minimal crude anti-hack scrubbing...
//slightly more anti-hack scrubbing
if (substr($logo, -4) !== '.jpg'){
  echo pInvalid Input/p;
  require 'footer.inc';
  exit;
}
//In an IDEAL world, you program the logos into a DB
//You then check that '$logo' is *in* the DB, so you know it's
//a valid logo.
//Unless they hack your DB *and* muck with your URL at same time...
// end of input validty section
?
img src=/images/?php echo $logo? /
?php
  }
  else{
?
pPut the square inch logo here or whatever is there when there
is no image selected/p
?php
  }
  require 'footer.inc';
?

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Confused about how to best execute php scripts in /cgi-bin/

2005-09-07 Thread KEVIN ZEMBOWER
Disappointed that there was no response to this message, I nevertheless seemed 
to have solved the problem by adding AddHandler php-script .php to the 
Directory stanza for my /cgi-bin/ directory. For the archives, in case anyone 
is searching for this answer, too.

-Kevin

 KEVIN ZEMBOWER [EMAIL PROTECTED] 09/06/05 10:44AM 
I'm trying to allow php scripts to execute from the /cgi-bin/ directory, which 
is currently set up as a ScriptAlias in my Apache2 configuration. I've found 
lots of references to this, but there seems to be a couple of different ways to 
accomplish this, and I can't tell which one is recommended or safest. There 
seems to be lots of security risks associated with some of the solutions 
proposed.

I'm using Debian woody. This was working under Apache 1, but somehow upgrading 
to Apache 2 broke it, and I haven't been able to fix it.

I've found solutions involving changing the ScriptAlias directory to just an 
Alias, with ExecuteCGI turned on in the Apache2 configuration. I've also found 
adding an alias to the php4 executable in the cgi-bin directory and adding an 
Action and AddHandler to the configuration, but I wasn't able to get this 
working. I get the sense that changing the SafeMode section of 
/etc/php4/apache2/php.ini is the recommended, safest way, but I haven't been 
able to find any cookbook-style directions on what to change to allow the 
execution of the php scripts from /cgi-bin/.

Can anyone help me get this set up? Searching the archives of this list 
produced some information that seemed contradictory and I couldn't understand 
which methods were recommended.

Thank you for your help and advice.

-Kevin Zembower

-
E. Kevin Zembower
Internet Systems Group manager
Johns Hopkins University
Bloomberg School of Public Health
Center for Communications Programs
111 Market Place, Suite 310
Baltimore, MD  21202
410-659-6139

--
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] Confused - $GLOBALS

2004-12-10 Thread Richard Lynch
 I always forget, because they changed it around on POST/GLOBALS/etc at
 some point, but only on some of them.  Grrr.

 The built-in arrays with names beginning $_ are superglobals, i.e.
 always
 global anyway.  The only other superglobal is $GLOBALS, which is a
 anming
 exception because it existed long before the $_ arrays came into
 existence.
 This has not changed at any point in the life of PHP -- the only change
 was
 the actual introduction of the $_ versions.

Allow me to be more precise.

In version 4.1.0 of December 2001's change log, we find this entry:

Introduced $_GET, $_POST, $_COOKIE, $_SERVER and $_ENV variables, which
deprecate the old $HTTP_*_VARS arrays. In addition to be much shorter to
type - these variables are also available regardless of the scope, and
there's no need to import them using the 'global' statement. (Andi 
Zeev)

Therefore my prepetual confusion about which thingies are superglobals
comes from the old $HTTP_*_VARS arrays, which are not superglobals, and
their $_* vars which have the same data, but are superglobals, and the
$GLOBALS variable, which has always been a superglobal.

So when I was supposed to go convert all my $HTTP_*_VARS, I *also* had to
get rid of all the places I used to have to make them global, but now I
don't any more...  Woof.  Can't just global search and replace my source
code, can I?

Now I know why I'm making that change piece-meal. :-^

-- 
Like Music?
http://l-i-e.com/artists.htm

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



RE: [PHP] Confused - $GLOBALS

2004-12-10 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 09 December 2004 20:41, Richard Lynch wrote:

 My best guess from skimming your code is that you need:
 
 global $_POST;

No, he doesn't.

 
 in the function that uses $_POST.
 
 Or is $_POST always global anyway?

Yes.

 
 I always forget, because they changed it around on POST/GLOBALS/etc at
 some point, but only on some of them.  Grrr.

The built-in arrays with names beginning $_ are superglobals, i.e. always
global anyway.  The only other superglobal is $GLOBALS, which is a anming
exception because it existed long before the $_ arrays came into existence.
This has not changed at any point in the life of PHP -- the only change was
the actual introduction of the $_ versions.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, 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] Confused - $GLOBALS

2004-12-09 Thread John Nichel
Danny Brow wrote:
Below is a snip of a program I am writing, I am a little new to php.
Any how, I can't for the life me figure out why one of my functions
cannot grab the item_pics1 variable. I have tried passing the variable
to the function, tried using $GLOBALS['item_pic1']. So I guess my
question is, does PHP in some cases need to have a variable in a if
statement sent back to the global scope? everything works but the
str_replace item_pics1. Hope this is enough code.
snip
If you want to use a variable from outside the function, you either have 
to pass it to the function; if you want to change it, you have to pass 
it by reference, or make it global inside the function

function foo ( $bar ) {
/--code--/
}
function foo ( $bar ) {
/--code--/
}
function foo() {
global $var;
/--more code--/
}
I may be mistaken, but I think the $GLOBALS array was introduced in 4.3.0.
http://us4.php.net/manual/en/language.variables.scope.php
--
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] Confused - $GLOBALS

2004-12-09 Thread John Nichel
Belay that...the $GLOBALS array has existed since PHP3
--
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] Confused - $GLOBALS

2004-12-09 Thread Danny Brow
On Thu, 2004-12-09 at 13:41 -0500, John Nichel wrote:
 Danny Brow wrote:
  Below is a snip of a program I am writing, I am a little new to php.
  Any how, I can't for the life me figure out why one of my functions
  cannot grab the item_pics1 variable. I have tried passing the variable
  to the function, tried using $GLOBALS['item_pic1']. So I guess my
  question is, does PHP in some cases need to have a variable in a if
  statement sent back to the global scope? everything works but the
  str_replace item_pics1. Hope this is enough code.
 snip
 
 If you want to use a variable from outside the function, you either have 
 to pass it to the function; if you want to change it, you have to pass 
 it by reference, or make it global inside the function
 
 function foo ( $bar ) {
   /--code--/
 }

 function foo ( $bar ) {
   /--code--/
 }
 
 function foo() {
   global $var;
   /--more code--/
 }
 
See this is where the confusion is, I've tried all these and it still
does not work.  I'm going to read the whole page on variable scope a few
times, see if I missed something.  Maybe it's something else in my code
screwing my up.

Thanks.
Dan.

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



Re: [PHP] Confused - $GLOBALS

2004-12-09 Thread Richard Lynch
My best guess from skimming your code is that you need:

global $_POST;

in the function that uses $_POST.

Or is $_POST always global anyway?

I always forget, because they changed it around on POST/GLOBALS/etc at
some point, but only on some of them.  Grrr.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Confused - $GLOBALS

2004-12-09 Thread Danny Brow
On Thu, 2004-12-09 at 12:40 -0800, Richard Lynch wrote:
 My best guess from skimming your code is that you need:
 
 global $_POST;
 

should I put this at the top of my code with the rest of my variables?

 in the function that uses $_POST.
 
 Or is $_POST always global anyway?
No. 

 
 I always forget, because they changed it around on POST/GLOBALS/etc at
 some point, but only on some of them.  Grrr.
 

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



Re: [PHP] Confused - $GLOBALS

2004-12-09 Thread Danny Brow
On Thu, 2004-12-09 at 15:39 -0500, Roger Spears wrote:
 Danny Brow wrote:
  On Thu, 2004-12-09 at 13:41 -0500, John Nichel wrote:
  
 Danny Brow wrote:
 
 Below is a snip of a program I am writing, I am a little new to php.
 Any how, I can't for the life me figure out why one of my functions
 cannot grab the item_pics1 variable. I have tried passing the variable
 to the function, tried using $GLOBALS['item_pic1']. So I guess my
 question is, does PHP in some cases need to have a variable in a if
 statement sent back to the global scope? everything works but the
 str_replace item_pics1. Hope this is enough code.
 
 
 This may seem a little simple, but it's happened to me.  Are you sure 
 the variable has a value?

Yes, I can do a print $item_pics before and after the function.

dan.

PS. Roger, sorry for sending this to you twice, you sent your reply to directly 
and not to the list.

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



Re: [PHP] Confused - $GLOBALS

2004-12-09 Thread Danny Brow
On Thu, 2004-12-09 at 12:40 -0800, Richard Lynch wrote:
 My best guess from skimming your code is that you need:
 
 global $_POST;
 
 in the function that uses $_POST.
 
 Or is $_POST always global anyway?
 
 I always forget, because they changed it around on POST/GLOBALS/etc at
 some point, but only on some of them.  Grrr.
 

After reading this again, the function does not use $_POST at all.

here it is again.

function html_template() {
global $item_pics1;
if (file_exists('item.html')) {
print This is item_pics1 . $item_pics1;
$html_template = $GLOBALS['html_template'];
$html_template = str_replace('{item_pictures}', $item_pics1,
$html_template);
$html_template = str_replace('{title}', $GLOBALS['title'],
$html_template);
$html_template = str_replace('{description}',
$GLOBALS['descrip'], $html_template);
$html_template = str_replace('{price}', $GLOBALS['price'],
$html_template);
$item_file_name = $GLOBALS['root_dir'] . / . $GLOBALS['dir'] .
/item.html;
$item_fh = fopen($item_file_name, 'x+');
fwrite($item_fh, $html_template);
} else {
$GLOBALS['errors'] .= item.html template does not exsit;
}
}

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



Re: [PHP] Confused - $GLOBALS

2004-12-09 Thread Jason Wong
On Friday 10 December 2004 04:48, Danny Brow wrote:
 On Thu, 2004-12-09 at 12:40 -0800, Richard Lynch wrote:
  My best guess from skimming your code is that you need:
 
  global $_POST;

 should I put this at the top of my code with the rest of my variables?

No

  in the function that uses $_POST.
 
  Or is $_POST always global anyway?

 No.

Yes

-- 
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
--
/*
BOFH Excuse #227:

Fatal error right in front of screen
*/

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



Re: [PHP] Confused - $GLOBALS

2004-12-09 Thread John Nichel
Danny Brow wrote:
snip
function html_template() {
global $item_pics1;
if (file_exists('item.html')) {
print This is item_pics1 . $item_pics1;
$html_template = $GLOBALS['html_template'];
$html_template = str_replace('{item_pictures}', $item_pics1,
$html_template);
$html_template = str_replace('{title}', $GLOBALS['title'],
$html_template);
$html_template = str_replace('{description}',
$GLOBALS['descrip'], $html_template);
$html_template = str_replace('{price}', $GLOBALS['price'],
$html_template);
$item_file_name = $GLOBALS['root_dir'] . / . $GLOBALS['dir'] .
/item.html;
$item_fh = fopen($item_file_name, 'x+');
fwrite($item_fh, $html_template);
} else {
$GLOBALS['errors'] .= item.html template does not exsit;
}
}

So what is the function doing or not doing?  If 'index.html' isn't in 
the same directory as the script, it will evaluate to false and the only 
code the function will execute is...

$GLOBALS['errors'] .= item.html template does not exsit;
Maybe do a print_r ( $GLOBALS ) inside the function to make sure the 
values you're looking for are actually there.

--
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] Confused - $GLOBALS

2004-12-09 Thread Jason Wong
On Friday 10 December 2004 04:52, Danny Brow wrote:

OK, you never said what your problem was except to say everything works but 
the str_replace item_pics1.

Did you check $GLOBALS['errors'] after calling this function?

 function html_template() {
 global $item_pics1;
 if (file_exists('item.html')) {

Is this file supposed to be same as the one below?

 $item_file_name = $GLOBALS['root_dir'] . / . $GLOBALS['dir'] .
 /item.html;

-- 
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
--
/*
We are all dying -- and we're gonna be dead for a long time.
*/

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



Re: [PHP] Confused - $GLOBALS

2004-12-09 Thread Danny Brow
On Fri, 2004-12-10 at 05:52 +0800, Jason Wong wrote:
 On Friday 10 December 2004 04:52, Danny Brow wrote:
 
 OK, you never said what your problem was except to say everything works but 
 the str_replace item_pics1.
 
 Did you check $GLOBALS['errors'] after calling this function?
No but I'm doing that now. I'm also reading the manual on $GLOBALS right
again, this must have been something I missed the first time reading it.

 
  function html_template() {
  global $item_pics1;
  if (file_exists('item.html')) {
 
 Is this file supposed to be same as the one below?
 
  $item_file_name = $GLOBALS['root_dir'] . / . $GLOBALS['dir'] .
  /item.html;

no, this is what the original item.html becomes.

In my program $GLOBALS['root_dir'] is the root directory of the program,
$GLOBALS['dir'] is created based on the current item number,
like /var/www/htdocs/items_for_sale/item1 

Thanks,
dan.


 
 -- 
 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
 --
 /*
 We are all dying -- and we're gonna be dead for a long time.
 */
 

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



Re: [PHP] Confused with constructors

2004-11-19 Thread Gareth Williams
Try this:
class base_object()
{
function base_object()
{
echo I'm the base;
}
function base_test()
{
echo I'm the base test;
}
}
class extended_object() extends base_object
{
function extended_object()
{
echo I'm the extend object;
$this-base_object();
}
function extended_test()
{
echo I'm the extended test;
}
}
Barring any syntax errors (I wrote this out of my head), this should 
show you that the base object is being properly constructed.

On 19 Nov 2004, at 09:02, Gerald Wharney wrote:
I'm trying the example at:
http://www.php.net/manual/en/language.oop.constructor.php
?php
class A
{
   function A()
   {
   echo I am the constructor of A.br /\n;
   }
   function B()
   {
   echo I am a regular function named B in class
A.br /\n;
   echo I am not a constructor in A.br /\n;
   }
}
class B extends A
{
   function C()
   {
   echo I am a regular function.br /\n;
   }
}
// This will call B() as a constructor.
$b = new B;
?
Running this on 4.3.9 both as an apache module and
from CLI I get:
I am a regular function named B in class A.
I am not a constructor in A.
This is contrary to what the manual says:
This is fixed in PHP 4 by modifying the rule to: 'A
constructor is a function of the same name as the
class it is being defined in.'. Thus in PHP 4, the
class B would have no constructor function of its own
and the constructor of the base class would have been
called, printing 'I am the constructor of A.br /'.
Is this an error in the manual?
Or a bug in php 4.3.9?
Or just me being stupid?
--
G W (no bush)

	
	
		
___
ALL-NEW Yahoo! Messenger - all new features - even more fun! 
http://uk.messenger.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] Confused overSimple PHP mySQL date question

2004-09-14 Thread Jay Blanchard
[snip]
DATE field in a mysql database.

What obvuios thing did I miss?  Note I am not using the system date or
time
stamp, these are entered dates.
[/snip]

You're using a DATE field in the MySQL database. MySQL requires an ISO
formatted date unless you manipulate it, such as 2004-09-14
http://dev.mysql.com/doc/mysql/en/Date_and_time_types.html

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



Re: [PHP] Confused overSimple PHP mySQL date question

2004-09-14 Thread John Holmes
From: Scott Miller [EMAIL PROTECTED]
I have a mysql database that has a date field and a time field.
I want users to be able to enter a date and a time in text boxes on an 
html
form and have them end up in the database.
Code examples would be good here. Either way, the format for a DATE field is 
MMDD or '-MM-DD' and the format for a TIME field is HHMMSS or 
'HH:MM:SS'. Make sure what you're trying to stick in the database is in that 
format. If you want to accept another format in your text fields, then 
you'll need to use date(), strtotime(), mktime(), explode(), etc to format 
it this way.

You really just need one DATETIME or TIMESTAMP field, though... there's 
reason to keep these values in two separate fields if they are related to 
the same event. It'll make searching down the road easier.

SELECT * FROM events WHERE datetimecolumn BETWEEN NOW() AND INTERVAL + 30 
DAY;

SELECT * FROM events WHERE datetimecolumn BETWEEN 20040901 AND 20040930;
etc...
---John Holmes... 

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


Re: [PHP] Confused...need some programming logic

2004-08-04 Thread Justin Patrin
On Wed, 4 Aug 2004 15:06:45 -0700 (PDT), PHP Gen [EMAIL PROTECTED] wrote:
 Hi,
 I have 13 folders with a few thousand images each, now
 the client wants me to export the gallerys to
 another server that does not run phpso he wants
 plain .htm files.
 
 Below is how far I have come to porting this... the
 idea being: generate .html files then simply copy the
 images folders to the clients other server and
 dump the html files there and he has a gallery ready
 to go..this is how i thought of it:
 
 1: read number of images from a directory (done)
 
 2: After reading, divide the number by 100 (eg: 1348
 images equals 14 pages...last page only 48 pics)
 (done)
 
 3: Dynamically create the .html files via a fopen
 (done)
 
 4: put 100 img tags to call 100 images per page
 (confused here)

I put some code inline below. Should work. If you want a thumbnail
gallery, you could also create thumbnails using the GD functions in
PHP, same them, and create an img tag with the thumbnail with a link
to the fill file.

 
 The images are numbered sequentially but dont start
 from 0 or 1, they start from something like 00047.jpg
 or 0024.jpg etc
 
 I think I will need a foreach (and tried a
 foreach...but didnt work) but am confused...ANY help
 appreciated.
 
 ** Start code 
 
 ?php
 function directory($dir,$filters){
 $handle=opendir($dir);
 $files=array();
 if ($filters == all){while(($file =
 readdir($handle))!==false){$files[] = $file;}}
 if ($filters != all){
 $filters=explode(,,$filters);
 while (($file = readdir($handle))!==false) {
 for ($f=0;$fsizeof($filters);$f++):
 $system=explode(.,$file);
 if ($system[1] == $filters[$f]){$files[] = $file;}
 endfor;
 }
 }
 closedir($handle);
 return $files;
 }
 
 $pics=directory(pics,jpg,JPG,JPEG,jpeg,png,PNG);
 $total_pics=count($pics);
 $pages = ceil($total_pics / 100); // using ceil so
 12.23 translates to 13
 
 $content=Mag;
 /*
 foreach ($pics as $p)
 // $p is the name of the file
 {$content.=$content.img src='thumbs/tn_.$p.';}
 */
 
 for($i=0; $i$pages;$i++)
 {
 if($i==0){$j=;}else{$j=$i;}
 $index=index.$j;
 
  if(!$handle = fopen($index..html, w))
  {echo Cannot open file ($filename);exit;}
 
  if(fwrite($handle, $content) === FALSE)
  {echo Cannot write to file $filename);exit;}

for($j = 0; $j  100; ++$j) {
  if($pics[$i * 100 + $j]) {
echo 'img src='.$pics[$i * 100 + $j].'/br/';
  }
}

  fclose($handle);
 
 }
 
 echo The end;
 ?
 
 ** End code 
 
 The above code is working so far as to:
 1.read from the dir
 2.create the required number of pages while making
 sure the first page is index.html
 3. Writing some content in..in this case just: Mag
 
 Thanks,
 Mag
 
 =
 --
 - The faulty interface lies between the chair and the keyboard.
 - Creativity is great, but plagiarism is faster!
 - Smile, everyone loves a moron. :-)
 
 __
 Do you Yahoo!?
 New and Improved Yahoo! Mail - Send 10MB messages!
 http://promotions.yahoo.com/new_mail
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 !DSPAM:41115bea172812942772655!
 
 


-- 
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] Confused...need some programming logic

2004-08-04 Thread PHP Gen

--- Justin Patrin [EMAIL PROTECTED] wrote:


  4: put 100 img tags to call 100 images per page
  (confused here)
 
 I put some code inline below. Should work. If you
 want a thumbnail
 gallery, you could also create thumbnails using the
 GD functions in
 PHP, same them, and create an img tag with the
 thumbnail with a link
 to the fill file.


Hi,
Thanks for replying.

I think you misunderstood my problem, your code is
just printing the images onto the screen...I need to
take 100 img tags and write it to each of the .html
pages...

eg:
if there 112 images in the folder,
it should create 2 html files (index.htm and
index1.htm - this is already done - 
THEN insert 100 img tags into the first file
(index.htm) and balance 12 img tags into the second
file)

Ideas?

Thanks,
-Mag

=
--
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)



__
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail 

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



Re: [PHP] Confused...need some programming logic

2004-08-04 Thread Justin Patrin
On Wed, 4 Aug 2004 15:40:03 -0700 (PDT), PHP Gen [EMAIL PROTECTED] wrote:
 
 --- Justin Patrin [EMAIL PROTECTED] wrote:
 
   4: put 100 img tags to call 100 images per page
   (confused here)
 
  I put some code inline below. Should work. If you
  want a thumbnail
  gallery, you could also create thumbnails using the
  GD functions in
  PHP, same them, and create an img tag with the
  thumbnail with a link
  to the fill file.
 
 
 Hi,
 Thanks for replying.
 
 I think you misunderstood my problem, your code is
 just printing the images onto the screen...I need to
 take 100 img tags and write it to each of the .html
 pages...
 
 eg:
 if there 112 images in the folder,
 it should create 2 html files (index.htm and
 index1.htm - this is already done -
 THEN insert 100 img tags into the first file
 (index.htm) and balance 12 img tags into the second
 file)
 
 Ideas?
 

No, I didn't misunderstand, it was an oversight.

Just change the echo to an fwrite.

for($j = 0; $j  100; ++$j) {
 if($pics[$i * 100 + $j]) {
   fwrite($handle, 'img src='.$pics[$i * 100 + $j].'/br/');
 }
}
-- 
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] Confused...need some programming logic

2004-08-04 Thread PHP Gen
Hey,


 Just change the echo to an fwrite.
 
 for($j = 0; $j  100; ++$j) {
  if($pics[$i * 100 + $j]) {
fwrite($handle, 'img src='.$pics[$i * 100 +
 $j].'/br/');
  }
 }


Works like a charm, thanks a million.
-Mag

=
--
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)



__
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

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



RE: [PHP] confused big time

2004-04-07 Thread Robert Cummings
On Tue, 2004-04-06 at 20:09, Chris W. Parker wrote:
 Chris W. Parker 
 on Tuesday, April 06, 2004 5:01 PM said:
 
 let me expand both of my points in an attempt to be more verbose.
 
  1. write readable queries.
  2. always put single quotes around array keys. $array['key']
 
 here is how i would write your query:
 
 ?php
 
   $sql = 
 insert into $EventsTable
 values(
 NULL
 , '{$_SESSION['add']['type]}'
 , '{$_SESSION['add']['start_date']}'
 , '{$_SESSION['add']['end_date']}'
 , '{$_SESSION['add']['name']}'
 , '{$_SESSION['add']['county']}'
 , '{$_SESSION['add']['discription']}'
 , '{$_SESSION['add']['StartingDay']}'
 , '{$_SESSION['add']['StartingMonth']}'
 , '{$_SESSION['add']['StartingYear']}'
 , '{$_SESSION['add']['EndingDay']}'
 , '{$_SESSION['add']['EndingMonth']}'
 , '{$_SESSION['add']['EndingYear']}';
 
 
   $sql = 
 insert into $GuestbookTable
 values(
 NULL
 , '{$_SESSION['add']['date']}'
 , '{$_SESSION['add']['name']}'
 , '{$_SESSION['add']['email']}'
 , '{$_SESSION['add']['website']}'
 , '{$_SESSION['add']['referred']}'
 , '{$_SESSION['add']['comments']}');

I don't advise this type of insert query. If you ever add a new field to
the table all of your queries will break since this style requires
ordered matching of values to table fields for every field in the table.
You should use the field names in the query:

$sql = 
INSERT INTO $guestbookTable
(
field1,
field2,
field3
)
VALUES
(
'$value1',
'$value2',
'$value3'
) ;

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] confused big time

2004-04-07 Thread Mark Ackroyd
I always found this way of inserting data into a database messy. Here is 
a handy function to do array inserts and it builds the sql for you.

function arrayINSERT($a,$tablename)
{
$sql = INSERT INTO $tablename (;
foreach($a as $key = $value)
{
$sql .= $key .,;
}   
$sql[strlen($sql)-1] = ')';
$sql .=  VALUES (;
foreach($a as $key = $value)
{
if (gettype($value) == 'string')
{   
$sql .= '. addslashes($value) .',;
}
else
{
$sql .= $value .,;
}
}
$sql[strlen($sql)-1] = ')';
return $sql;
}
if you do this :

$a['field1'] = $blah;
$a['field2'] = $here;
$a['field3'] = $etc;
$sql = arrayINSERT($a,tablename);
it builds the sql statement for you.  It covers 99.9% of the inserts 
your likely to need.  I use an update and insert function like this all 
the time. :-)

Mark



Richard Davey wrote:

$sql = 
INSERT INTO
   tablename
   (
field1,
field2,
field3
   )
VALUES
  (
'$blah',
$here',
'$etc'
  )
;
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] confused big time

2004-04-07 Thread John W. Holmes
From: Mark Ackroyd [EMAIL PROTECTED]

 I always found this way of inserting data into a database messy. Here is 
 a handy function to do array inserts and it builds the sql for you.
 
 function arrayINSERT($a,$tablename)
 {
 $sql = INSERT INTO $tablename (;
 foreach($a as $key = $value)
 {
 $sql .= $key .,;
 } 
 $sql[strlen($sql)-1] = ')';
 $sql .=  VALUES (;
 foreach($a as $key = $value)
 {
 if (gettype($value) == 'string')
 { 
 $sql .= '. addslashes($value) .',;
 }
 else
 {
 $sql .= $value .,;
 }
 }
 $sql[strlen($sql)-1] = ')';
 return $sql;
 }

To get your list of columns, you could do this:

$column_list = implode(',',array_keys($a));
$sql = INSERT INTO $tablename ($column_list) VALUES ;

That way you only have to loop through $a once. 

---John Holmes...

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



Re: [PHP] confused big time

2004-04-07 Thread Mark Ackroyd
RD That .1% of the time being when you need to insert a value as now() ?
RD (which will break the string check as it'll wrap it with '' which will
RD cause MySQL to insert -00-00 00:00:00) or if it's an enum field
RD with a numeric allowed value? :)
Not really, since you usally format a timestamp into something thats db 
friendly. How many times have you written code where the date 02-01-2004 
  means the 2nd of Jan or the 1st of Feb?. On a MS SQL BOX the best 
format is '01-MAR-2004 12:00:00' which is eval'ed as a string. On mysql 
it's '2004-03-01 12:00:00' if you get into the habbit of *always* 
converting the date into a db friendly string, then you'll never have 
date insert problems and it can be used in the function without issues.

Mark

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


Re: [PHP] confused big time

2004-04-07 Thread Mark Ackroyd
RD But now() IS a DB friendly format for MySQL and is the recommended
RD way of inserting the current time into a datetime or timestamp
RD field.
But what about MsSQL, Oracle and postgres to name a few. I have worked 
on a few projects where you read from one db and load into another db. 
Dates then become the spawn of satan.

RD Converting it to a timestamp/datetime locally first is a waste of
RD processing time IMHO and opens you up to a potential
RD slight)
True that it wastes CPU time, but in todays climate, having developers 
churning out manageable , readable code is better then something  that 
looks like the perl DeCSS program.  If you need the nano seconds that
much buy a better box !.

Mark

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


Re: [PHP] confused big time

2004-04-07 Thread Red Wingate
You could even do:

$sql .=  ( '.implode( ',' , $a ).' );

This way everything is quoted though ( but this doesn't matter using
MySQL anyway ).
If you want to escape the values of $a you could use array_map to
do this also without having to loop :-)

  -- red

[...]
 To get your list of columns, you could do this:

 $column_list = implode(',',array_keys($a));
 $sql = INSERT INTO $tablename ($column_list) VALUES ;

 That way you only have to loop through $a once.
[...]

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



RE: [PHP] confused big time

2004-04-07 Thread Chris W. Parker
Andy B mailto:[EMAIL PROTECTED]
on Tuesday, April 06, 2004 7:56 PM said:

 $query=insert into table values(
 '{$array['index1']['index2']}',
 '{$array[index2']['index3']}',
 //so on down the list
 );
 
 if i understand the readable way right...

no, not quite. here is how you should do it (imo):

1. always write SQL commands in upper case. i.e. SELECT name FROM
table

2. indent the different sections of the query. i'm not sure that i'm
indenting correctly, but i'm basically just copying SQL statements i've
seen in the past, as far as indentation goes.

$query = 
INSERT INTO table
VALUES
( '{$array['index1']['index2']}'
, '{$array['index2']['index3']}' );

 oh btw if you do something like that is it possible to insert
 comments in the middle of a query like that without breaking it up
 (i.e. for huge queries comment on what the variables are for)??

yes. i don't know if mysql supports them but i think it works like this:

$query = 
INSERT INTO table /* comment */
VALUES
( '{$array['index1']['index2']}'
, '{$array['index2']['index3']}' );


hth,
chris.

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



Re: [PHP] confused big time

2004-04-07 Thread Andy B

- Original Message - 
From: Chris W. Parker [EMAIL PROTECTED]
To: Andy B [EMAIL PROTECTED]
Sent: Wednesday, April 07, 2004 6:30 PM
Subject: RE: [PHP] confused big time


Andy B mailto:[EMAIL PROTECTED]
on Wednesday, April 07, 2004 2:09 PM said:

 yes you can absolutely do it that way. in this case it's just a
 matter of preference. 
 
 got it tnx
 
 i think we can close this tread now

ok. i hope i've been helpful.
sure arekeep up good work

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



RE: [PHP] confused big time

2004-04-06 Thread Chris W. Parker
Andy B mailto:[EMAIL PROTECTED]
on Tuesday, April 06, 2004 4:51 PM said:

 they both use the same identical format to insert the arrays. there
 is an interesting problem though: the first one complains about use
 of undefined constant add - assumed 'add' in the second query...the
 first one doesnt do that??   
 
 everything is set up exactly the same for both queries except the
 relevant variable/array names... 

two things i would recommend before disecting your code.

1. write readable queries.

GOOD:

  $sql = 
  SELECT
name
, age
, height
, etc
  FROM user
  WHERE
name = '$name'
AND height = '5';

2. always put single quotes around array keys. $array['key']



hth,
chris.

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



RE: [PHP] confused big time

2004-04-06 Thread Chris W. Parker
Chris W. Parker 
on Tuesday, April 06, 2004 5:01 PM said:

let me expand both of my points in an attempt to be more verbose.

 1. write readable queries.
 2. always put single quotes around array keys. $array['key']

here is how i would write your query:

?php

  $sql = 
insert into $EventsTable
values(
NULL
, '{$_SESSION['add']['type]}'
, '{$_SESSION['add']['start_date']}'
, '{$_SESSION['add']['end_date']}'
, '{$_SESSION['add']['name']}'
, '{$_SESSION['add']['county']}'
, '{$_SESSION['add']['discription']}'
, '{$_SESSION['add']['StartingDay']}'
, '{$_SESSION['add']['StartingMonth']}'
, '{$_SESSION['add']['StartingYear']}'
, '{$_SESSION['add']['EndingDay']}'
, '{$_SESSION['add']['EndingMonth']}'
, '{$_SESSION['add']['EndingYear']}';


  $sql = 
insert into $GuestbookTable
values(
NULL
, '{$_SESSION['add']['date']}'
, '{$_SESSION['add']['name']}'
, '{$_SESSION['add']['email']}'
, '{$_SESSION['add']['website']}'
, '{$_SESSION['add']['referred']}'
, '{$_SESSION['add']['comments']}');


hth,
chris.

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



Re: [PHP] confused big time

2004-04-06 Thread Richard Davey
Hello Andy,

Wednesday, April 7, 2004, 1:06:52 AM, you wrote:

AB 1. how were those queries unreadable?? and

You're kidding, right?

AB 2. whenever i put '' around the array keys in multi dimensional arrays in a
AB query i get a parse error of trying to use undefined keys or it doesnt
AB expand the array all the way... and

If you don't include '' PHP will assume you are trying to use a
constant, which (as you haven't defined one anywhere) obviously you're
not.

$something = $my_array['area1']['blah']['value'];

.. is the correct syntax, assuming the array is created as such.

$something = $my_array[area1][blah][value];

.. will give you a Constant Undefined error warning, as it should.

AB 3. when i used the {} on the arrays and the '' around the keys all i got was
AB parse error because of the '' around them...

Try this - right before your query dump out the value of $_SESSION
with either var_dump() or print_r() - see if ALL of the values you are
trying to insert into your query are present and correct. I have a
feeling you'll find they aren't.

BTW you don't need to insert NULL values in MySQL, you can just not
insert anything if null is the default anyway for that field.

-- 
Best regards,
 Richard Davey
 http://www.phpcommunity.org/wiki/296.html

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



Re: [PHP] confused big time

2004-04-06 Thread Richard Davey
Hello Andy,

Wednesday, April 7, 2004, 1:18:06 AM, you wrote:

AB um...im not doing selects im doing inserts with variable names... i
AB understand the idea with select but thats not the dealits an insert...

He was showing you a neatly formatted query, the example applies to
inserts too:

$sql = 
INSERT INTO
   tablename
   (
field1,
field2,
field3
   )
VALUES
  (
'$blah',
$here',
'$etc'
  )
;

There you have a visually instant way of telling where the missing '
is.

-- 
Best regards,
 Richard Davey
 http://www.phpcommunity.org/wiki/296.html

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



RE: [PHP] confused big time

2004-04-06 Thread Chris W. Parker
Andy B mailto:[EMAIL PROTECTED]
on Tuesday, April 06, 2004 5:18 PM said:

 um...im not doing selects im doing inserts with variable names... i
 understand the idea with select but thats not the dealits an
 insert... 

i was hoping that wouldn't cause any confusion, but i guess it did. the
thing to remember is that a query is a query. you know, parts is parts.

here is your first query, written better.

?php
$sql = 
INSERT INTO $EventsTable
VALUES
( NULL
, '{$_SESSION['add']['type']}'
, '{$_SESSION['add']['start_date']}'
, '{$_SESSION['add']['end_date']}'
, '{$_SESSION['add']['name']}'
, '{$_SESSION['add']['county']}'
, '{$_SESSION['add']['discription']}'
, '{$_SESSION['add']['StartingDay']}'
, '{$_SESSION['add']['StartingMonth']}'
, '{$_SESSION['add']['StartingYear']}'
, '{$_SESSION['add']['EndingDay']}'
, '{$_SESSION['add']['EndingMonth']}'
, '{$_SESSION['add']['EndingYear']}';

?


hth,
chris.

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



RE: [PHP] confused big time

2004-04-06 Thread Martin Towell
  um...im not doing selects im doing inserts with variable names... i
  understand the idea with select but thats not the dealits an
  insert... 
 
 i was hoping that wouldn't cause any confusion, but i guess 
 it did. the
 thing to remember is that a query is a query. you know, parts 
 is parts.
 
 here is your first query, written better.
 
 ?php
   $sql = 
   INSERT INTO $EventsTable
   VALUES
   ( NULL
   , '{$_SESSION['add']['type']}'
   , '{$_SESSION['add']['start_date']}'
   , '{$_SESSION['add']['end_date']}'
   , '{$_SESSION['add']['name']}'
   , '{$_SESSION['add']['county']}'
   , '{$_SESSION['add']['discription']}'
   , '{$_SESSION['add']['StartingDay']}'
   , '{$_SESSION['add']['StartingMonth']}'
   , '{$_SESSION['add']['StartingYear']}'
   , '{$_SESSION['add']['EndingDay']}'
   , '{$_SESSION['add']['EndingMonth']}'
   , '{$_SESSION['add']['EndingYear']}';
 
 ?

Also noting that there's no closing parenthesis... But maybe it's being
added in a following line.

Martin

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



Re: [PHP] confused big time

2004-04-06 Thread Andy B
 He was showing you a neatly formatted query, the example applies to
 inserts too:

 $sql = 
 INSERT INTO
tablename
(
 field1,
 field2,
 field3
)
 VALUES
   (
 '$blah',
 $here',
 '$etc'
   )
 ;

 There you have a visually instant way of telling where the missing '
 is.

 -- 
 Best regards,
  Richard Davey


sorry i got it now... didnt quite get it all right away but it does look
better that way more than anything (at least easier to deal with)...

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



Re: [PHP] confused big time

2004-04-06 Thread Andy B
 AB 1. how were those queries unreadable?? and

 You're kidding, right?
sorry...my bad... never had any writing readable code help
anywhere...guess if i do it like c/c++ then it would work better


 AB 2. whenever i put '' around the array keys in multi dimensional arrays
in a
 AB query i get a parse error of trying to use undefined keys or it doesnt
 AB expand the array all the way... and

 If you don't include '' PHP will assume you are trying to use a
 constant, which (as you haven't defined one anywhere) obviously you're
 not.

 $something = $my_array['area1']['blah']['value'];

 .. is the correct syntax, assuming the array is created as such.

 $something = $my_array[area1][blah][value];

 .. will give you a Constant Undefined error warning, as it should.

i keep getting confused on when i need to use a {} around the array to
expand it first of all (never had to use them before). the next part of my
problem was getting confused with where '' needed to go. i forgot/didnt
understand that the '' around the variable/array itself was for mysql server
use only and php ignores them to the point that it doesnt parse them
(thought it expanded them when using the {} thing).  as far as when to put
'' around index names in arrays im still confused somewhat on that one:
echo $array['index'];//the right way
echo $array[index];//right way?? at least i dont get
//errors
echo $array$array[\'index\'];//works on my server but
//never use it
 AB 3. when i used the {} on the arrays and the '' around the keys all i
got was
 AB parse error because of the '' around them...

 Try this - right before your query dump out the value of $_SESSION
 with either var_dump() or print_r() - see if ALL of the values you are
 trying to insert into your query are present and correct. I have a
 feeling you'll find they aren't.

hmmm well i wont post my $_SESSION var dump here because it took a while
just for me to read it... they are all there just the way they should (like
i said above i referrenced them the wrong way)...

 BTW you don't need to insert NULL values in MySQL, you can just not
 insert anything if null is the default anyway for that field.

hmmm the way the table was set up is a timestamp(14) field called Posted and
a value of some kind is required because the table was set up with:
Posted timestamp(14) default not null

so as far as i know of a value of some kind is required (NULL itself or some
date string)...
sorry for all the trouble with stuff (still dont get lots of stuff) havent
done php/mysql stuff for a year yet so kind of new at it i guess...

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



Re: [PHP] confused big time

2004-04-06 Thread Andy B
i was hoping that wouldn't cause any confusion, but i guess it did. the
thing to remember is that a query is a query. you know, parts is parts.

oops stress and the fact that im sort of new at this stuff mixed me up...

$query=insert into table values(
'{$array['index1']['index2']}',
'{$array[index2']['index3']}',
//so on down the list
);

if i understand the readable way right...

oh btw if you do something like that is it possible to insert comments in
the middle of a query like that without breaking it up (i.e. for huge
queries comment on what the variables are for)??

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



Re: [PHP] confused about logic

2004-03-19 Thread Chris Boget
 To enter multiple order numbers they can comma separate like:
 1,34,21,34,54
 What I need to do is take those numbers and make a query that would like
 like:
 (cart_id in('1','34','21','34','54') OR id in('1','34','21','34','54'))
 ANY idea how I can accomplish this?

$string = ' . implode( ', ', explode( ',', '1,34,21,34,54' )) . ';

echo (cart_id in( $string ) OR id in( $string ));

Chris


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



Re: [PHP] confused about logic

2004-03-19 Thread John W. Holmes
From: Aaron Wolski [EMAIL PROTECTED]

 I have input for where users can enter order numbers in which to search
 the database to find results matching their entry.
  
 To enter multiple order numbers they can comma separate like:
 1,34,21,34,54
  
 What I need to do is take those numbers and make a query that would like
 like:
  
 (cart_id in('1','34','21','34','54') OR id in('1','34','21','34','54'))

Why do you need to put quotes around integers??

$var = '1,34,21,34,54';

//replace comma with quote,comma,quote and add quotes to beginning and end
$in_clause = ' . str_replace(',',',',$var) . ';

$query = WHERE (cart_id IN ($in_clause) OR id IN ($in_clause));

---John Holmes...

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



RE: [PHP] confused about logic

2004-03-19 Thread Aaron Wolski
Chris!

Thanks so much. This worked perfectly

Aaron

 -Original Message-
 From: Chris Boget [mailto:[EMAIL PROTECTED]
 Sent: March 19, 2004 10:59 AM
 To: Aaron Wolski; [EMAIL PROTECTED]
 Subject: Re: [PHP] confused about logic
 
  To enter multiple order numbers they can comma separate like:
  1,34,21,34,54
  What I need to do is take those numbers and make a query that would
like
  like:
  (cart_id in('1','34','21','34','54') OR id
in('1','34','21','34','54'))
  ANY idea how I can accomplish this?
 
 $string = ' . implode( ', ', explode( ',', '1,34,21,34,54' )) .
';
 
 echo (cart_id in( $string ) OR id in( $string ));
 
 Chris
 
 
 --
 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] confused about logic

2004-03-19 Thread Aaron Wolski
Thanks for the time John.

Chris's did the trick. I'll keep yours on hand in case I do happen to
run into problems.

I DO appreciate your help.

Thanks again!

Aaron

 -Original Message-
 From: John W. Holmes [mailto:[EMAIL PROTECTED]
 Sent: March 19, 2004 11:28 AM
 To: Aaron Wolski; [EMAIL PROTECTED]
 Subject: Re: [PHP] confused about logic
 
 From: Aaron Wolski [EMAIL PROTECTED]
 
  I have input for where users can enter order numbers in which to
search
  the database to find results matching their entry.
 
  To enter multiple order numbers they can comma separate like:
  1,34,21,34,54
 
  What I need to do is take those numbers and make a query that would
like
  like:
 
  (cart_id in('1','34','21','34','54') OR id
in('1','34','21','34','54'))
 
 Why do you need to put quotes around integers??
 
 $var = '1,34,21,34,54';
 
 //replace comma with quote,comma,quote and add quotes to beginning and
end
 $in_clause = ' . str_replace(',',',',$var) . ';
 
 $query = WHERE (cart_id IN ($in_clause) OR id IN ($in_clause));
 
 ---John Holmes...
 
 --
 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] confused about logic

2004-03-19 Thread Chris Boget
 Thanks for the time John.
 Chris's did the trick. I'll keep yours on hand in case I do happen to
 run into problems.
 I DO appreciate your help.

John's solution is actually technically better than mine in that it's only
using
one function call (str_replace()) and as such only one possible point of
failure whereas mine is using 2 (explode() and implode()) with 2
possible
points of failure.
This is all totally academic but am just pointing out...

Chris

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



RE: [PHP] Confused a little with = to and grater than ...

2003-03-15 Thread Dennis Cole
I think this is what you mean 

?php
// This looks cleaner, and is a lot easyer to read!
$siteAccessLevel = 2;
$gAccessLevel = 1;

switch ($siteAccessLevel) {
case level-1:
$slevel = 0;
break;
case level-2:
$slevel = 1;
break;
case level-3:
$slevel = 2;
  break;
}

switch ($gAccessLevel) {
case level-1:
$glevel = 1;
break;
case level-2:
$glevel = 2;
break;
case level-3:
$glevel = 3;
  break;
}

if ($slevel  $glevel) {

echo Access Granted;

}else{

echo You don't belong;
}


?

-Original Message-
From: Philip J. Newman [mailto:[EMAIL PROTECTED]
Sent: Saturday, March 15, 2003 8:29 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Confused a little with = to and grater than ...
Importance: Low


Well i thought about changeing access levels into numbers so that only
LARGER numbers can access lower numbers and Lower numbers can't access
anything higher ... if that makes sence ...

So 3 can access 2 and 1,
2 can't access 3, but can access 2 and 1 and one can't access 2 or 3, but
can 1 ...

assuming that $siteAccessLevel is = to eather level-1, level-2 or level-3
...

  if ($slevel = $glevel) {

is the line i can't seem to get right.

*GRIN*  any help? code below.


 if ($siteAccessLevel == level-1) { $slevel = 1; }
 else if ($siteAccessLevel == level-2) { $slevel = 2; }
 else if ($siteAccessLevel == level-3) { $slevel = 3; }

 if ($gAccessLevel == level-1) { $glevel = 1; }
 else if ($gAccessLevel == level-2) { $glevel = 2; }
 else if ($gAccessLevel == level-3) { $glevel = 3; }

  if ($slevel = $glevel) {

//LOAD PAGE

}else {

// ERROR MESSAGE HERE.

{


--
Philip J. Newman.
Head Developer
[EMAIL PROTECTED]

+64 (9) 576 9491
+64 021-048-3999

--
Friends are like stars
You can't allways see them,
but they are always there.

--
Websites:

PhilipNZ.com - Design.
http://www.philipnz.com/
[EMAIL PROTECTED]

Philip's Domain // Internet Project.
http://www.philipsdomain.com/
[EMAIL PROTECTED]

Vital Kiwi / NEWMAN.NET.NZ.
http://www.newman.net.nz/
[EMAIL PROTECTED]



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





Re: [PHP] Confused about $_SESSION and $_COOKIE scope..

2002-12-06 Thread Tom Rogers
Hi,

Saturday, December 7, 2002, 6:01:19 AM, you wrote:
CD I'm not sure why this isn't working, been banging my head at it for a couple
CD hours now.

CD I have a file (index.php), which calls a function that draws the header to
CD my page.

CD Inside that function (site_header), is an include to a file (menu.php) which
CD draws dynamic javascript menus based on
CD cookie or session values.

CD I can't seem to access ANY variables, be them $_SESSION, $_COOKIE, or
CD anything else, inside this menu.php file.  I've tried even passing simple
CD variables, globalizing them, etc, all the way down to see if I can access
CD them in that menu.php file.  I still can't.. the closest I get is being able
CD to access them in the site_header function, but when the include(menu.php)
CD is called, everything seems to vanish.

CD And yes, I have session_start(); at the top of my menu.php file as well..

CD Can anyone help me out on this?  I was under the impression that the
CD superglobals would be available from basically anything.. apparently I was
CD wrong.

CD Thanks,
CD Chad

Get rid of that second session_start() you don't need it on included files only
on the main files which the browser is asking for.

-- 
regards,
Tom


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




RE: [PHP] Confused

2002-09-23 Thread M . A . Bond

Nope,

Do a select like so:

Select user_name, group_name from users,groups where
users.group_id=groups_id order by group_name;


Then do a php loop (you'll need to find the eact php commands, this is just
an example):

While (!$results-EOF)
{

If ($results[group_name]!=$old_groupname)
{
$old_groupname=$results[group_name];
print TRTD$old_groupname/tdtdnbsp;/td/tr;
}else
{
print TRTDnbsp;/tdTD$results[user_name]/td/tr;
}
$results=mysql_fetch_array($sql);
}

You'll obviously need to get exact mysql commands etc, and open and close
your table outside the loop, but this should be basically it.


Thanks

Mark


-Original Message-
From: Rankin, Randy [mailto:[EMAIL PROTECTED]] 
Sent: 23 September 2002 13:37
To: '[EMAIL PROTECTED]'
Subject: [PHP] Confused


I have two MySQL tables, groups and users:

groups: group_id, group_name

users: user_id, user_name, group_id, etc.

I would like to produce one table for each group which will list all the

members for that particular group. For example:

Blue (group_id 1)

Tom (group_id 1)

Nancy (group_id 1)

Jim (group_id 1)

Red (group_id 2)

Bob (group_id 1)

Susan (group_id 1)

James (group_id 1)

...

My question is, do I need to run 2 queries? The first to select all the

groups and the second to select all the users in each group based on the

group_id? How would I loop through to create a table for each group? 

Thanks in advance for any help.

Randy Rankin


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




Re: [PHP] Confused

2002-09-23 Thread -=| Julien Bonastre |=-

well it depends how you want to go about it..

I have done something exactly like this, this morning.. :-p

Firstly.. you can use a normal SQL SELECT statement, but use GROUPing to
seperate the groups in this case and ORDER them alphabetically or
something..

Next.. You can do something like this:

?
$curgrp=;
$sql=mysql_query(SELECT groups.group_name, users.user_name FROM groups
INNER JOIN users ON groups.group_id=users.group_id GROUP BY
groups.group_name ORDER BY groups.group_name ASC, users.user_name
ASC,$DBH);
while($row=mysql_fetch_array($sql)) {
  if($curgrp!=$row[group_name]) {
if(strlen($curgrp)0) echo /table;
$curgrp=$row[group_name];
echo table border=1 cellpadding=2 cellspacing=2trtd
colspan=2Group: b.$row[group_name]./b/td/tr;
  }
  echo trtdnbsp;nbsp;/tdtd.$row[user_name]./tdtr;
}
?


This HAS NOT been tested. but I have ran it through the inbuilt PHP
interpretor in my brain.. and passed it through the mySQL server also up in
my head.. and it seems OK..


In any case it was mainly to demonstrate the concept.. As you can see.. It
iterates through the result table which should look a little like this
(using your data supplied):

Blue,Tom
Blue,Nancy
Blue,Jim
Red,Bob
Red,Susan
Red,James

You get it?

HIH.. Please if you notice any bugs in the coding above.. point it out.. I
did it quite quickly and with very little checking as such or testing..


Good luck ;)

I could post what I used but that could get confusing.. :-p

Anyways.. Now I'm rambling.. ha. I'm off..

--oOo---oOo--

 Julien Bonastre [The_RadiX]
 The-Spectrum Network CEO
 [EMAIL PROTECTED]
 www.the-spectrum.org

--oOo---oOo--

- Original Message -
From: Rankin, Randy [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, September 23, 2002 10:36 PM
Subject: [PHP] Confused


 I have two MySQL tables, groups and users:

 groups: group_id, group_name

 users: user_id, user_name, group_id, etc.

 I would like to produce one table for each group which will list all the

 members for that particular group. For example:

 Blue (group_id 1)

 Tom (group_id 1)

 Nancy (group_id 1)

 Jim (group_id 1)

 Red (group_id 2)

 Bob (group_id 1)

 Susan (group_id 1)

 James (group_id 1)

 ...

 My question is, do I need to run 2 queries? The first to select all the

 groups and the second to select all the users in each group based on the

 group_id? How would I loop through to create a table for each group?

 Thanks in advance for any help.

 Randy Rankin





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




Re: [PHP] Confused about the list() function

2002-07-17 Thread 1LT John W. Holmes

How do you want to parse the string? why not just echo $color_list?

---John Holmes...

- Original Message -
From: DonPro [EMAIL PROTECTED]
To: php list [EMAIL PROTECTED]
Sent: Wednesday, July 17, 2002 12:26 PM
Subject: [PHP] Confused about the list() function


Hi,

I have the following situation.  I have an array of colors that I would like
to print out.  My first course of action would be to convert the array to a
string so that I can parse it.  My command would be:

$color_list = explode(,, $color);

Now that I have a string of colors delimited by commas, I would like to
parse the string and print out all my colors.  I have read the documentation
on using the list() function but I find it confusing.  Can someone clear the
fog from my mind please?

Thanks,
Don




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




Re: [PHP] Confused about the list() function

2002-07-17 Thread Analysis Solutions

On Wed, Jul 17, 2002 at 12:26:08PM -0400, DonPro wrote:
 
 $color_list = explode(,, $color);
 
 Now that I have a string of colors delimited by commas, I would like to 
 parse the string and print out all my colors.

Start with turning on line wrapping in your email client...

Now, your sentence isn't specific enough.  What do you mean by you want
the print out all my colors?  Specifically what do you want your output
to look like?

--Dan

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

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




RE: [PHP] confused newbie on PHP and Javascript.

2002-06-13 Thread Steve Bradwell

Hi thanks for the reply,

I do believe I understand what client side and server side really mean
although I have much to learn, but is there a way to accomplish what I'm
trying to do? Maybe some kind of work around a person has found when doing
this kind of thing? 

Thanks again,

Steve

-Original Message-
From: 1LT John W. Holmes [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 13, 2002 2:26 PM
To: Steve Bradwell; [EMAIL PROTECTED]
Subject: Re: [PHP] confused newbie on PHP and Javascript.


 I am having a problem, mostly concept wise of how, or if I can use client
 side Javascript in a server side php statement.

Do you know what client side and server side really mean??

For the function below...

 function Modify_Item_Details(){

 var test =
 document.forms[0].item.options[document.forms[0].item.selectedIndex].text;

 ?
 $sql = Select i.QTY_ON_HAND, u.UNIT from items i INNER JOIN;
 $sql.=  units u ON i.Unit_Index = u.Unit_Index;
 $sql.=  where i.Item_Index = '.echo test\n.';

 $result = mysql_query($sql);
  while ($vars = mysql_fetch_array($result)){
echo document.forms[0].available.text='.$vars[0].';;
echo document.forms[0].units.text='.$vars[0].';;
  }
 ?
 }//end Modify_Item Details

you do realize that the PHP runs first, on the server, right?. The output is
then sent to the client and the javascript is exectuted. You can't mix the
two. So, when you call that Javascript function, the PHP is already done,
it's not going to execute. Do a view source of your page...

You can send Javascript variables to PHP by submitting a form or creating a
URL to be clicked on. Either way, the page has to be refreshed/submitted in
order for PHP to recieve the variable.

You can send PHP variables to Javascript, too, but the PHP runs first.

? echo scriptvar test = '$test';/script; ?

---John Holmes...


-- 
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] confused newbie on PHP and Javascript.

2002-06-13 Thread Lazor, Ed

Hi Steve,

What you're asking isn't possible.  Javascript runs client-side.  PHP runs
server-side.  You can't directly mix the two.

For example, you can use Javascript to respond when people choose menu
options, but you can't have Javascript communicate with PHP and pull
additional information from the database for your form.

You need to use a round-about approach.  Have Javascript reload the page
based on user input.  When the page is reloaded from the server, PHP can
process it (server-side).  PHP can add Javascript code / data to the page
arriving at the viewer's browser.  The Javascript runs and operates based on
this code / data.  Javascript passes information to PHP by posting forms or
including parameters in the url.

Here's another example...

You load a page for the first time...  PHP processes it...

if ($Name == )
$Name = Brian;

echo script language='Javascript';
echo \$Name = $Name;;
echo /script;



The page displays on the viewers browser and Javascript responds to user
form input.  Based on some action, Javascript reloads the page with the
following URL:

mytest.php?Name=John


Now PHP is receiving the variable Name and prints out different
JavaScript


Does this make any sense?  I'm probably not sounding very clear... someone
help describe this, please =)

-Ed


 -Original Message-
 From: Steve Bradwell [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, June 13, 2002 11:35 AM
 To: 1LT John W. Holmes; Steve Bradwell; [EMAIL PROTECTED]
 Subject: RE: [PHP] confused newbie on PHP and Javascript.
 
 
 Hi thanks for the reply,
 
 I do believe I understand what client side and server side really mean
 although I have much to learn, but is there a way to 
 accomplish what I'm
 trying to do? Maybe some kind of work around a person has 
 found when doing
 this kind of thing? 
 
 Thanks again,
 
 Steve
 
 -Original Message-
 From: 1LT John W. Holmes [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, June 13, 2002 2:26 PM
 To: Steve Bradwell; [EMAIL PROTECTED]
 Subject: Re: [PHP] confused newbie on PHP and Javascript.
 
 
  I am having a problem, mostly concept wise of how, or if I 
 can use client
  side Javascript in a server side php statement.
 
 Do you know what client side and server side really mean??
 
 For the function below...
 
  function Modify_Item_Details(){
 
  var test =
  
 document.forms[0].item.options[document.forms[0].item.selected
 Index].text;
 
  ?
  $sql = Select i.QTY_ON_HAND, u.UNIT from items i INNER JOIN;
  $sql.=  units u ON i.Unit_Index = u.Unit_Index;
  $sql.=  where i.Item_Index = '.echo test\n.';
 
  $result = mysql_query($sql);
   while ($vars = mysql_fetch_array($result)){
 echo document.forms[0].available.text='.$vars[0].';;
 echo document.forms[0].units.text='.$vars[0].';;
   }
  ?
  }//end Modify_Item Details
 
 you do realize that the PHP runs first, on the server, 
 right?. The output is
 then sent to the client and the javascript is exectuted. You 
 can't mix the
 two. So, when you call that Javascript function, the PHP is 
 already done,
 it's not going to execute. Do a view source of your page...
 
 You can send Javascript variables to PHP by submitting a form 
 or creating a
 URL to be clicked on. Either way, the page has to be 
 refreshed/submitted in
 order for PHP to recieve the variable.
 
 You can send PHP variables to Javascript, too, but the PHP runs first.
 
 ? echo scriptvar test = '$test';/script; ?
 
 ---John Holmes...
 
 
 -- 
 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
 
 

This message is intended for the sole use of the individual and entity to
whom it is addressed, and may contain information that is privileged,
confidential and exempt from disclosure under applicable law.  If you are
not the intended addressee, nor authorized to receive for the intended
addressee, you are hereby notified that you may not use, copy, disclose or
distribute to anyone the message or any information contained in the
message.  If you have received this message in error, please immediately
advise the sender by reply email and delete the message.  Thank you very
much.   

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




RE: [PHP] confused newbie on PHP and Javascript.

2002-06-13 Thread David Freeman


  I have a JavaScript function that onChange of a list box, 
  takes the value of an option and grabs data from a MySQL 
  table. My problem is how do I use the JavaScript var in my 
  sql statement?

Javascript is client-side, php is server-side.  The only way to get
something that happens in javascript to interact with something that
needs to happen on the server is to reload the page and, in doing so,
pass those variables back to the server.  The main ways you would pass
variables back to the server are either GET args in a url or POST args
from a form.

Perhaps your onChange needs to include an implied submit so that the
form data can be passed back to the server.


--
--
Outback Queensland Internet   
Longreach ** New Web Site Online *
Queensland
Australia W: www.outbackqld.net.au



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




Re: [PHP] Confused about which function to use with forms/database

2002-05-17 Thread Analysis Solutions

Don:

 I have forms that retrieve date from mysql databases and send (for
 storage) data to same databases.  I note many functions to make sure
 that the data is correct in appearance when it comes to special
 characters.
 
 addslashes()
 stripslashes()
 htmlspecialchars()
 htmlentities()
 get_html_translation_table(HTML_ENTITIES)

 When passing data from forms to database, which do I use?
 When retrieving data from database to display in forms, which do I use?

A question similar to this was just asked by Dennis
(Subject: Re: [PHP] forms into database and visa versa)

I'll copy the answer I gave there into here...

 It's a good idea to validate all data you're sticking in before you 
 do. For example, if you have a numeric field, you don't want the 
 person to be able to submit letters in that field.  So, always check 
 that the data is formatted the way you want it to be before sending it 
 to the database.

 I usually use preg_replace() to remove undesireable characters.

 If you want text to go into a field and want people to be able to 
 have quotes and other such items in there, then use addslashes().

But, it sounds like you're concerned about characters in the database
coming out properly in the HTML you generate.  So, if someone stored 
in the database, you want it to show up as lt; in your HTML.  That's 
what htmlspecialchars() is for.  Run your text coming OUT of the 
database through that.

Now, if you're then going to have users edit that data in a form and
resubmit it to the database, you need to convert the HTML entities back 
to standard ascii characters.  Here's a simple way to do that:

$replace['amp;']  = '';
$replace['lt;']   = '';
$replace['gt;']   = '';
$replace['quot;'] = '';

$UserInput = strtr($UserInput, $replace);


--Dan

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

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




Re: [PHP] Confused about which function to use with forms/database

2002-05-17 Thread Miguel Cruz

On Fri, 17 May 2002, Don wrote:
 I have forms that retrieve date from mysql databases and send (for
 storage) data to same databases.  I note many functions to make sure
 that the data is correct in appearance when it comes to special
 characters.
 
 addslashes()
 stripslashes()
 htmlspecialchars()
 htmlentities()
 get_html_translation_table(HTML_ENTITIES)
 
 I've read the documentation but am still confused about what to use when.
 
 When passing data from forms to database, which do I use?
 When retrieving data from database to display in forms, which do I use?

The basic goal is that you don't want anything being sent to your 
database's command interpreter that would result in data being taken for 
commands.

So that means that when you're sending textual data, it should be 
surrounded by quotes and any quotes inside there should be escaped 
properly.

There are different ways to make sure this gets done, and to some degree 
it's a matter of preference.

Personally, I turn magic_quotes_runtime OFF because it really creates a 
lot more work than it saves.

Then I use intval() on every integer, floatval() on every floating-point 
number, and addslashes() on every string. Then I build the SQL statement.

htmlentities has nothing to do with database operations, but is
used when sending text to browsers that might contain characters like , 
, and . It escapes those characters so that they'll be shown as intended 
rather than interpreted for their special HTML meanings.

miguel


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




RE: [PHP] Confused about which function to use with forms/database

2002-05-17 Thread David Freeman


  I've read the documentation but am still confused about what 
  to use when.
  
  When passing data from forms to database, which do I use?
  When retrieving data from database to display in forms, 
  which do I use?

Kinda depends on what you're using the data for really.  If you don't
care about preserving formatting or any sort or keeping any html tags
that are included then strip the lot out before you drop it into your
database.  If you want to keep it all then you'll need to be more
selective.

As a general rule, though, you'll need to 'escape' anything that your
database won't like - this is typically the ' and  chars.  Addslashes()
will do that for you.  Anything else you want to do depends on what you
need the data for.

When you suck the data back out you'll obviously need to stripslashes()
to get rid of the 'escape' chars you added above.  Then you'll also need
to do any other processing required - for example, converting \n to br
if you're just displaying data on a page (nl2br()).  If you're actually
sucking that data back out to go into a textarea in a form or something
then you won't do that.

Unless you're particularly careful it's probably worth stripping out all
html tags anyway as they offer the potential to have someone include
scripting.  When displaying to a html page you probably also want to
convert special chars to html entities using htmlspecialchars().

I may have missed some stuff here, didn't bother looking at a manual
while writing this but I hope you'll get the idea.

CYA, Dave



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




RE: [PHP] Confused about which function to use with forms/database

2002-05-17 Thread Miguel Cruz

On Sat, 18 May 2002, David Freeman wrote:
 As a general rule, though, you'll need to 'escape' anything that your
 database won't like - this is typically the ' and  chars.  Addslashes()
 will do that for you.  Anything else you want to do depends on what you
 need the data for.
 
 When you suck the data back out you'll obviously need to stripslashes()
 to get rid of the 'escape' chars you added above.

Nope, because the escape characters don't actually get added to the 
database.

If you have a string:

Chief O'Brien

and you want to pass it into a database whose command interpreter uses 
single quotes (') as string delimeters, then you need to tell it that the 
' after O is not the end of the string. So you use addslashes() to preface 
it with a backslash (\). This results in the following string:

Chief O\'Brien

When the database's command interpreter sees it, it removes the escape
character (\) before inserting the string into the database. So it's back
to its original form then. When you retrieve it, you'll just get:

Chief O'Brien

miguel


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




RE: [PHP] Confused about which function to use with forms/database

2002-05-17 Thread David Freeman


   When you suck the data back out you'll obviously need to 
   stripslashes() to get rid of the 'escape' chars you added above.
  
  Nope, because the escape characters don't actually get added to the 
  database.

  When the database's command interpreter sees it, it removes 
  the escape character (\) before inserting the string into 
  the database. So it's back to its original form then. When 
  you retrieve it, you'll just get:

Ah, fair enough.  Obviously, I've never actually tested that particular
behaviour.  I'll keep this in mind for future reference though.

CYA, Dave



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




RE: [PHP] Confused About Classes

2002-03-25 Thread Rick Emery

  if ($this-private==FALSE) //   Undefined variable
this
  return;
 }

$this is relevant ONLY within the scope of the class definition.
The above snippet is located OUTSIDE of the class definition.
You must use an object pointer.  That is:

$newobj = new standardquestion($filename);
if( $newobj-private==FALSE)
{
}
-Original Message-
From: arti [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 25, 2002 9:33 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Confused About Classes


I am getting the error Undefined variable this in my class.  I am new to
PHP and presume I am just doing something wrong.  But, I don't understand
what it could be as the code looks straightforward to me.  Note that I
trimmed out some code to keep this listing from being huge, but the relevant
pieces are included.


?php

class standardquestion
{

var $private;

function standardquestion($xmlfilename)
{

 $this-private=FALSE;

 $parser=xml_parser_create();

 xml_set_element_handler($parser,
array(standardquestion,startElementHandler),
array(standardquestion,endElementHandler));

 while ($data = fread($fp, 4096))
 {
  if (!xml_parse($parser, $data, feof($fp)))
  {
   die(sprintf(XML error %d %d,
xml_get_currentnode_line_number($parser),
xml_get_currentnode_column_number($parser)));
  }
 }
}

function startElementHandler($parser, $name, $attribs)
{
 if ($name==private)
  $this-private = TRUE;

 if ($this-private==FALSE) //   Undefined variable this
  return;
}


function endElementHandler($parser, $name)
{
}


}
?




-- 
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] Confused About Classes

2002-03-25 Thread arti

No, the only thing I supplied is the class.  The startElementHandler IS a
function in the class.



Rick Emery [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   if ($this-private==FALSE) //   Undefined variable
 this
   return;
  }

 $this is relevant ONLY within the scope of the class definition.
 The above snippet is located OUTSIDE of the class definition.
 You must use an object pointer.  That is:

 $newobj = new standardquestion($filename);
 if( $newobj-private==FALSE)
 {
 }
 -Original Message-
 From: arti [mailto:[EMAIL PROTECTED]]
 Sent: Monday, March 25, 2002 9:33 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Confused About Classes


 I am getting the error Undefined variable this in my class.  I am new to
 PHP and presume I am just doing something wrong.  But, I don't understand
 what it could be as the code looks straightforward to me.  Note that I
 trimmed out some code to keep this listing from being huge, but the
relevant
 pieces are included.


 ?php

 class standardquestion
 {

 var $private;

 function standardquestion($xmlfilename)
 {

  $this-private=FALSE;

  $parser=xml_parser_create();

  xml_set_element_handler($parser,
 array(standardquestion,startElementHandler),
 array(standardquestion,endElementHandler));

  while ($data = fread($fp, 4096))
  {
   if (!xml_parse($parser, $data, feof($fp)))
   {
die(sprintf(XML error %d %d,
 xml_get_currentnode_line_number($parser),
 xml_get_currentnode_column_number($parser)));
   }
  }
 }

 function startElementHandler($parser, $name, $attribs)
 {
  if ($name==private)
   $this-private = TRUE;

  if ($this-private==FALSE) //   Undefined variable
this
   return;
 }


 function endElementHandler($parser, $name)
 {
 }


 }
 ?




 --
 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] Confused About Classes

2002-03-25 Thread Rick Emery

However, startElementHandler() is not be called in a class context.
According to the manual for xml_set_element_handler():
There is currently no support for object/method handlers.


-Original Message-
From: arti [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 25, 2002 9:43 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Confused About Classes


No, the only thing I supplied is the class.  The startElementHandler IS a
function in the class.



Rick Emery [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   if ($this-private==FALSE) //   Undefined variable
 this
   return;
  }

 $this is relevant ONLY within the scope of the class definition.
 The above snippet is located OUTSIDE of the class definition.
 You must use an object pointer.  That is:

 $newobj = new standardquestion($filename);
 if( $newobj-private==FALSE)
 {
 }
 -Original Message-
 From: arti [mailto:[EMAIL PROTECTED]]
 Sent: Monday, March 25, 2002 9:33 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Confused About Classes


 I am getting the error Undefined variable this in my class.  I am new to
 PHP and presume I am just doing something wrong.  But, I don't understand
 what it could be as the code looks straightforward to me.  Note that I
 trimmed out some code to keep this listing from being huge, but the
relevant
 pieces are included.


 ?php

 class standardquestion
 {

 var $private;

 function standardquestion($xmlfilename)
 {

  $this-private=FALSE;

  $parser=xml_parser_create();

  xml_set_element_handler($parser,
 array(standardquestion,startElementHandler),
 array(standardquestion,endElementHandler));

  while ($data = fread($fp, 4096))
  {
   if (!xml_parse($parser, $data, feof($fp)))
   {
die(sprintf(XML error %d %d,
 xml_get_currentnode_line_number($parser),
 xml_get_currentnode_column_number($parser)));
   }
  }
 }

 function startElementHandler($parser, $name, $attribs)
 {
  if ($name==private)
   $this-private = TRUE;

  if ($this-private==FALSE) //   Undefined variable
this
   return;
 }


 function endElementHandler($parser, $name)
 {
 }


 }
 ?




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



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

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




Re: [PHP] Confused object in session variable.

2001-10-25 Thread Steve Cayford

An update...
I had register_globals turned off. Now that I've turned register_globals 
on and changed my references from $HTTP_SESSION_VARS['ucAuthoUser'] to 
$ucAuthoUser it works as I expect.

I'm not real happy with having register_globals on, though, and I'd like 
to figure out what I was doing wrong.

Thanks for any suggestions.

-Steve

On Thursday, October 25, 2001, at 12:07  PM, Steve Cayford wrote:

 Well, it's probably me that's confused. I have an authenticate() 
 function which should start a session and if the user is not logged in 
 then show the login screen otherwise return after storing and 
 registering a user object in a session variable. This object has 
 accessor methods to get the login name, access level, etc... This seems 
 to work okay--within the authenticate function I can access the object 
 in the HTTP_SESSION_VARS array. But as soon as I return to the main 
 script it's gone. I must be doing something wrong with the scoping, but 
 I can't see what. Any thoughts? Here's the code:

 ?php
 /* - */
 /* index.php */
 /* - */

 require_once('ucautho/ucautho.inc');

 authenticate();

 print(From index testUser:  . $testUser-getLogin() . br\n);
 print(From index HTTP_SESSION_VARS['ucAuthoUser']: );
 print($HTTP_SESSION_VARS['ucAuthoUser']-getLogin() . br\n); //this 
 is line 12

 ?

 ?php
 /* --- */
 /* ucautho/ucautho.inc */
 /* --- */

 function authenticate($appName=) {
 global $HTTP_SESSION_VARS, $HTTP_POST_VARS;
 global $testUser;
 session_name(UCAutho);
 session_start();

 if (isset($HTTP_SESSION_VARS['ucAuthoUser'])  
 $HTTP_SESSION_VARS['ucAuthoUser']-isValid()) {
 return;
 } else {
 if (isset($HTTP_POST_VARS['authoSubmit'])) {
 $HTTP_SESSION_VARS['ucAuthoUser'] =
 new 
 UcAuthoUser($HTTP_POST_VARS['authoLogin'],$HTTP_POST_VARS['authoPword']);
 if ($HTTP_SESSION_VARS['ucAuthoUser']-isValid()) {
 session_register('ucAuthoUser');
 $testUser = $HTTP_SESSION_VARS['ucAuthoUser'];
 print(From authenticate testUser:  . 
 $testUser-getLogin() . br\n);
 print(From authenticate 
 HTTP_SESSION_VARS['ucAuthoUser']: );
 print($HTTP_SESSION_VARS['ucAuthoUser']-getLogin() . 
 br\n);
 return;
 }
 }
 showLogin($appName);
 }
 }

 /* more functions and the class declaration snipped */

 ?

 Here's what I get when I login as 'steve' with a good password:

 From authenticate testUser: steve
 From authenticate HTTP_SESSION_VARS['ucAuthoUser']: steve
 From index testUser: steve
 From index HTTP_SESSION_VARS['ucAuthoUser']:
 Fatal error: Call to a member function on a non-object in 
 /home/httpd/html/ucdamage/index.php on line 12

 Note the testUser works in both instances, the session var only works 
 inside the function.

 -Steve


 -- PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] confused with sessions

2001-06-22 Thread Chris Lee

trans_sid is only enabled when cookies are not supported. php.ini has
session.use_cookies = 0; this will disable cookies and force trans-sid. you
should also verify trans-sid with phpinfo(), make sure it really did get
compiled in.

trans-sid will only re-write urls that are not full urls. ie.

index.php is ok
http://www.e-tankless.com/index.php is not. you will have to re-write it
yourself.

if cookies are disabled and the phpsessid is not in the url then php has
absolutly no way of knowing its the same customer, therfore it creates a new
phpsessid.

--

  Chris Lee
  [EMAIL PROTECTED]




kaab kaoutar [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hi!
 I'm confused with these sessions :(
 well here is what i want to do!
 I have a web site whos pages are all composed of frames(4)!
 and in the top frame i have the loggin button!
 i want , once the user logged, the fees that are in pages (frames) become
 visible and once logged out, the fees likns disappear...
 i have  atable that in mysql dbs that stores users login!
 enable_transit_id is enabled in php! the os is unix and wS is apache!

 Any ideas?
 What i've done so far is to start sessions in each page register the
logged
 boolean once logged and destroy it once logged out!
 also i had to phpsessid to each url in frames otherwise it does not work!
i
 also added the session_name but if i don't add phpsessid to urls it
creates
 new sessions each time !
 i don't want to use cookies, they are enabled ! maybe that's why
 session_name does not work ?

 Please help me !

 _
 Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] confused about getenv arguements

2001-01-27 Thread Rasmus Lerdorf

Just put ?phpinfo()? in a file and read through it.  Note that
HTTP_REFERER (1 R) is only set if you click on a link to get to the page.

Also note that relying on HTTP_REFERER for anything important is not safe.
Anybody can spoof this variable.

-Rasmus

On Sat, 27 Jan 2001, Noel Akins wrote:

 Hello,
 I found this script at zend. Please note the getenv("HTTP_REFFERER").

 ?

 /* Anti-leech bandwidth protecter by Corey Milner, http://www.odey.com.
 Turn the refererring URL into a variable */
 $from = getenv("HTTP_REFERER");

 /* Check to see if the URL in the variable is a valid referrer. Add the
 page URL which you would like people to arrive from here. */
 if ($from != "http://www.yoursite.com/validpage.htm")

 /* If the URL is valid, page loads now */

 /* If URL is invalid the following error message and proper link appears,
 enter your custom error message and a hyperlink to the valid URL you
 entered above here*/
 {print(" Sorry you have tried to link to a page which does not accept
 visitors directly. br
 a href=http://www.yoursite.com/validpage.htmCLICK HERE/a to enter");

 /* Prevent the rest of the page from loading */
 exit;}

 ?

 I went to check getenv in the php manual, and it said "You can see a list
 of all the environmental variables by using phpinfo(). You can find out
 what many of them mean by taking a look at the CGI specification,
 specifically the page on environmental variables.

 I made a php script phpinfo(INFO_ALL) to return everything for my host and
 did not see HTTP_REFFERER, not did I see any of the other args that were in
 the comments on the getenv page.
 I looked at the linked cgi pages and didn't find anything there either.

 If by not seeing these HTTP_like variables in my phpinfo, does that mean
 they are unavailable to me to use? Do they have to be setup during the
 install of php/apache?
 Where can I get more info on these getenv args/vars?

 Thanks


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]