Re: [PHP] Finding out which file is retrieved over HTTP

2003-03-25 Thread Jens Lehmann
David Otton wrote:
On Sun, 23 Mar 2003 21:21:39 +0100, you wrote:


The following short script retrieves a file over HTTP:

$url = 'http://www.example.com/';
implode('',file($url)); // or file_get_contents()
Now I'd like to find out which file was really retrieved, for instance 
http://www.example.com/index.html. Is this possible and how?

[...]
I need to write a small link-checker (Intranet), which reads in all 
links within a file and then looks if they're broken and collects some 
information. Unfortunately I didn't find a simple, free link-checker 
that's why I write my own. It would be good to find out the complete 
url, because I want to collect the file-endings (.php,.html, ...).


I really think this already exists. You should probably search a bit
harder.
Maybe there are good standalone-link-checkers, but I need to integrate 
it in an application and my customer has some special wishes. Anyways I 
finished writing the link-checker.

A thing which seemed a bit confusing to me is that if I open a 
non-existing website (fopen('http://www.amazon.de/nonsensestuff')) I 
always get an error message Success. It's the same thing if I use 
file(). The manual explains that fopen() returns false if the website 
could not be opened, that's why I don't know why this error message 
appears? Besides this Success-message is surely a very bad error 
message. I use PHP 4.2.3.

Jens



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


Re: [PHP] Finding out which file is retrieved over HTTP

2003-03-25 Thread Jens Lehmann
Ernest E Vogelsinger wrote:
At 20:48 25.03.2003, Jens Lehmann spoke out and said:
[snip]
To actually check on the HTTP status codes you need to run your own, either
using cURL, or by doing your own stuff using fsockopen().
I tried using fsockopen(), but still experience a problem, I want to use 
the following script to retrieve both, the headers and the actual file:


You need to transmit the Host: header so the web server has a chance to
know which virtual host you want to reach. Ideally you would also tell the
server what type of content you can handle (see below). Also note that the
correct line ending for MIME headers is always CRLF (\r\n):
$hostname = 'www.example.com';
$file = '/index.php';
$ip = gethostbyname($hostname);
$fp = fsockopen($ip, 80, $errno, $errstr);
if ($fp)
{
fputs( $fp, GET .$file. HTTP/1.0\r\n .
 Host: $hostname\r\n .
 Accept: text/html\r\n .
 Accept: text/plain\r\n\r\n );
$src = '';
while (!feof ($fp))
$src .= fgets($fp, 4096);
fclose ($fp);
}

This will get you the whole page, including all headers.
Thank you! This works fine. I can use this for reading the HTTP-Status.

Jens

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


[PHP] Finding out which file is retrieved over HTTP

2003-03-23 Thread Jens Lehmann
The following short script retrieves a file over HTTP:

$url = 'http://www.example.com/';
implode('',file($url)); // or file_get_contents()
Now I'd like to find out which file was really retrieved, for instance 
http://www.example.com/index.html. Is this possible and how?

Background:

I need to write a small link-checker (Intranet), which reads in all 
links within a file and then looks if they're broken and collects some 
information. Unfortunately I didn't find a simple, free link-checker 
that's why I write my own. It would be good to find out the complete 
url, because I want to collect the file-endings (.php,.html, ...).

Another thing is that my script is recursive, so I need a function 
absolute_link() which takes a (possibly relative) path and an url to 
find out which page to go next.

Example:

$url = http://www.example.com/foo/bar/
Somewhere in the source code:
... a href=../articles/page.html / ...
My script reads in $path='../articles/page.html'. The function 
absolute_link($url, $path) should return 
'http://www.example.com/foo/articles/page.html'. However $url could be 
http://www.example.com/foo/bar (bar can be file or dir here imho) or 
http://www.example.com/foo/bar/index.php and in any case absolute_link() 
should return the same. Of course this function is easier to implement 
if I always have something like 
http://www.example.com/foo/bar/index.php. Maybe there's already a useful 
function besides parse-url() I can use here.

Jens

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


[PHP] Re: [RegExp] extracting anchors

2003-03-13 Thread Jens Lehmann
Jome wrote:
Jens Lehmann wrote:

Hello,

I want to extract the name-attribute of all anchors out of an
HTML-source-code which don't have the href-attribute. I can use this
code to get the name-attribute:
preg_match_all('/a([^]*?)name=[ \'\](.*?)[
\'\](.*?)/is',$src,$ar);
The name-attributes are now in $ar[2]. How can I exclude all links
which have the href-attribute? I didn't find an easy way how to say
that a string must _not_ be part of a pattern match. I hope you can
give me some advise.
This is one lousy solution but hey - it's a solution after all; you
can simply remove all a tags containing href before doing the
preg_match_all()-call, something like this below should do it I think.
$src = preg_replace('/a[^]*?href=[^]*?/is', '', $src);
This is of course a working solution, but I'm still interested if it can 
be done directly with just one regular expression. Thanks anyways.

Jens

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


[PHP] [RegExp] extracting anchors

2003-03-12 Thread Jens Lehmann
Hello,

I want to extract the name-attribute of all anchors out of an 
HTML-source-code which don't have the href-attribute. I can use this 
code to get the name-attribute:

preg_match_all('/a([^]*?)name=[ \'\](.*?)[ \'\](.*?)/is',$src,$ar);

The name-attributes are now in $ar[2]. How can I exclude all links which 
have the href-attribute? I didn't find an easy way how to say that a 
string must _not_ be part of a pattern match. I hope you can give me 
some advise.

Jens

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


Re: [PHP] Cleaning up HTML table structure

2003-03-10 Thread Jens Lehmann
Beau Hartshorne wrote:
Jens,

I would suggest that you try writing a script that keeps track of how
many tags have been opened (look for ), versus how many tags have
been closed ([^]*/) on a line-by-line basis. Using that number, you
should be able to indent the code properly.
I need to count how often the important tags (table, tr, td) have been 
opened, but that's only a part of the solution. It doesn't make sense to 
count every  and  because most of the tags don't play a role (in the 
script I should write).

Let us know what you've got so far.
I solved the problem by first getting all position of the table, tr and 
td-tags. After that I go serially from the first to the last occurence 
of a tag and keep track how often it was opened and closed. Additionally 
I have a variable which counts the numbers of bytes I added to the text. 
After that I reduce the linelength to less than $maxlength chars.

Jens

PS: If you want a tool which really cleans up HTML you should use 
HTMLTidy of course. :)

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


[PHP] google-apis (was: error while reading google-search-results)

2003-03-09 Thread Jens Lehmann
James wrote:
LWP is a perl thing.  Curl is probably the best thing to use.
Have you tried using googles php api which they provide free?
http://www.google.com/apis/
I had a look at the API, but I'm not sure if it's appropriate and easy 
to use with PHP. It's still beta and might change again (or maybe I've 
to pay for every query soon). Has anyone already used the api? Is it 
simple to (for instance) find out all listed pages of www.foo.com which 
are in the Top 1000?

Jens



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


[PHP] Cleaning up HTML table structure

2003-03-09 Thread Jens Lehmann
The following problem seems to be hard to solve:

A PHP-Script reads in an HTML-File and removes linebreaks, tabs and not 
needed spaces. After that the script should reconstruct the 
table-structure this way (example):

table ... 
  tr ... 
td ... 
  table ...
tr ... 
  td ... 
...
  /td
  td ... 
...
  /td
/tr
  /table
/td
  /tr
/table
The next thing is that lines longer than for instance 80 chars 
($maxlength) should be split up into several lines.

Is there any good way to solve this? Regular expressions seem to be of 
limited use because the recursion of tables can be infinitely deep and 
the lines between td and /td must not not be longer than $maxlength 
and should have the appropriate number of spaces before it. Stepping 
through the string (the whole file is a string) with simple 
String-functions is very complicated either.

I hope you can give me some hints how to find a (simple) solution for 
this problem.

Jens

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


Re: [Fwd: Re: [PHP] error while reading google-search-results]

2003-03-08 Thread Jens Lehmann
James Holden wrote:


Welcome to a mine field of problems :-)

1. The url you have entered is invalid.  Thats a good first check to 
make usually.  Try /search?q=test to get that bit sorted.
Ok, this was just a typo. :)

2. Google prevents known useragents from accessing it's content as it 
believes you are acting as a spider or a search engine stealing thier 
content.  To counter this you need to use a new url capturing method and 
specifically set the name of the useragent.  Use 'MSIE'.  You can use 
curl, lwp etc to do this kind of thing.
Curl is excellent, fast, highly configurable and execellent with secure 
connections. 
I heard about curl, but not about lwp. I can't find documentation for 
lwp on php.net. I must check out if I can use one of these.

3. I suggest you don't do this - they prevent it for a reason.
It's part of a larger project and not especially related to google. The 
script should be able to read in any website and do some processing. One 
of its functions should (later) be to determine search engine positions. 
Is there a simple way to do this without reading in the search results 
of google (or other search engines)?

Jens



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


[PHP] error while reading google-search-results

2003-03-07 Thread Jens Lehmann
For reading in and displaying a file $uri I use this short script:

?php
$uri = 'http://www.google.de?q=test';
echo implode('',file($uri));
?
Of course this works well for almost every website, but I have problems 
reading in the results of google (for instance the URI above). The error 
message I get is:

[07-Mar-2003 16:14:13] PHP Warning:  file(http://www.google.de?q=test;) 
- Success in /var/www/test/getfile.php on line 20
[07-Mar-2003 16:14:13] PHP Warning:  Bad arguments to implode() in 
/var/www/test/getfile.php on line 20

Does anyone know why this happens?

I use PHP 4.23 and Apache 1.3.26 on Debian GNU/Linux 3.0.

Jens

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


[PHP] RegExp for Forum-List-Code

2002-11-09 Thread Jens Lehmann
Hi out there,

I encountered a lot of problems while trying to convert a list
in Forum-Code (like UBB-Code).

[list]
[*] item 1
[*] item 2
[*] item 3
[/list]

should be converted to

ul
liitem 1/li
liitem 2/li
liitem 3/li
/ul

I converted the first one to

ul
[*] item 1
[*] item 2
[*] item 3
/ul

Now I need a Regexp for converting every [*] foo to lifoo/li.

I started with

$text = preq_replace('/\[\*\]([^(\[\*\])]*)/i','li$1/li',$text);

The RegExp starts from [*] and saves every char in $1 until [*]
occurs again. That's fine, but what I need is a RegExp which starts
from [*] and saves every char in $1 until [*] OR /ul occurs in
$text. I tested a lot, but didn't find a solution. I'd be glad about
any help.

Jens







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




Re: [PHP] W3C and PHP

2002-11-09 Thread Jens Lehmann
  ... a href=nav.php?page=aboutsection=Linuxfont color=#256 ...
  ^
Error: unknown entity section

 If this is really what the W3C validator tells you you should file a bug
 report, IMHO. Passing GET variables should be valid HTML ;-)

Usually entities start with  and end with ;. The entity section
doesn't end with ; and is not defined, that's why it's not valid.

Jens

PS: Be aware of not writing something like
header(Location: script.php?foo1=aamp;foo2=b);
or use $amp; in mails, which are send thorugh the PHP-
mail-function.



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




Re: [PHP] RegExp for Forum-List-Code

2002-11-09 Thread Jens Lehmann
That's what I thought, too. But it doesn't work.

test.php:

$text = 'ul [*] jusfj [*] ijusnf [*] jsf [*] jusdf /ul';
$text = preg_replace('/\[\*\]([^(\[\*\])(\/ul)]*)/i','li$1/li',$text);
$text = htmlentities($text);

Output:

ul li j/liusfj li ij/liusnf li jsf /lili j/liusdf /ul

I tested some different things, which didn't work. Any more ideas
are appreciated.

Jens

 untested:

 preq_replace('/\[\*\]([^(\[\*\])(\/ul)]*)/i','li$1/li',$text);



 Jens Lehmann wrote:

 Hi out there,
 
 I encountered a lot of problems while trying to convert a list
 in Forum-Code (like UBB-Code).
 
 [list]
 [*] item 1
 [*] item 2
 [*] item 3
 [/list]
 
 should be converted to
 
 ul
 liitem 1/li
 liitem 2/li
 liitem 3/li
 /ul
 
 I converted the first one to
 
 ul
 [*] item 1
 [*] item 2
 [*] item 3
 /ul
 
 Now I need a Regexp for converting every [*] foo to lifoo/li.
 
 I started with
 
 $text = preq_replace('/\[\*\]([^(\[\*\])]*)/i','li$1/li',$text);
 
 The RegExp starts from [*] and saves every char in $1 until [*]
 occurs again. That's fine, but what I need is a RegExp which starts
 from [*] and saves every char in $1 until [*] OR /ul occurs in
 $text. I tested a lot, but didn't find a solution. I'd be glad about
 any help.
 
 Jens
 



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




[PHP] variable declaration in class

2002-06-18 Thread Jens Lehmann

Can anyone explain me why the following code causes
the parse error ... unexpected * ...  ?

class test
{
var $a = 2*10;
}

Of course I know why there's a parse error, but I don't
know the reason why PHP doesn't allow this multiplication,
although it allows a statement like e.g. var $a = 20.
I'd be thankful if anyone could enlighten me. I'm using
PHP 4.2. on Win2k.

Jens



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




Re: [PHP] ini_set('register_globals',0) doesn't work

2002-05-27 Thread Jens Lehmann

Thank you for answer. I didn't expect ini_set('register_globals','Off') to
work, that's why I had a look at the documentation. There should be
PHP_INI_PERDIR, PHP_INI_SYSTEM but not PHP_INI_ALL
in the table (so it's a mistake in the documentation).

Anyway it may be possible to use this, if the variables are unset. This
is overload of course, because the variables are first set (because of
register_globals=On in php.ini) and are unset if I call
ini_set('register_globals','Off'), but this could be a nice feature,
making it easier to work with register_globals=Off while other
old projects still work. Do you consider this a good idea? Does
anything except performance speak against doing this manually?

Jens


 register_globals affects things that happen before PHP parsing begins, so
 by the time you get to your ini_set() it is too late.  So no, that won't
 work.  You need to set it in your php.ini, httpd.conf or .htaccess.

 -Rasmus

 On Sun, 26 May 2002, Jens Lehmann wrote:

  I tested ini_set('register_globals',0) and
ini_set('register_globals','Off')
  for turning register_globals off. It doesn't work and it doesn't produce
any
  notice, warning or error.
 
  Here's a quick example:
 
  ?php
 
  ini_set('register_globals',0);
 
  if(isset($test))
echo h2$test/h2;
 
  ?
  form action=ini_set.php method=get
   input type=text name=test /
   input type=submit /
  /form
 
  This prints out $test, what it shouldn't do with register_globals turned
  off.
  I tested this with PHP 4.1.2 and 4.2.1. Even if I start to doubt it is
  supposed to work according to the documentation. Can anyone tell
  me what I've done wrong?
 
  For some strange reason if I do
 
  echo ini_set('register_globals',0);
 
  it will print 10. For
 
  echo ini_set('register_globals','Off');
 
  it will print 1Off.
 
  Jens
 
  PS: ini_set works fine with include_path and error_reporting
 
 
 
  --
  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] gmtime?

2002-05-27 Thread Jens Lehmann

  -Original Message-
  From: Jens Lehmann [mailto:[EMAIL PROTECTED]]
  Sent: 24 May 2002 20:31
 
  time() returns the number of seconds since the Unix Epoch to
  the current
  local time
 
  gmtime() should return the number of seconds since the Unix
  Epoch to the
  current GM-time
 
  Do you understand now?

 Uh, no, actually now I'm more confused!

I can understand that you're confused. :-) Or am I?

 As I understand it, a Unix timestamp is *always* the number
 of seconds since 1-Jan-1970 GMT (the Unix epoch), and
 so is always a GMT time.

Imho no, because 1-Jan-1970 GMT is just the starting point,
the result depends on which timezone your server is located in.
Please correct me if I'm wrong here!

 Any function that converts between local time and a Unix
 timestamp therefore has to take the current timezone (and
 any daylight-savings rules) into account.  This is why there
 are two versions of mktime() and date(), but only one time().

 Cheers!

 Mike


Jens








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




Re: [PHP] gmtime?

2002-05-27 Thread Jens Lehmann


  -Original Message-
  From: Jens Lehmann [mailto:[EMAIL PROTECTED]]
  Sent: 27 May 2002 12:48
 
-Original Message-
From: Jens Lehmann [mailto:[EMAIL PROTECTED]]
Sent: 24 May 2002 20:31
   
time() returns the number of seconds since the Unix Epoch to
the current
local time
   
gmtime() should return the number of seconds since the Unix
Epoch to the
current GM-time
   
Do you understand now?
 
   Uh, no, actually now I'm more confused!
 
  I can understand that you're confused. :-) Or am I?
 
   As I understand it, a Unix timestamp is *always* the number
   of seconds since 1-Jan-1970 GMT (the Unix epoch), and
   so is always a GMT time.
 
  Imho no, because 1-Jan-1970 GMT is just the starting point,
  the result depends on which timezone your server is located in.
  Please correct me if I'm wrong here!

 Well, I'm not sure, because I think we're talking at cross purposes.  I'm
*still* not sure what you want gmtime() to achieve that's different from
time(), because, as far as I can see, the two scenarios you describe above
actually return the same value.  Or, to put it another way, because a
timestamp is *always in GMT*, it returns the time since 1-Jan-1970 00:00:00,
full stop, period, end of story.  In other words, timestamps operate in a
single timezone, and it's up to anything else that works with a timestamp to
do the timezone (and daylight-savings) corrections.  (This is also why you
get the anomaly of 23- and 25-hour days in areas which have daylight-savings
timeshifts.)

 Let's take some detailed examples, and maybe you can explain what you're
trying to get with your gmtime() (and why!):

 In a purely GMT zone, with local time 27-May-2002 12:00:00, the UNIX
timestamp is 1022500800.

 In a nominally GMT zone, but with daylight-savings in effect (such as
British Summer Time!), with local time 27-May-2002 13:00:00, the UNIX time
stamp for this is also 1022500800.

 Likewise, in a GMT+0200 zone, a local time of 27-May-2002 14:00:00 also
gives a timestamp of 1022500800.

 In fact, this same timestamp of 1022500800 also represents all of these
local times:

 27-May-2002 04:00 -0800
 27-May-2002 07:00 -0500
 27-May-2002 17:00 +0500
 27-May-2002 23:00 +1100

 and even such oddities as:

 27-May-2002 21:30 (Western Australia / Northern Territory)

 Thus, given the timestamp of 1022500800, it's the job of date() to
determine the correct timezone and daylight-savings offset and apply them
before formatting the output; gmdate() just formats it without applying any
offsets.  Likewise, mkdate() and gmmkdate() translate the other way
respectively with and without timezone correction.

 Forgive me if I've gone on at what seems like excessive length, but I just
wanted to make sure we both know exactly what it is we're talking about!

 Cheers!

 Mike


@mattmike:

Thank you for your explanations. I'm a bit sorry for having
asked such a question. The deeper I thought about it the
more confused I was. I see now that there's no sense in a
function like gmtime(). Sorry.

Jens







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




[PHP] ini_set('register_globals',0) doesn't work

2002-05-26 Thread Jens Lehmann

I tested ini_set('register_globals',0) and ini_set('register_globals','Off')
for turning register_globals off. It doesn't work and it doesn't produce any
notice, warning or error.

Here's a quick example:

?php

ini_set('register_globals',0);

if(isset($test))
  echo h2$test/h2;

?
form action=ini_set.php method=get
 input type=text name=test /
 input type=submit /
/form

This prints out $test, what it shouldn't do with register_globals turned
off.
I tested this with PHP 4.1.2 and 4.2.1. Even if I start to doubt it is
supposed to work according to the documentation. Can anyone tell
me what I've done wrong?

For some strange reason if I do

echo ini_set('register_globals',0);

it will print 10. For

echo ini_set('register_globals','Off');

it will print 1Off.

Jens

PS: ini_set works fine with include_path and error_reporting



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




[PHP] Re: displaying an image with header(... does not work

2002-05-25 Thread Jens Lehmann


 Hi there,

 I am pulling out an image out of a mysql blob field. The image is there, I
 can see it in mysqlfront. So I pull it out of the db store it into a
 variable and then do a:

  header(Content-type: image/pjpeg);
  echo $picture;

 I do get a white screen and the browser is loading forever. I can not see
 any error in that. Outputting text works, but not the image.

 Thanx for any help,

 Andy


Don't know if it's a typo, but it must be image/jpeg of course. Check your
loops (if any) and your strings (esp.  and '). Maybe it's better to post
the whole
source in this case.

Jens



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




Re: [PHP] Session question

2002-05-25 Thread Jens Lehmann

  Just be sure you call session_start() on any page you want to access
  session variables.
 

 I have to call this function on each page I use session variable or juste
 once ?

The statement is pretty clear. You've to call it once on each page you want
to access session variables.


  This assumes the latest version of PHP. The procedure is similar on
  older versions, you just have to use session_register().

 From wich version session_start() is include ?

Don't know what you want, but session_start() is part of PHP since version
4.0

Jens




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




[PHP] Re: Switch() ?????

2002-05-25 Thread Jens Lehmann


 I have a script that switches.
 switch($pid)
 {
 case 1:
 break;

 case 2:
 break;
 }

 Now I'm doing a check in case 1 and if everything goes well, i want to
 switch directly to case 2 while the script is runny.

 How would i do that ???


Don't write break; in case 1.

Jens



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




[PHP] Re: Function Switch($pid) - NEED HELP

2002-05-25 Thread Jens Lehmann

 I have a script that switches.
 switch($pid)
 {
 case 1:
 break;

 case 2:
 break;
 }

 Now I'm doing a check in case 1 and if everything goes well, i want to
 switch directly to case 2 while the script is runny.

 How would i do that ???


Please don't post the same question several times.

Jens



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




Re: [PHP] gmtime?

2002-05-25 Thread Jens Lehmann


 I don't know what gmtime() is supposed to do.  But is gmmktime() similar?
 http://www.php.net/manual/en/function.gmmktime.php
 -Kevin

Sorry, my first answer was incorrect. gmmktime() does not do what I want.
Do you have any other suggestion why we need/don't need gmtime()?

Jens



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




[PHP] Re: Can't get Apache and PHP to run together -each seems to work OK WinME

2002-05-25 Thread Jens Lehmann

Maybe Apache and PHP have problems with the 2MHz-CPU. :-)

I can only guess what may be the problem:

1. You didn't write phpinfo.php correctly.
2. phpinfo.php is in the wrong directory.

I suggest this because if the apache-site comes up correctly and
phpinfo.php does not it _might_ be a directory problem. Please try to
put a test.html-file in your webserver-root and call it in your browser.

Jens


  I am not an advanced user but not incapable.  Please bear with me for
 any amateurishness.

 I am trying to get PHP to work with Apache.
 I have a Windows ME PC, 2Mhz and 512 of RAM.

 I want it only to learn PHP and then test out a few things, using
 MySQL too.

 I downloaded Apache version 1.3.24 and installed it plain and
 simple.It starts up.

 I have also installed PHP version 4.2.1.  I have also a version of
 MySQL loaded (4.0.1) and that sits happily running under a
 WinMySQLAdmin logo in the corner of the screen.

 I carefully followed the help files and looked up articles and books
 for instructions for setting up the config file and have made changes
 to Apache so the relevant sections now read like this.
 (There seem only to be a few necessary changes)./


 QUOTE
ScriptAlias /cgi-bin/ C:/Program Files/Apache
 Group/Apache/cgi-bin/

 #
 # C:/Program Files/Apache Group/Apache/cgi-bin should be changed
 to whatever your ScriptAliased
 # CGI directory exists, if you have that configured.
 #
 Directory C:/Program Files/Apache Group/Apache/cgi-bin
 AllowOverride None
 Options None
 Order allow,deny
 Allow from all
 /Directory

 /IfModule

 ScriptAlias /php/ C:/PHP/



 # End of aliases.

 END QUOTE


 and ..


 QUOTE

  #
 # AddType allows you to tweak mime.types without actually editing
 it, or to
 # make certain files to be certain types.
 #
 AddType application/x-tar .tgz
 AddType application/x-httpd-php .php
 AddType application/x-httpd-php .php3
 AddType application/x-httpd-php .php4
 AddType application/x-httpd-php .phtml

 Action application/x-httpd-php /php/php.exe

 END QUOTE

 With this done the Apache config tester says the syntax is OK and when
 I access localhost  (using IE6) up comes the Apache information page
 saying it is running.

 But when I ask for  localhost/phpinfo.php
 (I have a phpinfo function written into a file with that extension)
 I get an error 500 internal configuration is wrong message.



 Maybe it is PHP that is wrong?So I have checked all the changes
 needed for installing PHP --- again after reading the php site and
 looking a FAQs etc.

 I mean putting the php4tl file into Windows/System etc and PHP.ini
 into Windows.  (I used the Windows installer anyway and have again
 carefully followed the changes needed to the INI file.)



 Still the problem.

 A PHP FAQ says that if you get a 500 error (internatl config problem)
 it is worth testing with the command line:

 php.exe -i


 so I did this in DOS. Reams of HTML stuff whizzed by.
 According to the FAQ answer this means PHP  is OK.

 So back to Apache.  But that is as above.

 I tried Netscape version 2 and IE6   -   both give the same answer. So
 it is not the browser because I have tried different ones.

 It is not PHP because on the command line that works OK and shows
 PHPINFO stuff.

 It is not Apache because it says it is running in the browser windows
 when you call localhost.

 So - I am being driven slowly nuts with frustration.

 May I ask for any ideas?

 (I should add that I am a rank amateur trying to do all this so please
 take it slowly).

 Regards from
 Adrian Greeman



 Regards from
 Adrian Greeman

 52 Salterford Road, Tooting, London, SW17 9TF

 Phone  +44 (0)20 8672 9661
 Mobile  +44 (0)780 329 7447

 Fax:  I can receive these
 on the computer
 but only when present
 - please phone first




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




[PHP] gmtime?

2002-05-24 Thread Jens Lehmann

Any reasons why there's no gmtime()-function in PHP? I'd like to hear your
thoughts.

Jens Lehmann



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




Re: [PHP] gmtime?

2002-05-24 Thread Jens Lehmann

 Did you see gmdate()?
 http://www.php.net/manual/en/function.gmdate.php

Yes, of course.

I can do time()-date(Z) to have gmtime
(or maybe) something better, but wouldn't it be better to
have gmtime() implemented anyways? Please tell me if I
missed something. Thank you.

Jens Lehmann

PS: date(U) and gmdate(U) return the same results



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




Re: [PHP] gmtime?

2002-05-24 Thread Jens Lehmann


 I don't know what gmtime() is supposed to do.  But is gmmktime() similar?

time() returns the number of seconds since the Unix Epoch to the current
local time

gmtime() should return the number of seconds since the Unix Epoch to the
current GM-time

Do you understand now?

gmmktime() does exactly what I want if I don't pass arguments but since
this behaviour is not documented it's probably confusing to a lot of people,
isn't it?

Jens Lehmann



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




[PHP] Re: accessing a mysql column by number

2002-03-28 Thread Jens Lehmann


 Is there a way to access a column in Mysql just by using a number?

Please refer to the MySQL-Documentation. A database doesn't have
any predefined structure, so you're responsible for doing this. Can you
explain why you need this feature?

 Like if you had three columns called column1, column2, and
 column3 and I wanted to access column3 just by using the number 3

This could simply be done by using prefixes:

$col = $prefix.$number

Jens



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




Re: [PHP] Re: accessing a mysql column by number

2002-03-28 Thread Jens Lehmann

Hi Rick,

thanks for correcting me. (numeric order)

I thought he just wants to select one col. (SELECT 3rd column FROM table
... )

I didn't read your answer because it was not in the same thread (reading the
news
with MS Outlook Express), because the subject-line changed. Can you suggest
me
a newsreader which can manage this? I assume this is the wrong place to ask,
so
if you don't want to answer, please tell me where to find the answer.
(I didn't find it in any FAQs.) Sorry for asking such a stupid question.

Jens


 Jens,

 A database does have a structure.  The order in which the columns/fields
are
 defined is their numeric order.
 Second, mysql_fetch_row() will accomplish what he needs.
 Third, we answered this yesterday.

 -Original Message-
 From: Jens Lehmann [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, March 28, 2002 8:18 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Re: accessing a mysql column by number



  Is there a way to access a column in Mysql just by using a number?

 Please refer to the MySQL-Documentation. A database doesn't have
 any predefined structure, so you're responsible for doing this. Can you
 explain why you need this feature?

  Like if you had three columns called column1, column2, and
  column3 and I wanted to access column3 just by using the number 3

 This could simply be done by using prefixes:

 $col = $prefix.$number

 Jens



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