[PHP] problem reading sessions

2002-01-04 Thread Alastair


I have just recently set up PHP on my Win2K laptop and I have just found out
that I can't read sessions. As far as I can tell the session file is being
created, but PHP doesn't seem to be able to get any data into it.

Here is what the session file looks like:
!sess_user|!blah|

The two PHP files look like this:

test_session1.php
?
$blah = good;
session_start();
session_register(blah);
?


test_session2.php
?
session_start();
echo session_is_registered(blah) . br;
echo session_encode(). br;
echo isset($HTTP_SESSION_VARS) . br;
echo sizeof($HTTP_SESSION_VARS) . br;

echo $blah;
?

For the second PHP page the ouput I get is:
- true for the 'session is registered' function
- the string that is found in the session file (listed above)
- true for the 'isset' function
- size of zero
- The warning: 'Warning: Undefined variable: blah '

Does anybody know why I would not be able to read these variables?

thanks,
alastair




-- 
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] problem reading sessions

2002-01-04 Thread Alastair

I get the error: 'Warning: Undefined index: blah' when I use the long name.
As far as I can tell it doesn't seem to be actually writing the data into
the session file.  Am I missing a crucial step somewhere?

alastair

Kevin Stone [EMAIL PROTECTED] wrote in message
003401c19563$95ee2e00$[EMAIL PROTECTED]">news:003401c19563$95ee2e00$[EMAIL PROTECTED]...
 I'll add if you do not have register_globals set then you can access the
 variable by its long name, $HTTP_SESSION_VARS[blah].

 -Kevin


  Is register_globals set to 'on' in php.ini? It needs to be for this
coding
  style to work.
 
  Kirk
 
   -Original Message-
   From: Alastair [mailto:[EMAIL PROTECTED]]
   Sent: Friday, January 04, 2002 1:41 PM
   To: [EMAIL PROTECTED]
   Subject: [PHP] problem reading sessions
  
  
  
   I have just recently set up PHP on my Win2K laptop and I have
   just found out
   that I can't read sessions. As far as I can tell the session
   file is being
   created, but PHP doesn't seem to be able to get any data into it.
  
   Here is what the session file looks like:
   !sess_user|!blah|
  
   The two PHP files look like this:
  
   test_session1.php
   ?
   $blah = good;
   session_start();
   session_register(blah);
   ?
  
  
   test_session2.php
   ?
   session_start();
   echo session_is_registered(blah) . br;
   echo session_encode(). br;
   echo isset($HTTP_SESSION_VARS) . br;
   echo sizeof($HTTP_SESSION_VARS) . br;
  
   echo $blah;
   ?
  
   For the second PHP page the ouput I get is:
   - true for the 'session is registered' function
   - the string that is found in the session file (listed above)
   - true for the 'isset' function
   - size of zero
   - The warning: 'Warning: Undefined variable: blah '
  
   Does anybody know why I would not be able to read these variables?
  
   thanks,
   alastair
 
  --
  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] problem reading sessions

2002-01-04 Thread Alastair

yup, it's set correctly.  It actually creates the file (I've opened it in a
text editor) with the correct variable names, but just no values.
R'Twick Niceorgaw [EMAIL PROTECTED] wrote in message
065d01c1956a$f1321db0$[EMAIL PROTECTED]">news:065d01c1956a$f1321db0$[EMAIL PROTECTED]...
 Have you set the session.save_path properly in php.ini ? By default it is
 set to /tmp which doesn't work under Win* systems. You need to point it to
a
 valid directory on your machine.

 HTH

 - Original Message -
 From: Alastair [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Friday, January 04, 2002 4:35 PM
 Subject: Re: [PHP] problem reading sessions


  I get the error: 'Warning: Undefined index: blah' when I use the long
 name.
  As far as I can tell it doesn't seem to be actually writing the data
into
  the session file.  Am I missing a crucial step somewhere?
 
  alastair
 
  Kevin Stone [EMAIL PROTECTED] wrote in message
  003401c19563$95ee2e00$[EMAIL PROTECTED]">news:003401c19563$95ee2e00$[EMAIL PROTECTED]...
   I'll add if you do not have register_globals set then you can access
the
   variable by its long name, $HTTP_SESSION_VARS[blah].
  
   -Kevin
  
  
Is register_globals set to 'on' in php.ini? It needs to be for this
  coding
style to work.
   
Kirk
   
 -Original Message-
     From: Alastair [mailto:[EMAIL PROTECTED]]
 Sent: Friday, January 04, 2002 1:41 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] problem reading sessions



 I have just recently set up PHP on my Win2K laptop and I have
 just found out
 that I can't read sessions. As far as I can tell the session
 file is being
 created, but PHP doesn't seem to be able to get any data into it.

 Here is what the session file looks like:
 !sess_user|!blah|

 The two PHP files look like this:

 test_session1.php
 ?
 $blah = good;
 session_start();
 session_register(blah);
 ?


 test_session2.php
 ?
 session_start();
 echo session_is_registered(blah) . br;
 echo session_encode(). br;
 echo isset($HTTP_SESSION_VARS) . br;
 echo sizeof($HTTP_SESSION_VARS) . br;

 echo $blah;
 ?

 For the second PHP page the ouput I get is:
 - true for the 'session is registered' function
 - the string that is found in the session file (listed above)
 - true for the 'isset' function
 - size of zero
 - The warning: 'Warning: Undefined variable: blah '

 Does anybody know why I would not be able to read these variables?

     thanks,
 alastair
   
--
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]
 
 




-- 
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] Strange Session Issues

2002-01-07 Thread Alastair

I posted a question earlier,  but I don't think I explained my problem all
that well.

I am having problem with sessions on my W2K box.  I can start sessions and
register variables but  I can't, however, seem to get the contents of the
registered variables written.

When I open the session file (the actual physical file located on the
server), this is its contents:

!sess_user|!blah|!sessUserClass|!sessFormData|!oUser|

Each of those variables should have some data associated with them.  Please
note that I have not added the '!' to the variables.

I don't think I am having file permission problems because some data is
actually being written.  The only data missing (and the most crucial) is the
contents of each those variables.

Does anybody have any suggestions?

Thanks!

alastair






-- 
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] Strange Session Issues

2002-01-07 Thread Alastair

I've turned it off.  When I try reading a variable using
$HTTP_SESSION_VARS[blah] but it says that there is no index for 'blah'.

thanks!
alastair
Kirk Johnson [EMAIL PROTECTED] wrote in message
01A4B59FD1EBD311838100A0C98BE0D9AD5EFB@chef">news:01A4B59FD1EBD311838100A0C98BE0D9AD5EFB@chef...
 Once again, is register_globals on or off in your php.ini file? It would
 help us if we knew that :)

 Kirk

  -Original Message-
  From: Alastair [mailto:[EMAIL PROTECTED]]
  Sent: Monday, January 07, 2002 9:05 AM
  To: [EMAIL PROTECTED]
  Subject: [PHP] Strange Session Issues
 
 
  I posted a question earlier,  but I don't think I explained
  my problem all
  that well.
 
  I am having problem with sessions on my W2K box.  I can start
  sessions and
  register variables but  I can't, however, seem to get the
  contents of the
  registered variables written.



-- 
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] Strange Session Issues

2002-01-07 Thread Alastair

WOO HOO!!! :-)

Thanks Kirk! I didn't realize that you had to use session_vars to write the
variables as well.  That's a huge weight taken off my chest. :-)

cheers,
alastair


Kirk Johnson [EMAIL PROTECTED] wrote in message
01A4B59FD1EBD311838100A0C98BE0D9AD5EFC@chef">news:01A4B59FD1EBD311838100A0C98BE0D9AD5EFC@chef...
 With it off, session_register() is not needed. Also, session variables
must
 be accessed thru the $HTTP_SESSION_VARS[] array. Try this code:

 test_session1.php
 ?
 session_start();
 $HTTP_SESSION_VARS['blah'] = good;
 ?

 test_session2.php
 ?
 session_start();
 echo session_is_registered(blah) . br;
 echo session_encode(). br;
 echo isset($HTTP_SESSION_VARS) . br;
 echo sizeof($HTTP_SESSION_VARS) . br;

 echo $HTTP_SESSION_VARS['blah'];
 ?

  -Original Message-
  From: Alastair [mailto:[EMAIL PROTECTED]]
  Sent: Monday, January 07, 2002 9:33 AM
  To: [EMAIL PROTECTED]
  Subject: Re: [PHP] Strange Session Issues
 
 
  I've turned it off.  When I try reading a variable using
  $HTTP_SESSION_VARS[blah] but it says that there is no index
  for 'blah'.
 
  thanks!
  alastair
  Kirk Johnson [EMAIL PROTECTED] wrote in message
  01A4B59FD1EBD311838100A0C98BE0D9AD5EFB@chef">news:01A4B59FD1EBD311838100A0C98BE0D9AD5EFB@chef...
   Once again, is register_globals on or off in your php.ini
  file? It would
   help us if we knew that :)
  
   Kirk
  
-Original Message-
    From: Alastair [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 07, 2002 9:05 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Strange Session Issues
   
   
I posted a question earlier,  but I don't think I explained
my problem all
that well.
   
I am having problem with sessions on my W2K box.  I can start
sessions and
register variables but  I can't, however, seem to get the
contents of the
registered variables written.
 
 
 
  --
  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]




[PHP] session_unregister and register_globals = Off

2002-01-10 Thread Alastair


I'm having difficulty trying to figure out how unregister a variable when
register_globals is turned on.  I've tried session_unregister but it doesn't
seem to do anything.

thanks,
alastair



-- 
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] form values and the back button

2002-01-12 Thread Alastair

Is there a way to ensure that the data in a form is not cleared when you
click the back button?

I have numerous forms that all have some PHP error checking.  The standard
error page has a simple JavaScript back command.  Every time I click it (or
the browser's back button), it clears the form on the previous page.  I
really don't want to have to keep all the data and repopulate the form if I
don't have to.

thanks,
alastair



-- 
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] Re: HTTP Server vars

2002-01-12 Thread Alastair

I'm not exactly sure what you are asking..  Are you wondering if it is safer
to have register_globals on or off?  If it is off, you will have to access
all the globals through the $HTTP_*_VARS variables.  They are quite a bit
safer but require a bit of getting used too (just look at my posts in the
last few days..).

cheers,
alastair

Gerard Samuel [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hey all.  I was wondering.  Is it safe to use HTTP global variables ie
 $HTTP_POST_VARS etc in my scripts?
 Thought I read somewhere that they weren't safe.
 Got a lot of forms to work with, it sure would make life easier...




-- 
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] Cheap, PHP, mySQL hosting!

2002-02-13 Thread Alastair Battrick

 Lookin for about 50 Megs with php4, mySQL and the
 works. Any economical hosts??

You could try:
http://www.datasnke.co.uk
And I am biased...

Alastair
Lightwood Consultancy Ltd


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




RE: [PHP] how a function 'return' statement works

2002-02-14 Thread Alastair Battrick

Do you not have to make $_SERVER a global variable in the function ?

Alastair
Lightwood Consultancy Ltd

 Hm... I tried quite a few variations on this.  I can't seem to get any 
 displayable value out of this function.
 
 function get_current_page_name()
 {
 $current_page_name = explode(/, $_SERVER['PHP_SELF']);
 $current_page_name = $current_page_name[-1];
 return $current_page_name ;
 }
 
 $errorcode = get_current_page_name();
 echo $errorcode;
 
 Nothing.
 
 The only thing that works is $errorcode = 
 basename($_SERVER['PHP_SELF']), but that's not the point -- I still 
 don't understand why the function above doesn't return anything.  In 
 this case, I'm positive that I've specified the last element of the 
 array.  (Haven't I?)
 
 
 Erik
 
 
 
 
 On Wednesday, February 13, 2002, at 05:03  PM, Darren Gamble wrote:
 
  I think what you're trying to do is return one particular element out 
  of the
  array.  If that's the case, just use something like:
 
  return $current_page_name[-1]
 
  to return the last element in the array.
 
  
 
 
 
 Erik Price
 Web Developer Temp
 Media Lab, H.H. Brown
 [EMAIL PROTECTED]
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

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




RE: [PHP] get_browser();

2002-02-18 Thread Alastair Battrick

Have you got the browscap.ini file installed properly ?

and

have you got a up to date version of browscap.ini ?

and

What is reported by IE visitng the script ?


Alastair

 -Original Message-
 From: Chris Boget [mailto:[EMAIL PROTECTED]]
 Sent: 18 February 2002 17:48
 To: [EMAIL PROTECTED]
 Subject: [PHP] get_browser();
 
 
 The following example that is in the onsite documentation:
 
 ?
 function list_array ($array) {
 while (list ($key, $value) = each ($array)) {
 $str .= b$key:/b $valuebr\n;
 }
 return $str;
 }
 echo $HTTP_USER_AGENThr\n;
 $browser = get_browser();
 echo list_array ((array) $browser);
 ?
 
 Isn't working as described in the example output provided on
 the page.  In fact, half the time, get_browser() is returning
 nothing.  And HTTP_USER_AGENT is only returning:
 
 Mozilla/4.7 [en] (Win95; I)
 
 for Netscape.  Why isn't it (get_browser()) providing all the
 information as displayed in the example provided in the docs?
 
 Ultimately, I'm trying to figure out how I can determine if the
 user is using NS 4.x or not...
 
 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] mktime() into TIMESTAMP ?

2002-03-04 Thread Alastair Battrick

Just make sure that whichever way you choose, you always use the same style,
so things don't get messy.

Personally, I always use INT(11) MySQL columns and store the unix timestamp
and this makes things easy for me. The only exception is when storing dates
that are before 1970, but I very rarely have to do this.

In the end, I guess it depends if you want to do the formatting of the date
field when you're inserting the data (use TIMESTAMP) or when you're pulling
it out (use INT).


Alastair Battrick
Lightwood Consultancy Ltd
http://www.lightwood.net

 -Original Message-
 From: Erik Price [mailto:[EMAIL PROTECTED]]
 Sent: 04 March 2002 22:12
 To: PHP (E-mail)
 Subject: [PHP] mktime() into TIMESTAMP ?


 PHP's mktime() function uses a timestamp that is the number of seconds
 since the Unix epoch.  MySQL uses the MMDDhhmmss format for its
 TIMESTAMP column type.

 I'm not complaining that they're not the same, but curious as to which I
 should use for storing timestamps -- does it matter?  PHP has a lot of
 nice formatting conventions with date(), so I am leaning towards using
 mktime() to store PHP-style timestamps into a MySQL TIMESTAMP column.
 But MySQL does have the ability to format dates, and its TIMESTAMP
 column type bumps up if I don't manually insert a value.

 Any suggestions?


 Erik




 

 Erik Price
 Web Developer Temp
 Media Lab, H.H. Brown
 [EMAIL PROTECTED]


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


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




RE: [PHP] number_format

2002-03-08 Thread Alastair Battrick

why not multiply the number by 1000 and then use
str_pad($in,6,0,STR_PAD_LEFT)

Alastair Battrick
Senior Developer
Lightwood Consultancy Ltd
http://www.lightwood.net

 -Original Message-
 From: Scott St. John [mailto:[EMAIL PROTECTED]]
 Sent: 08 March 2002 17:02
 To: [EMAIL PROTECTED]
 Subject: [PHP] number_format


 Hi everyone,

 I am trying to format a number for a report, the one consistant thing is
 the three decimal places.  But I need to strip them, then fill in zero's
 from the left.

 So, if the number coming in is 8.000 I need to convert to 00800, 11.070
 would convert to 01107.

 I have tried a combination of number_format and usually end up with 8000
 or 00110.

 Help!  Thank you!  Mind in slow motion this morning.

 -Scott


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


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




RE: [PHP] Re: Can't display PNG images

2002-03-12 Thread Alastair Battrick

Echoing text to the screen is a very useful debugging tool when creating
images from php, if you type the full location of the image script in the
address bar, rather than specifying it as an image that is opened by a html
page.

If you do this Teresa, you should get the PHP error message, and if you give
this to us it would help.

Alastair Battrick
Senior Developer
Lightwood Consultancy Ltd
http://www.lightwood.net

 -Original Message-
 From: Jordan S. Jones [mailto:[EMAIL PROTECTED]]
 Sent: 12 March 2002 11:29
 To: [EMAIL PROTECTED]
 Subject: [PHP] Re: Can't display PNG images


 The icon essentially means that it was a broken image, or that
 they code did
 not work.  I know that wasn't much help.

 On another point, in my opinion, it doesn't make a whole lot of logical
 sense to have a die(Error text) statement in code that creates
 an image..
 If an error does occur, it will still display the same broken image icon.
 However, I am not the definitive word on the matter, and if you or anyone
 else has a different opinion on the matter, I would be more than happy to
 hear it.

 Jordan

 Teresa Narvaez [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Hello,
  Background info:
  
  I'm running
  o PHP 4.1.1 on a linux server kernel(2.2.16).
  o Using Netscape Communicator 4.75
  o Compiled and installed the gd(1.8.4) library
 
  Problem(2 problems):
  
  1.- The following code won't display an image(I get an icon of some type
 of
  piece of paper).
  ?php
 header (Content-type: image/png);
 $im = @ImageCreate (50, 100)
or die (Cannot Initialize new GD image stream);
 $background_color = ImageColorAllocate ($im, 255, 255, 255);
 $text_color = ImageColorAllocate ($im, 233, 14, 91);
 ImageString ($im, 1, 5, 5,  A Simple Text String, $text_color);
 ImagePng ($im);
  ?
 
  2.- The configure Command from phpinfo() is different than what
 I actually
  typed at the
  command line.  Also, phpinfo() area for GD does not show PNG or JPEG
  support.  why?
 from phpinfo()
 --
   './configure' '--with-mysql' '--with-apxs=/var/apache/bin/apxs'
   '--with-gd=/home/builder/downloads/untarred/gd-1.8.4'
  '--enable-sockets'
   '--enable-calendar' '--enable-ftp' '--enable-trans-sid'
 What I typed at the command line:
 -
   ./configure --with-mysql --with-apxs=/var/apache/bin/apxs
--with-gd=/home/builder/downloads/untarred/gd-1.8.4
--with-png-dir=/usr/lib --enable-gd-native-ttf --with-ttf
--with-jpeg-dir=/home/builder/downloads/untarred/jpeg-6b
--with-t1lib=/home/builder/downloads/untarred/t1lib-1.3.1
--enable-sockets --with-zlib-dir --with-xpm-dir
 --enable-calenda
 r
--enable-ftp --enable-trans-sid
 
  OUTPUT from phpinfo()
  ---
  GD Supportenabled
  GD Version1.6.2 or higher
  WBMP Support  enabled
 
  I would really appretiate any ideas you could give me.
  Thanks in advance! -Teresa
 
 
 
 



 --
 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] sessions

2002-03-20 Thread Alastair Battrick

There must be some whitespace in the script before the opening ?php

Lose that and the error should go with it.

Alastair Battrick
Senior Developer
Lightwood Consultancy Ltd
http://www.lightwood.net 

 I am kind of confused by an error I am getting when trying to destroy a
 session.  Here is the error that I am receiving along with the 
 code that is
 causing the problem.
 
 Warning: Cannot send session cache limiter - headers already sent (output
 started at /home/www/wildwebtech/cumc/default.php:9) in
 /home/www/wildwebtech/cumc/default.php on line 10
 
 ?
   session_start();
 
   $old_user = $cumc_user;  // store  to test if they *were* logged in
   $result = session_unregister(cumc_user);
   session_destroy();
 ?


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




RE: [PHP] fsockopen

2002-03-26 Thread Alastair Battrick

Is $tempPort set ?

Alastair Battrick
Senior Developer
Lightwood Consultancy Ltd
http://www.lightwood.net


 -Original Message-
 From: Christoph Starkmann [mailto:[EMAIL PROTECTED]]
 Sent: 26 March 2002 12:40
 To: '[EMAIL PROTECTED]'
 Subject: [PHP] fsockopen


 Hi!

 I'm trying to check the validity of given hyperlinks...
 I thought this code should work (Apache 1.3.9, Win98)

 $tempUrl = ereg_replace(http://;, , $url);

 $fp = fsockopen ($tempUrl, $tempPort, $errno, $errstr, 30);

 if (!$fp)
 {
 echo brerror opening $url: \$errstr=$errstr, \$errno=$errnobr\n;
 }
 else
 {
 fputs ($fp, GET / HTTP/1.0\r\n\r\n);
   echo brs . fgets($fp,1024);
 fclose($fp);
 }

 For each and every url,

 $fp = false;
 $errstr = ;
 $errno = 0;

 Where is my mistake? I guess I'm simply getting sth wrong...

 Any hint would be great.

 Cheers,
 Kiko

 -
 It's not a bug, it's a feature.
 christoph starkmann
 mailto:[EMAIL PROTECTED]
 http://www.fh-augsburg.de/~kiko
 ICQ: 100601600
 -

 --
 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] fsockopen

2002-03-26 Thread Alastair Battrick

There are a few things that it could be.

Change the ereg_replace to str_replace

Try adding Host: $server_name on the line after the GET:

fputs ($fp, GET / HTTP/1.0\r\nHost: $server_name\r\n\r\n);

iirc, if the server uses virtual hosts, the GET won't work properly without
it.

If that's not it, try adding this instead of your single echo line:

while (!feof ($fp)) {
  $line = fgets($fp, 4096);
  echo $line;
}

As that will return and echo all the page, not just the header.

Alastair

 -Original Message-
 From: Christoph Starkmann [mailto:[EMAIL PROTECTED]]
 Sent: 26 March 2002 12:48
 To: '[EMAIL PROTECTED]'; Christoph Starkmann; [EMAIL PROTECTED]
 Subject: RE: [PHP] fsockopen


 Hi!

  Is $tempPort set ?

 Yes... 80 as default...

   $tempUrl = ereg_replace(http://;, , $url);
  
   $fp = fsockopen ($tempUrl, $tempPort, $errno, $errstr, 30);
  
   if (!$fp)
   {
   echo brerror opening $url: \$errstr=$errstr,
  \$errno=$errnobr\n;
   }
   else
   {
   fputs ($fp, GET / HTTP/1.0\r\n\r\n);
 echo brs . fgets($fp,1024);
   fclose($fp);
   }

 Cheers...
 Kiko

 -
 It's not a bug, it's a feature.
 christoph starkmann
 mailto:[EMAIL PROTECTED]
 http://www.fh-augsburg.de/~kiko
 ICQ: 100601600
 -


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




[PHP] OT - representing data

2002-03-29 Thread Alastair Battrick

Hi All

I have over 26000 urls in a table. They are all urls and query strings of
hits to the same 10 - 20 sites.

I need to have a way to allow the user to select one of these, and then do
some processing on it, and I'm struggling to find a way.

I did have a select dropdown with a list of them, but that has become
unmanageable, even when coupled with a restrictor text box. For example, the
user types 'david' in the restrictor, and then the dropdown only lists those
urls with '%david%'

Has anyone got a genius way of allowing the user to select one easily and
without having to download all 26000.

TIA

Alastair Battrick
Senior Developer
Lightwood Consultancy Ltd
http://www.lightwood.net


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




[PHP] Problem with readfile

2003-08-27 Thread French, Alastair
Hi all

I am using the following to pass a file to the client

snip
header(Content-type:  . $row['filetype'] );
$path = ROOT_PATH . file_uploads/;
$real_filename = $path . $row['location'] . '/' .$row['filename'];
header(Content-Disposition: attachment; filename=  . $row['filename']);
readfile($real_filename);
/snip

The content type is obtained from a database along with the actual location
of the file. The files are outside of the webroot.

The problem is that the file is either corrupted or something different is
sent.

E.g. if a pdf is sent the first line of the received file is 

%PDF-1.3 followed by some unprintable (in a 7 bit email) characters, this
causes adobe to report an error.

If a text file is downloaded, then all I get is the source of the webpage I
called the function from.

Where am I going wrong?

I have checked the pathnames and the headers and all seems to be correct.
The browser produces a dialog with the correct information in it, i.e what
file type and the name.

Thanks

Alastair



This email and any attached files are confidential and intended
solely for the use of the individual/s or entity to whom it is
addressed. If you have received this email in error please notify:-
[EMAIL PROTECTED]

RACAL INSTRUMENTS WIRELESS SOLUTIONS.
An AEROFLEX Company. Visit our website at:-
http://www.racalinstruments.com/

This footnote also confirms that this email message has
been swept for the presence of computer viruses.


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



[PHP] Problem retrieving URLs

2003-06-11 Thread French, Alastair
Hi all

I am having a few problems retrieving URLs from within PHP. I am using the
following to get the URL

?

$lines = file($URL);

foreach ($lines as $line_num = $line) {
echo Line #b{$line_num}/b :  . htmlspecialchars($line) .
br\n;
}
?

It works fine even for .htaccess protect areas unless I need to change ports
i.e I need to get some data from a server on port 81 instead of port 80. I
get the following back from the script. The second warning I'm fine with as
there is obviously nothing coming back, but the first has got me stumped.
Any ideas?

(I've masked the URL)

Warning: file(http://www.xx.uk:81/;) - Success in
/home/sites/site70/users/afrench/web/get_test.php on line 3

Warning: Invalid argument supplied for foreach() in
/home/sites/site70/users/afrench/web/get_test.php on line 5

The server is a cobalt with PHP v4.1.2

Thanks

Alastair French


==
IMPORTANT NOTICE

The information contained in this e-mail is confidential. It may also
be legally privileged. It is intended only for the stated
addressee(s) and access to it by any other person is unauthorised. If
you are not an addressee, you must not disclose, copy, circulate or
in any other way use or rely on the information contained in this
e-mail. Such unauthorised use may be unlawful.

If you have received this e-mail in error, please inform
Racal Instruments Ltd. immediately by emailing
[EMAIL PROTECTED] or phoning +44 (0)1628 604455 (ask
for the I.T. Dept.) and delete it and all copies from your system.

www.racalinstruments.com

==


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



RE: [PHP] a generic getsql() function

2003-06-25 Thread French, Alastair
Thomas Hochstetter wrote:
 Hi guys,
 
 I wrote a generic getsql() function for my project's class. However, I
 only manage to retrieve a single row. What it should really do is:
 Read all rows into the array (with multiple results). The code is
 below: 
 
 function getsql($sql,$conn,$dbase,$arr)
 {
 if($conn)
 {
 mysql_select_db($dbase,$conn);
 $result = mysql_query($sql,$conn);
 
 while ($arr = mysql_fetch_assoc($result))
 { return $arr;
 // Something has to happen here!!!
 }
 }

I think your problem is that you are returning after the first row has been
read, what you need to do is add the row ($arr) to another array using
$new_array[] = $arr or similar. and then move the return $arr to after the
while loop, but then return $new_array not $arr.

Hope this makes sense.

Alastair


==
IMPORTANT NOTICE

The information contained in this e-mail is confidential. It may also
be legally privileged. It is intended only for the stated
addressee(s) and access to it by any other person is unauthorised. If
you are not an addressee, you must not disclose, copy, circulate or
in any other way use or rely on the information contained in this
e-mail. Such unauthorised use may be unlawful.

If you have received this e-mail in error, please inform
Racal Instruments Ltd. immediately by emailing
[EMAIL PROTECTED] or phoning +44 (0)1628 604455 (ask
for the I.T. Dept.) and delete it and all copies from your system.

www.racalinstruments.com

==


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