Re: [PHP] Is this list less busy than it used to be?

2012-07-04 Thread Erwin Poeze
Well, I think you are right. Take a look at this graph of the number of
messages posted starting in 1998. The stackoverflow.org effect?

messages -
https://docs.google.com/spreadsheet/ccc?key=0Ak1QF0ijPYbedDNvb19SQl80MHcxUWhhbTZOYm5FUlE

Erwin


2012/7/4 RGraph.net support supp...@rgraph.net

 Hi,

 Is this list less busy than it used to be? Or is it just me? When I
 used to be on this list ISTR sometimes being overwhelmed by email.

 Cheers

 --
 Richard, RGraph.net support
 RGraph: JavaScript charts for your website
 http://www.rgraph.net

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




Re: [PHP] Way to test if variable contains valid date

2012-07-03 Thread Erwin Poeze
Or you could use a regular expression:

$probe = '2000-01-01';
$found = preg_match('/(19|20)\d\d[- \.](0[1-9]|1[012])[-
\.](0[1-9]|[12][0-9]|3[01])/', $probe);
var_dump($found==1);

Erwin

2012/7/3 shiplu shiplu@gmail.com

 
 
  I want to thank you, Daniel, for this help.  - I was looking for an
  isarray type function


 There is no such function or facility in php. However you can check date in
 string by DateTime object also

 try {
 $date = new DateTime('2000-01-01');
 } catch (Exception $e) {
 echo $e-getMessage();
 exit(1);
 }

 Check php.net/datetime.construct

 --
 Shiplu.Mokadd.im
 ImgSign.com | A dynamic signature machine
 Innovation distinguishes between follower and leader



Re: [PHP] Destructor not called when extending SimpleXMLElement

2012-07-02 Thread Erwin Poeze
Interesting problem. I would expect it to work too. I assume it is a bug.


2012/7/2 Nick Chalk n...@loadbalancer.org

 Afternoon all.

 I seem to be having a little trouble with extending the
 SimpleXMLElement class. I would like to add a destructor to the
 subclass, but am finding that it is not called.

 Attached is a minimal demonstration of the problem. The XMLConfig
 class extends SimpleXMLElement, and its destructor is not called. The
 XMLConfig2 class, which does not use inheritance, does have its
 destructor called.

 The test platform is CentOS 6.2, with PHP version 5.3.3.

 What am I missing?

 Thanks for your help.
 Nick.

 --
 Nick Chalk.

 Loadbalancer.org Ltd.
 Phone: +44 (0)870 443 8779
 http://www.loadbalancer.org/

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



[PHP] Strange comparison behaviour

2005-05-13 Thread Erwin Kerk
Hi All,
Can anyone explain me why the following code:
if (info == 0) echo is 0\n; else echo not 0\n;
Results in: not 0
Whereas:
if (inf == 0) echo is 0\n; else echo not 0\n;
Results in: is 0

Notice the difference: info in the first sample, inf in the second sample.
The used PHP version is PHP 4.1.2 (CLI version)
Erwin Kerk
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Strange comparison behaviour

2005-05-13 Thread Erwin Kerk
Bogdan Stancescu wrote:
You probably mis-typed something:
[EMAIL PROTECTED] ~]$ php
?
if (info == 0) echo is 0\n; else echo not 0\n;
?
Content-type: text/html
X-Powered-By: PHP/4.3.11
is 0
Tried that, but notice the PHP Version, it is failing in PHP 4.1.2!
Erwin Kerk
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Image and PHP

2005-04-14 Thread Erwin Kerk
Mario de Frutos Dieguez wrote:
Petar Nedyalkov escribió:
On Thursday 14 April 2005 10:06, Mario de Frutos Dieguez wrote:
 

I have a page where i place an image but i want when i show the image
delete it. How can i do this?
  

You want to delete it from the clients machine or what?
 

--
Mario de Frutos Dieguez
División de Ingeniería del Software
y Comunicaciones
CARTIF -Parque Tecnológico Boecillo
  

 

Sorry, i want delete it from the server side. I put the images in a 
directory in the server.


Try a wrapper script, that first outputs the image data, and then 
removes the file.

somethinglike:
img src=script_that_show_image_and_deletes_it.php?image=ladieda.jpg /
Erwin Kerk
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] regular expressions

2005-04-14 Thread Erwin Kerk
pete M wrote:
I've been messing about with this for a while to no avail.. so help 
would be appreciates

I'm new to regular expressions and tried this with preg_replace, now I'm 
using eregi_replace !

here's the text
$txt = 'span style=font-size: 10pt; font-family: Times New 
Roman;Itbr /
blahh blahhh blahhh ofbr /
/span';

what I want to do it take the font-size and font-family attributes out so
style=font-size: 10pt; font-family: Times New Roman;
beomes
style=  
and the php
$pattern = 'font-size:*\;';
$txt = eregi_replace($replace,'',$txt);
$pattern = 'font-family:*\;';
$txt = eregi_replace($replace,'',$txt);
What I'm trying to do is match the font-size: and replace everything up 
to the ; with '' ie nothing

dont work
Feel I'm so close ;-(
tia
Pete

Try this:
$pattern = 'font\-size:.*?\;';

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


Re: [PHP] regular expressions

2005-04-14 Thread Erwin Kerk
pete M wrote:
The pattern
$pattern = 'font\-size:.*?\;';
throwns the error
eregi_replace(): REG_BADRPT
Well, this should work (tested and all )
$pattern=|font\-size:.*?;|si;
$txt = preg_replace( $pattern, , $txt );
Erwin
--

  mail   : [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED]
  msn: [EMAIL PROTECTED]
  jabber : [EMAIL PROTECTED]
  skype  : erwinkerk
  hello  : vlits

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


Re: [PHP] Is it Possible?

2005-02-04 Thread Erwin Kerk
Sagar C Nannapaneni wrote:
I'm calling a php script with img tag
for ex: img src=http://localhost/test.php?img=asfd;
and the test.php is as follows...
test.php

?
...
...
some server side validations
...
readfile(abcd.gif);
?
---
Theres no problem with this..its working fine. But i want to return some text(or Html) the 
browser along with the image. So is there anyway that i can send the text to the browser
in this fashion. Even anyother solution other than the img is also Ok. Showing img
is not a priority for me but sending the text is..

Any help will be greatly appreciated..
Thanks,
/sagar

I guess you're trying to get some data from the server after the page 
load (problably by javascript), so this might be of help:

http://www.scss.com.au/family/andrew/webdesign/xmlhttprequest/

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


[PHP] Name of CRON visualiser script

2005-01-19 Thread Erwin Kerk
Hi All,
I've seen a script somewhere which accepts a crontab file for input, and 
then displays all jobs in a calendar-like screen. However, I forgot the 
name. Searching Google didn't help me either.

Does anyone know the name (and if possible, an url) of this script?
Thanks in advance,
Erwin Kerk
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] question about a cron job

2005-01-17 Thread Erwin Kerk
Al wrote:
I've got a question about the following cronjob.
#At 3:01 our time, run backups
1 0 * * * /usr/local/bin/php 
/www/r/rester/htdocs/auto_backup/back_em_up.php 
/www/r/rester/htdocs/auto_backup/cron.log 21

#At 3:02 clean up sessions folder
2 0 * * * (find /www/r/rester/htdocs/sessions/ -name 'sess_*' -mtime 
+1 -delete)

#this is only for testing a new cronjob, every minute
* * * * * /usr/local/bin/php 
/www/r/rester/htdocs/phpList_cronjob/process_cronjob.php 
/www/r/rester/htdocs/phpList_cronjob/cron.log 21

The new one doesn't seem to want to run until after 3:01 or 3:02.  
Shouldn't the sever just run it every minute?

And, the every minute job doesn't add anything to its log file.
Apache on a virtual host.  The 3:01 and 3:02 jobs have been running fine 
for months.

Thanks
The CRON daemon only refreshes it's job list after a job in the current 
list is completed. Therefore, the CRON daemon won't notice the 
every-minute job until 3.01 pm.

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


Re: [PHP] Website and Mozilla/Firefox

2005-01-10 Thread Erwin Kerk
M. Sokolewicz wrote:
M. Sokolewicz wrote:
Lester Caine wrote:
John Holmes wrote:
  I switched from using the us2.php.net mirror to the us4.php.net 
mirror

and things were fine.


That has been 'knobled' now.
At least now I know I'm not going mad ;)
it's because of an issue with the JS scripts. Just have to wait and 
see if anyone gets to fixing it. Just turning off Javascript when 
visiting the manual works fine.

The reason us4. work(s|ed) is because it's not up-to-date (yet)

turning automatic search completion off via my.php.net works aswell 
(but to get there you also need to turn off JS)

Seems to be solved...
Erwin
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Question in posting form-data

2004-12-16 Thread Erwin Kerk
Yao, Minghua wrote:
Hi, all,
I am testing how to post form-data to a host using the following code 
(test.php):
?php
function PostToHost($host, $path, $name, $value) {  // Test of posting 
form-data
$fp = fsockopen($host,80);  
fputs($fp, POST $path HTTP/1.1\n);
fputs($fp, Host: $host\n);
fputs($fp, Content-Type: multipart/form-data\n);
fputs($fp, content-disposition: form-data; name=$name\n);
fputs($fp, Connection: close\n\n);
fputs($fp, $value\n);
$res = ;
while(!feof($fp)) {
$res .= fgets($fp, 128);
}

fclose($fp);
return $res;
}
Check your function carefully. Where are you using the $name of the value?
Nowhere! Therefore the receiving script cannot identify the value as x.
Try: fputs($fp, $name=$value\n);

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


Re: [PHP] php4 and php5 on the same apache server

2004-09-13 Thread Erwin Kerk
Jacob Friis Larsen wrote:
How can I run both php4 and php5 on the same apache server?
Could I do it like this:
AddType application/x-httpd-php .php
AddType application/x-httpd-php5 .php5
And somehow tell php5 to use application/x-httpd-php5
The approach I use is as follows:
On port 80 I run an Apache instance with PHP4
On port 81 I run an Apache instance with PHP5
Via an Apache rewriterule I rewrite all .php5 calls to the other 
webserver (by proxy), and therefore transparent.

Like this (not sure, dont have the config at hand right now):
RewriteEngine On
RewriteRule (.*)\.php5$  http://%{HTTP_HOST}:81$1.php
Erwin Kerk
Webdeveloper
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] resubmitting $POST data to another script

2004-03-03 Thread Erwin Kerk
Chris Shiflett wrote:

It loses all new data:

input type=hidden name=post
value=?php echo htmlspecialchars(serialize($_POST)); ? /
input type=text name=this_will_be_lost /

Because of this:

$_POST = unserialize(stripslashes($_POST['post']));
I think array_merge will fix this:

$_POST = array_merge($_POST,unserialize(stripslashes($_POST['post'])));



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


Re: [PHP] Apache/IE hangs with PHP

2004-02-26 Thread Erwin Kerk
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Vincent Bouret wrote:

| Hi,
|
| I have this strange problem. I have Apache 1.3.28 on Windows XP Home SP1
| with PHP 4.3.4 as a module:
|
| httpd.conf
| LoadModule php4_module c:/php/sapi/php4apache.dll
| AddType application/x-httpd-php .php
| AddType application/x-httpd-php .phtml
|
| //After a list of modules
| AddModule mod_php4.c
|
| Let's say I have test.php that does nothing more than sleeping for 30
| seconds:
| ?php
| sleep(30);
| ?
| html
| content
| /html
|
| When I open up this script in IE with http://localhost/test.php and within
| the 30 seconds sleep I try to load another file with .php extension
| (regardless of whether there are some php statements or not in the
file) on
| the same localhost server with another IE window, IE or Apache hangs until
| the first script is done and then gives output of the second script.
|
| The thing is that when I connect to Apache manually with Telnet during the
| same 30 seconds and I request a PHP script, I get the answer immediately.
| Thanks for your help,
| Vincent
|
I suspect it has something to do with session handling. Check your ini
settings for a session_autostart or something.
Normal behavior for jultiple windows (or frames) and sessions, is that
they wait for each other to close (not destrow, close) the session.
See http://www.php.net/manual/en/function.session-write-close.php for
more information.
Godd luck with this one.

Erwin Kerk
Web Developer
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.4 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFAPfIW4rV3/oG+84URAizzAJ4+OpLSfMnA0J4tKl0NSdDprfvrtQCgvcc2
F2l+E0q/e0HpOwW5ecBAxUk=
=sPMG
-END PGP SIGNATURE-
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Weird result from query...?

2004-02-26 Thread Erwin Kerk
Ryan A wrote:
which runs the sql in show_accounts.php:
SELECT *,now()-0 from .$tcname. where oorder='.$o.' and nname='.$n.'
and total='$p'
Try this:
which runs the sql in show_accounts.php:
SELECT *,now()-0 from .$tcname. where oorder='.$o.' and 
nname='.$n.' and total=$p

without the single quotes around $p

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


Re: [PHP] Weird result from query...?

2004-02-26 Thread Erwin Kerk
Daniel Clark wrote:
p=4.78

I wonder if a dot is a valid character for a URL adderss?
Yup. Just tried it, it works.

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


Re: [PHP] PHP IDE?

2003-12-14 Thread Erwin Kerk
Jough Jeaux wrote:
Was wondering what everyone's favortie IDE is for
coding in PHP.  I've got a big PHP project in the
works.  I'll be doing alot with it and am looking for
ways to boost my productivity.
--Jough

__
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/
I use HTML-kit all the time. Has a built-in ftp client, lots of plugins 
available, in-program previews (via local webserver), and much more.

http://www.htmlkit.com

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


Re: [PHP] PHP and Intranets

2003-12-03 Thread Erwin Kerk
Colin Eldridge wrote:

 Question:  Is there a simple way for PHP to identify which host a 
form  has come from?

Do the hosts have fixed ip's?

If Yes, you could use $_SERVER[REMOTE_ADDR] do identify them...

Erwin Kerk
Web Developer
E: [EMAIL PROTECTED]
W: www.blixem.nl
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] is it possible to have the following URL?

2003-09-22 Thread Erwin Kerk
This should work:

https://url_locaion.org/prev_page.php?SID=$SIDuid=$uidELEM_ID=$id#tag

Erwin

Susan Ator wrote:

I am passing 3 pieces of information on every URL. For example:

https://url_location.org/page.php?SID=$SIDuid=$uidELEM_ID=$id

I need to be able to return to a previous page using an anchor tag like so:

https://url_locaion.org/prev_page.php#tag?SID=$SIDuid=$uidELEM_ID=$id

So far it doesn't work at all. Is this even possible? Just using the
javascript:history.go(-1) doesn't work in every browser.
susan

 

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


Re: [PHP] using a php variable in javascript

2003-09-22 Thread Erwin Kerk
have you tried:

so = window.open('','? echo $callerWin; ?'); ??

Erwin Kerk
Web Developer




Rich Fox wrote:

I have a page with the following code:

?
$callerWin = $_POST['CallerWin'];
?
html
body
script type=text/javascript
!--
so = window.open('','CompanyEdit');
so.location.reload();
window.close();
// --
/script
/body
/html
I have 'CompanyEdit' hardcoded, but what I want instead is something like:

so = window.open('','$callerWin');

This does not work, of course, but you get the idea: I want to use the value
of the $callerWin php variable in my javascript. Can someone tell me the
syntax for this? My reading of the documentation and trial-and-error have
not met with success.
thanks,

Rich

 

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


Re: [PHP] Apache SetHandler

2003-04-03 Thread Erwin Kerk


Zoff wrote:
Hi Guys!

ich have a question with apache and mod_perl I can write a Handler in perl
which is called before anything else happens. this allows me to write 
all sorts of auth stuff.
is there something similar in PHP.

There is a topic in the php manual which describes something similar.

check: http://www.php.net/manual/en/features.file-upload.put-method.php

Maybe something is similar is possible for POST, and for GET your could 
use a rewrite rule in the httpd.conf file



Erwin Kerk
Web Architect


--
 ____
| __|_ ___ __ _(_)_ _
| _|| '_\ V  V / | ' \ @blixem.nl (work)
|___|_|  \_/\_/|_|_||_|@scoutingnederland.nl (private)


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


Re: [PHP] Re: how to test string to see if it is a date or time?

2003-03-24 Thread Erwin Kerk
Try this (as found on php.net)

$str = 'Not Good';
if (($timestamp = strtotime($str)) === -1) {
echo The string ($str) is bogus;
} else {
echo $str == . date('l dS of F Y h:i:s A',$timestamp);
}
Erwin Kerk
Web Developer @ BliXem.nl


Jason Wong wrote:
On Tuesday 25 March 2003 00:39, DomIntCom wrote:

can anybody help me out with this?  I have figured out checkdate finally,
but still have nothing that will help me with time validation.


explode() on the time delimiter (probably colon)
check that hour is 1-12 (or 0-23)
check that minute is 0-59
check that second is 0-59


--
 ____
| __|_ ___ __ _(_)_ _
| _|| '_\ V  V / | ' \ @blixem.nl (work)
|___|_|  \_/\_/|_|_||_|@scoutingnederland.nl (private)


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


[PHP] Re: can't pass complete URL (part of the query string) from one script to another --??

2002-11-26 Thread Erwin
Nicole Lallande wrote:
 Gretings:

 I want to pass a URL query string to another php script.  I am able to
 pass the complete query string with all the variables I want through
 to the javascript function call but then the string gets cut in the
 php script:

 in the shopping cart:
 a href=javascript: openWin('email.php?ref=?php echo $pageURL;
 ')this page/a

 where 'ref' is set correctly and  $pageURL is returned as
 'http://mydomain.com/shop.php?val1=1val2=2val3=3' (this shows up on
 my status bar and I can 'echo' it on the shopping cart page - so
 Iknow it is getting captured correctly -- also - I removed the
 javascript and saw it get passet in the url as a 'get' correctly.)

 but in the email script  I try to display 'ref' and what I get is:

 'http://mydomain.com/shop.php?val1=1' -- everything past the first ''
 gets cut off (ie, I lose  the 'val2=2val3=3' portion of the query
 string )

Use

a href=javascript:
openWin('email.php?ref=?=urlencode($pageURL);?')this page/a

HTH
Erwin


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




[PHP] Re: using mbstring without having /configure'd it

2002-11-26 Thread Erwin
Oliver Spiesshofer wrote:
 Hi,
 
 Is it possible to use mbstring after setting the necessary values in
 ini_set() or htaccess without having it enabled during /configure?

Nope...the functions of mb are unknown, because you didn't compile them.

Grtz Erwin

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




[PHP] Re: amp; in Query String

2002-11-26 Thread Erwin
Derick Rethans wrote:
 Jonathan Rosenberg wrote:
 I have a page with thumbnail pictures that can be clicked on to see
 a larger picture.  Each picture is hyperlinked as follows

 a HREF=show_pic.php?pic=blahcaption=Some+Text

 I access the 'pic'  'caption' attributes with $_GET['pic'], etc.
 Pretty standard stuff.

 I have PHP set up so that error messages get mailed to a specified
 mail account.  Every so often I get the following error message:

 Undefined index:  caption
 In file /home//show_pic.php, line 64
 page: /show_pic.php?pic=gb3.jpgamp;caption=Some+Text

 The problem is obviously (I think) that the $_GET['caption'] is
 failing.

True, if you receive amp;caption in your URL, then the variable won't be
called $_GET['caption'], but $_GET['amp;caption'], which (I think) is
invalid because of the ;.


 What I can't figure out is why the '' got turned into 'amp;'.  Is a
 browser doing this?

 Yes it is.

No, it isn't. I sure hope there is no browser which turns  in amp; in
URL's. That would be very, very bad indeed!

 Actually, you should specify the URL with the amp;
 yourself, like this:

 a HREF=show_pic.php?pic=blahamp;caption=Some+Text

Of course not...this is a HREF tag, which can use  instead of amp;. amp;
is for displaying purposes only, not for URL's.

Following the tip from Marek, adjust your errormessage mailing thingy...add
all the $_GET variables to it (print_r($_GET)). Some other notices maybe
usefull to...

Erwin


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




[PHP] Re: Starting an application on web server

2002-11-26 Thread Erwin
Nic Fordham wrote:
 Hi there,
 I am hosting a server running castle wolfenstein for a few friends of
 mine  want to make a web page to run on the same server that they
 can log in to to stop  start the game when they want.
 I have tried putting the following code in a web page -
 
 ?
 exec ('f:\wolf\wolfmp.exe +set dedicated 2 +map mp_beach  +set
 sv_maxclients 8 ')
 
 
 This creates a process on my server as of wolfmp.exe but I cannot see
 it on my lan  they can't see it over the web.

Probably it failed? Or is requesting some more information?

 I also don't get any visual output on the server of the wolfmp.exe
 starting up the game console.

Don't you get any visual output if you use passthru instead of exec???

Erwin

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




Re: [PHP] Re: amp; in Query String

2002-11-26 Thread Erwin
 I'll let you know what turns up (of course, the problem will stop
 occurring once I add this info :-).

As it always does ;-))

Grtz Erwin

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




[PHP] Re: inserting preexisting image inside dynamic image

2002-11-25 Thread Erwin
Eric Pierce wrote:
 Hi there...
 
 Just wondering... when creating a dynamic image, is
 there a way/fuction to insert an existing image using
 x,y coordiantes for precision?

Yes, there is...use imagecopy (http://www.php.net/imagecopy)

Grtz Erwin

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




[PHP] Re: Dumb POST Array question

2002-11-25 Thread Erwin
David Russell wrote:
 Hi all,

 I have a multiple select called Consultants[] In one page.

 On the target page, how would I reference it? Would it be:

 $_POST['Consultants'][0]
 $_POST['Consultants'][1]
 Etc

Since $_POST['Consultants'] contains an array, you can indeed use the above
syntax.

Grtz Erwin


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




[PHP] Re: Image from MIME email

2002-11-14 Thread Erwin
Christoph wrote:
 Hello,

 I'm currently programming a webmail interface with php 4.1.2 and
 c-client 2001.
 I'm getting the Mime data from the mail.
 Now I have the image data as text but how I can get it into an img
 field?

At first, you'll have to convert the data back to binary using the encoding
specified in the header (of that MIME part). Then you'll have to save the
image to the disk (or to a database), after which you can use the img tag.
Be sure to give the filename the correct extension (which you can gain using
the content-type, also specified in the header of that MIME-part).

Grtz Erwin


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




[PHP] Re: Help w/ 4.2.3 Problem

2002-11-08 Thread Erwin
Jack Sasportas wrote:
 I have been running 4.1.2 fine, but decided to compile in the latest
 version 4.2.3.
 When I run some existing code that works perfect under 4.1.2, not only
 does the code not run properly, but there are no error messages in the
 error_log ( apache file ).
 also in php.ini I  added log_errors = On, and error_log = php_log,
 but I never see any error messages.

 Running on RedHat 7.2 with apache_1.3.27, mod_ssl-2.8.12-1.3.27,
 openssl-0.9.6g, php-4.2.3.
 ( Again this all ran fine with php-4.1.2 ).

 Any ideas on where to start ?

 Thanks

Check the register_globals setting. As from php version 4.2.2, this setting
defaults to Off, while older versions defaults to On.

Grtz Erwin


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




[PHP] Re: Cookie error after 4.2.3 upgrade

2002-11-08 Thread Erwin
Jack Sasportas wrote:
 I get the following error when using a previously working cookie
 function: expects parameter 3 to be long

 Code is below... I just don't see the difference then the way the doc
 uses: time() - 3600

 -vs- the way I did it below...

 Thanks !

 function
 f_put_cookie($user_name,$user_email,$account_type,$company_name) {

 global $HTTP_COOKIE_VARS;
 global $s_c_url;

 $l_url = ..$s_c_url;
 $l_cookie_expireN = date('r', time() - 4000 );
 $l_cookie_expire = date('r', time() + 400 );
 $l_cookie_expire2 = date('r', time() + 400*30*12 );

time() - 3600 returns an integer. The date function returns a string. The
function setcookie expects an integer (or long) as parameter 3. There's your
problem, change your code to:

$l_cookie_expireN = (int) date('r', time() - 4000 );
$l_cookie_expire = (int) date('r', time() + 400 );
$l_cookie_expire2 = (int) date('r', time() + 400*30*12 );

HTH
Erwin


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




Re: [PHP] Re: Cookie error after 4.2.3 upgrade

2002-11-08 Thread Erwin
 change your code to:

 $l_cookie_expireN = (int) date('r', time() - 4000 );
 $l_cookie_expire = (int) date('r', time() + 400 );
 $l_cookie_expire2 = (int) date('r', time() + 400*30*12 );

 No, that's even worse!!  Try this:

$l_cookie_expireN = time() - 4000;
$l_cookie_expire = time() + 400;
$l_cookie_expire2 = time() + 400*30*12;

You're right of course, let's say that it was very early when I wrote that
answer ;-))

Grtz Erwin


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




Re: [PHP] string to array

2002-11-08 Thread Erwin
Tom Rogers wrote:
 Hi,

 Friday, November 8, 2002, 10:43:10 PM, you wrote:
 Hi all,

 has anyone an elegant (and faster) way of converting 'string' to
 array('s','t','r','i','n','g'), other then
 for($i=0; $istrlen($string); $i++) $array[$i]=$string[$i];



 A string is already an array of chars

 $string = 'string';
 echo $string[0]; // will echo 's'

True, but that's different than the array type. Sometimes you'll just need
an array instead of a string.

Try using

$string = explode( '', 'string' );

Grtz Erwin


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




Re: [PHP] string to array

2002-11-08 Thread Erwin
 $string = explode( '', 'string' );

Timothy Hitchens wrote:
 That won't work.. empty delimiter errors always..

Your right, I didn't know.

 you will have to use
 my preg one from earlier...

But your preg thingy will only split at spaces, so that'll have to change to

?
$string = 'test';
preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY);
?

in this case, right?

Grtz Erwin


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




[PHP] Re: Format Date

2002-11-07 Thread Erwin
Dark Rotter wrote:
 Hi,
 
 
 When i print a date, the format of this date is: 8 nov
 2001 0:00
 (print ($array[date]))
 
 but i need print this: 08/11/2001
 
 how i print this ?

try

print date( 'd/m/Y', strtotime( $array['date'] ) );

HTH
Erwin

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




[PHP] Re: New to PHP, and stuck

2002-11-06 Thread Erwin
Markus JäNtti wrote:
 I'm working myself through Julie C. Meloni's book PHP and now I'm
 stuck at chapter 12.
 My script gives me this error:  You have an error in your SQL syntax
 near '()' at line 1
 even tho I've even tried replacing my own work with the file from the
 book's companion-files.
 I'd be very happy if someone would take the time to look through this
 and tell me what the problem might be. Hard to move forward when I
 don't understand this.


The $_POST array exists of keys and values. The keys are strings (in the
case of $_POST), so you'll have to access them like strings. Use
$_POST['table_name'] instead of $_POST[table_name]. The same goed also for
$_POST[field_name], $_POST[field_type] and $_POST[field_length].

HTH
Erwin

 ?
 //indicate the database you want to use
 $db_name =testDB;

 //connect to database
 $connection = mysql_connect(localhost,john,doe99) or
 die(mysql_error());
 $db = mysql_select_db($db_name,$connection) or die(mysql_error());

 //start creating the SQL statement
 $sql =CREATE TABLE $_POST[table_name] ((;

 //continue the SQL statement for each new field
 for ($i =0;$i  count($_POST[field_name]);$i++){
  $sql .= $_POST[field_name][$i]..$_POST[field_type][$i];
  if ($_POST [field_length][$i] != ) {
   $sql .= (.$_POST [field_length][$i].),;
  } else {
   $sql .= ,;
  }
 }

 //clean up the end of the string
 $sql = substr($sql,0,-1);
 $sql .= );

 //execute the query
 $result = mysql_query($sql,$connection) or die(mysql_error());

 //get a good message for display upon success
 if ($result) {
  $msg =P.$_POST[table_name]. has been created!/P;
 }

 ?

 HTML
 HEAD
 TITLECreate a Database Table:Step 3/TITLE
 /HEAD
 BODY
 h1Adding table to ? echo $db_name; ?.../h1

 ? echo $msg; ?

 /BODY
 /HTML


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




[PHP] Re: HELP COOKIES !

2002-11-05 Thread Erwin
 Hi Grtz Erwin,
 
 let me tell you wat i need to do.
 
 1.) I have a login page - if the user logs in correctly i create
 session(with session_start()) , a cookie is written to client +
 session file to server.
 2.)When the user logs off - i call the logOff.php page . The contents
 are as follows :
 
 ?php
 session_start();
 setcookie(session_name(),-3600);
 session_unset();
 session_destroy();
 ect.
 ?
 
 Now , when the user logs in again , i want a NEW COOKIE to be sent
 with a new id , to the client! This does not happen as the first
 cookie was never deleted.
 So when the user logs in again the same cookie is used ! why ?

That's weird indeed. OK, try this instead:

?
$name = session_name();
session_unset();
session_destroy();
setcookie( $name, '', '', '/' );
?

Regards
Erwin

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




[PHP] Re: Spawning a background process

2002-11-05 Thread Erwin
 Basically, my question is.. how do I do this? I am actually (for
 various .. and probably stupid... reasons) trying to spawn a php
 process to run in the background. This process I know will take a
 couple of hours to run (mailing list stuff). I have been playing
 around with system to try to get it to run in the background but I
 can't seem to work out how to do it.

A process which generates output (or can generate output) will make the
system or exec call in blocking. That means that the PHP script will wait
until your script is finished. This can be simply fooled by adding 
/dev/null to your commandline (if you're running on a *nix based machine of
course).

I have a simple background process, which forks itself and then immediately
returns (only the parent process, the child keeps on running). Even then the
exec function was blocking, until I added  /dev/null to the commandline.
If you're background process doesn't spawn it's own child, I think you'll
have to add an ampersand () also, to make the program run in background.

HTH
Erwin


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




[PHP] Re: creating and ftp text file

2002-11-05 Thread Erwin
 I am pretty up to standard with getting stuff into and out of mysql,
 so I am basically just in need of pointers with generating the text
 file and ftp'ing automatically.
 It would be an even greater plus if it wasn't actually necessary to
 create a physical text file on the hard drive, but to simply ftp the
 memory file via the ftp functions, but I don't think that is
 possible?

In fact, it is...just open the file on the ftp directly

?
$fp = fopen( 'ftp://ftp.domain.com/file.txt', 'w' );
?

You can then write directly to that filepointer:

?
fwrite( $fp, 'some text' );
?

Don't forget to close the file (I think PHP does that anyway, but it's nicer
if you do that)

?
fclose( $fp );
?


 My routine will already have connections to the db, and the query will
 have already been run
 (something like select number from table where group=1)
 and I would then have a while to step through the result set.
 This is where I need help, how to create the file and add the
 numbers and static text to the file, and once completed with the
 loop, to ftp to a server with username and password.

You'll have to loop trough the resultset

?
$query = 'select number from table where group=1';
$result = mysql_query( $query );

$content = '';
while ( $res = mysql_fetch_array( $result ) )   // This piece of code will
add all the Cellphone-numbers to the $content variable
{
$content .= 'Cellphone: ' . $res['number'] . \n;
}
$content .= 'Reference: ' . $reference . \n;
$content .= 'Notify: ' . $notify . \n;

// And add everything else to the $content variable which needs to be
written

$fp = fopen('ftp://ftp.domain.com', 'w' );
fwrite( $fp, $content );
fclose( $fp );
?

HTH
Erwin


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




[PHP] Re: addslashes/stripslashes

2002-11-05 Thread Erwin
Paul Dionne wrote:
 Hey,

 I am trying to develop a search for my database.

 I used addslashes when entering the data, and then use addslashes
 with the search but nothing comes up:

 Select * from tblContacts, tblCountries WHERE
 (tblContacts.CountryCode=tblCountries.CountryID) AND (Organization
 LIKE '%o\'mallies%' )

I think your query goes wrong, because MySQL uses two single quotes instead
of backslash quote. So, try using
Select * from tblContacts, tblCountries WHERE
(tblContacts.CountryCode=tblCountries.CountryID) AND (Organization
LIKE %o\'mallies% ).


 I check in the database and o'mallies is indeed there as o\'mallies.
 And a search for just mallies works fine.

Because the data is save with the \ and with the ', you'll probably have to
change your search to
LIKE %o\\''mallies% ).

Try using mysql_escape_string instead of addslashes to store the o'mallies
as is, without the \.

HTH
Erwin


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




Re: [PHP] Re: creating and ftp text file

2002-11-05 Thread Erwin Bovendeur

- Original Message -
From: Petre Agenbag [EMAIL PROTECTED]
To: Erwin [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Tuesday, November 05, 2002 8:24 PM
Subject: Re: [PHP] Re: creating and ftp text file


 Hi Erwin

 OK, my first problem:

 your code genrates errors,
 it says fwrite and fclose are invalid file descriptors.

Errors or warnings? Probably the fopen function failes...

Add the following code:

?
$fp = fopen( 'ftp://ftp.domain.com/file.txt', 'w' );
if ( !$fp )
  die( Cannot open file\n );
?

You can then see if the fopen failes. If it does, then check the rights for
this user at the FTP Server.

 I gathered thatit is possibly because thos are for normal files, so I
 looked in the manual and found the FTP-functions, but it takes a
 $local_file variable, and that must be the name of the local file on
 disk, so I cannot simply put $content in there...

That's true for the FTP functions indeed, but you CAN use the normal file
function to...take a look at fopen in the manual. You can take a look at
example 1.

 Any ideas on how to directly stream the variable to the ftp site?

The only possibility to do this, is using fopen. If you can't use fopen for
some reason (i.e. don't give anonymous users write access to your FTP
Server), then you have to use the FTP functions:

?
$query = 'select number from table where group=1';
$result = mysql_query( $query );

$content = '';
while ( $res = mysql_fetch_array( $result ) )
{
$content .= 'Cellphone: ' . $res['number'] . \n;
}
$content .= 'Reference: ' . $reference . \n;
$content .= 'Notify: ' . $notify . \n;

$name = tempnam( /tmp,  );
$fp = fopen( $name, w );
fwrite( $fp, $content );
fclose( $fp );

$ftp = ftp_connect( ftp.domain.com );
ftp_login( $ftp, username, password );
ftp_put( $ftp, filename, $name, FTP_ASCII );

unlink( $name );
?

For this to work, you'll have to compile PHP with the --with-ftp
directive!!!

But again, I'm pretty sure the first possibility should work also.

Regards,
Erwin



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




[PHP] Re: Address array?

2002-11-04 Thread Erwin
Steve Jackson wrote:
 I want to display an address from my database based on an orderid.
 Where am I going wrong? I am still unsure how Php interacts with
 mySQL but am I right in assuming it should be an array?

 My code...

 function get_shipping_address($address_array)
 {
 $conn = db_connect();
 $orderid = get_order_id($orderid);
 $query = SELECT * FROM orders WHERE orderid = '$orderid';
 $row = mysql_fetch_array($query);
 foreach ($address_array as $row)
 {
 $ship_name = $row[ship_name];
 $ship_address = $row[ship_address];
 $ship_city = $row[ship_city];
 $ship_zip = $row[ship_zip];
 $ship_country = $row[ship_country];
 }
 }

Nope...that's not correct!

PHP will put every column of ONE row in an array. You will have to loop
trough your recordset to get all rows.

function get_shipping_address($address_array)
{
  $conn = db_connect();
  $orderid = get_order_id($orderid);
  $query = SELECT * FROM orders WHERE orderid = '$orderid';
  while( $row = mysql_fetch_array($query) );
  {
$ship_name = $row[ship_name];
$ship_address = $row[ship_address];
$ship_city = $row[ship_city];
$ship_zip = $row[ship_zip];
$ship_country = $row[ship_country];

// Do something...
  }
}

HTH
Erwin


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




[PHP] Re: Battling with highlighting search criteria

2002-11-04 Thread Erwin
 I have a search string ($search) and a result ($result). I need to
 highlight every occurance of $search in $result.
 
 I know that it means that I need to change (for example)
 
 $result = This is a test, isn't it?
 $search = is
 
 Into
 
 $result = thspan class=highlightis/span span
 class=highlightis/span a test, span
 class=highlightis/span'nt it
 
 Now I can easily see how to change the FIRST occurrence of the word,
 but how can I change every occurance?

How about str_replace?

$result = This is a test, isn't it?;
$search = is;

$replacement = 'span class=highlight' . $search . '/span';
$result = str_replace( $search, $replacement, $result );

HTH
Erwin

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




Re: [PHP] Re: Battling with highlighting search criteria

2002-11-04 Thread Erwin
David Russell wrote:
 Hey there

 I told you my brain was feeling fuzzy :)

 This works great. Only one problem... I would like it to be case
 insensitive... Any way?

 I assume that it would be a ereg/preg replace, but I have no clue with
 regexp at all.

Try the following one:

$result = This is a test, isn't it?;
$search = is;

$result = preg_replace( '/(' . $search . ')/i', span
class=\highlight\\$1/span, $result );


Grtz Erwin


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




Re: [PHP] Re: Battling with highlighting search criteria

2002-11-04 Thread Erwin
 Try the following one:

 $result = This is a test, isn't it?;
 $search = is;

 $result = preg_replace( '/(' . $search . ')/i', span
 class=\highlight\\$1/span, $result );


 Grtz Erwin

David Russell wrote:
 Hi Erwin,

 Yep, this does exactly what str_replace does.

No, it doens't...this one is case insensitive. The pattern (which is
/(is)/i in this example), has the i modifier (the last i), which means
case insensitive. In fact, the above regexp even preserves case for you!


 How can I make the whole thing case insensitive:

It already is, please try it again (I've doublechecked it by now) ;-))

Grtz Erwin


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




Re: [PHP] Re: Battling with highlighting search criteria

2002-11-04 Thread Erwin
 How can I get the return in the same case as it was originally?

 Ie if I have $string = Forward , and $search = for, I want
 spanForward/span, not span...forward/span.

Read my reply to your previous reply ;-))

But...some more explanation:

$result = preg_replace( '/(' . $search . ')/i', span
class=\highlight\\$1/span, $result );

The first argument is the pattern, which is '/(for)/i' in the case of
searching for for.
That will match every occurence of for, For, fOr, and so on. The case
insensitivy is reached by the i modifier at the end of the pattern. The
second argument is the replace string. The $1 is an backward reference to
the first item between brackets.
That'll mean that the from the word Forward, the $1 parameter will contain
For. So, the For -part from Forward will be replaced with
span class=highlightFor/span
and that's exactly what you want (right?)...

Hope this clears your brain up ;-)))

Grtz Erwin


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




[PHP] Re: finding a value in an array

2002-11-04 Thread Erwin
Craig wrote:
 I have a database table that holds the values of IDs in the format
 1,2,3,4,5,67,x,x,x,x,x,x

 I am using a dynamic select list menu that displays a list of items
 from a 2nd table with the values set to their unique ids
 eg
 option vaue =1item 1/option
 option vaue =2item2/option
 option vaue =3item 3/option
 option vaue =4item 4/option
 option vaue =5item 5/option

 i am trying to use an array search that will highlight the item if the
 option value is in the array of the IDs, but with no luck, either all
 the ids are highlighted or none at all

$ids = '1,2,3,4,5,6,7';  // This value represents the database value

$array_ids = explode( ',', $ids ); // This will give you an array with all
the id's
$amount = 10; // Amount of options

for ( $i = 0; $i  $amount; $i++ )
{
print 'option value=' . $i;
if ( in_array( $i, $array_ids ) ) // If the value is in the id's array,
then print selected
   print ' selected';
print '' . $i . '/option';
}

Something like that?

Grtz Erwin


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




[PHP] Re: HELP COOKIES !

2002-11-04 Thread Erwin
Shaun wrote:
 Hi,

 I tried some advice you gave , i tried to destroy the session cookie
 wiht setcookie(session_name()); and setcookie(session_name(),-3600);
 but the cookie is still there . Instead , there are now 2 cookies
 with the same name , the one has the session id , the other has no
 contents! HOW CAN I DELETE THESE THINGS !!!

Heh...LOL
My mistake...at first you destroy the session, then you are using
session_name(). The session_name() function will then (of course) return an
empty string. Try setting the cookie (with -3600) before session_destroy().

First question: why are you using a cookie??? If you use session_start(), a
cookie is automaticaly send to the client.

Grtz Erwin


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




[PHP] Re: Session cookies

2002-11-03 Thread Erwin
 When the user logs in , i create a session with session varialbles,
 the session cookie is saved on clients computer.

 When i log off i say

 session_unset();
 session_destroy();
 setcookie(session_name());

 The session in the tmp is deleted , but the cookie is still there , i
 know this because when i login , the same session id is used ! Why is
 that ?

Because you use the same session to connect from client to server. You don't
close your browser, don't wait 20 minutes (or something like that), so the
webserver knows you are the same. The session between the client and server
is not yet gone.

It's also possible that you need to set your cookie in the past. You're just
setting a cookie with setcookie(session_name()). If you want it destroyed,
set it some time ago, like setcookie(session_name(),-3600).


 The session id changes when you close the browser , as the default is
 0.

Not because default is 0, but because there isn't any session yet.

HTH
Erwin


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




[PHP] Re: fgets()

2002-11-03 Thread Erwin
Khalid El-Kary wrote:
 hi,
 i want to open a remote file using fopen() i tried both of these ways
 
 $filename=http://www.domain.com/filename.txt;;
 $file=fopen($filename,r);
 $filecontents=fread($file,filesize($filename));
 
 this one didn't work because it's apparent that the file isn't in the
 local file system so filesize($filename) won't work ...
 
 the second way was this:
 
 $filename=http://www.domain.com/filename.txt;;
 $file=fopen($filename,r);
 $filecontents=;
 while (!feof($file))
 {
   $filecontents.=fgets($file);
 }
 
 this one worked well with PHP4.2.3 but with versions under PHP 4.2.0
 it didn't work
 
 So what else can i try to just get the whole contents of the file
 into a string?

$filename = http://www.domain.com/filename.txt;
$fp = fopen($filename,r);
while (!feof($file))
   $content .= fread($fp,4096);


HTH
Erwin

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




[PHP] Re: why does eregi match for whitespace when there is none?

2002-11-01 Thread Erwin
Peter J. Schoenster wrote:
 Here is the example:

 ?php

 $string = 'asfddsaz';

 if (eregi('\s', $string)) {
 echo Whitespace present;
 }else {
 echo NO Whitespace present;
 }
 ?

 Why does the above return true? There is no whitespace in the string.
 What am I missing?

Try using [[:space:]] when using eregi. See also
http://www.developers-resources.com/stories.php?story=01/10/25/0549771

Grtz Erwin


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




[PHP] Re: How do you select?

2002-10-31 Thread Erwin
Steve Jackson wrote:
 I want to the select the very last record from my MySQL DB. How do I
 do it?

If the table has an id, use
select * from table order by id desc limit 0,1

Grtz Erwin

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




Re: [PHP] Making string upper/lowercase with regex?

2002-10-29 Thread Erwin
Leif K-Brooks wrote:
 I need a way to make a string be replaced with its uppercase version
 using ereg_replace.  Any ideas?


 Chris Shiflett wrote:

 Why must you use ereg_replace?

 Does your question mean that you, for whatever reason, cannot use
 strtoupper() instead?


 Leif K-Brooks wrote:
 I don't want the entire string upercase, just part of it as defined
 by a regex.

Then use preg_replace. The PHP website has an example to uppercase a part of
a string using preg_replace(http://www.php.net/preg_replace).

Erwin


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




[PHP] Re: Another question

2002-10-29 Thread Erwin
Trasca Ion-Catalin wrote:
 If I have a page with frames, how can I get the title of the frameset
 to be the title of the main frame? I want this title to change every
 time the visitor change the page.
 Any help?

That doesn't have anything to do with PHP, but...

you can use JavaScript, something like

top.document.title = 'Title'

or

document.title = 'Title'

I'm not exactly sure which one (if any) of these works, but it's something
like this...

Grtz Erwin


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




[PHP] Re: exploding values into new variables

2002-10-28 Thread Erwin
Petre Agenbag wrote:
 Hi
 The manual states:
 
 $pizza = piece1 piece2 piece3 piece4 piece5 piece6;
 $pieces = explode( , $pizza);
 
 So, if I want to be able to echo piece1 to the screen at a later
 stage, I would go:
 
 echo $pieces[0];
 
 or
 $first_piece = $pieces[0];
 echo $first_piece;
 
 Right?

Right!

Grtz Erwin

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




[PHP] Re: preg_replace and eval

2002-10-28 Thread Erwin
 The following line sort of works:
 $retVal =
 preg_replace(/(.*){parent.(.*)}(.*)/e,'\\1'.\$this-parentNode-
 getProper tyValue('\\2').'\\3',$retVal);

 However, if there are more than one string to replace it only works
 on the last one.  So:
 caption = the parent's coordinates are ({parent.left},
 {parent.top}) would only return something like:  the parent's
 coordinates are ({parent.left}, 100)

That is because the first (.*) skips the first parent.x pattern. It seems
the string is parsed backwards.
To avoid this problem, be more specific in your regexp. Don't use (.*), but
([^{]*) instead. The regexp which works in your example is the following:

/([^{]*){parent.([^{]*)}([^{]*)/e

HTH
Erwin


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




[PHP] Re: Ereg help

2002-10-25 Thread Erwin

 William Glenn [EMAIL PROTECTED] wrote in message
news:003101c27c3b$ff8c61a0$6401a8c0;cortez.co.charter.net...
 Hey all,
 I've been fighting this all night, I need a bit of help. I have a string
like.

 #21-935 Item Description: $35.95

 Where the part # could be 10-2034 a combination of 2 and 3 or 4 digits,
and the price could be a combination of 1,2,3 . 2 digits. I want to chop
that string into Part # / Description / Price.

 I'd appreciate any help, I know this is probably real simple :) Thanks in
advance.

Try:

?
$item = '#21-935 Item Description: $35.95';
$all = explode( ' ', $item );
$part_nr = substr( array_shift( $all ), 1 );
$rest = explode( '$', implode( ' ', $all ) );
$description = substr( trim( $rest[0] ), 0, -1 );
$price = $rest[1];
?

I bet there is a much nicer (and maybe faster way), but this is by far the
easiest (it doesn't cost one night) ;-))
One hundred thousand of these iterations took about 2 seconds...

Grtz Erwin


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




[PHP] Re: String manipulation

2002-10-24 Thread Erwin

Francisco Vaucher [EMAIL PROTECTED] wrote in message
news:3B966ABC166BAF47ACBF4639003B11AC848AE7;exchange.adtarg.com...

 Hi to all (again ;-)

 I need one or more PHP functions to handle a form input.

 i.e. you write: [EMAIL PROTECTED]

 I have to check that after the '@' comes 'test.com'. I think this is easy,

Something like this?

$address = explode( '@', $_POST['email'] );
if ( $address[1] == 'test.com' )
echo 'Valid';
else
echo 'Not valid';

or:

if ( preg_match( '/.*@test\.com$/', $_POST['email'] ) )
echo 'Valid';
else
echo 'Not valid';

$_POST['email'] contains the email address, submitted by the form.

HTH
Erwin


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




[PHP] Re: Seek for a value in a html file ...

2002-10-09 Thread Erwin

Bård tommy nilsen wrote:
 I want to read the contents from a html file to a pointer, and seek
 for
 A value, and return it 

 The text under is an example, and I want to get the 2505 value to be
 returned.
 Eks. $id = '2505'

 (a onmouseover=window.status='show text';return true;
 href=javascript:get(2505);

Try something like this:

$content = file( 'filename' );
$pattern = /a onmouseover=\window.status='show text';return true;\
href=\javascript:get(.*);/;

$result = preg_grep( $pattern, $content );

The $result variable is an array, where the elements are all the matching
lines from the $content array, which is your inputfile. You can then filter
out the value you want using strpos, strrpos and substr.

HTH
Erwin


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




[PHP] Re: =Next to last record in a file=

2002-10-08 Thread Erwin

Anthony Ritter wrote:
 I am trying to access a website that has tab delimited data and use
 PHP to open the file, read from the
 file for output.

 I'd like to then place this data into an array, loop through the
 array and output only the next to last record.

 Is there any way to loop through the following records - there are 96
 - and keep only the *next to last last one* (which would be the most
 current record) before hitting EOF.

 They store the records every 15 minutes for a 24 hour span.

 I do not need all 96 records - only the most current -  or - next to
 last - record.

Read the file with the file function (http://www.php.net/file). This will
give you an array, with each element representing a line in the original
file.
Pop the last element away (http://www.php.net/array_pop) twice. The second
time you do this, store the element you will gain (pop will return the
element it popped). There you have it...

In code:

?
$content = file(
'http://waterdata.usgs.gov/ny/nwis/uv?format=rdbperiod=1site_no=01420500' 
);
array_pop( $content );
$current = array_pop( $content );
?

HTH
Erwin


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




Re: [PHP] join() , can do that fast?

2002-10-07 Thread Erwin

Lallous wrote:
 John, what you said would simply produce:
var x = ['str1,str2,str3']
 and not as I want:
   var x = ['str1','str2','str3']

Elias,

did you actually tried that? Because it does produce what you want...

?
$x = Array( 'str1', 'str2', 'str3' );
echo sprintf(x=['%s'], join(',', $x));
?

produces:

x=['str1','str2','str3']


Grtz Erwin

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




[PHP] Re: Thumbnail with GD

2002-10-04 Thread Erwin

Net Php wrote:
 Hi, I am pretty lost..
 I am trying to create a php thumbnail with php without using any *sql
 database.this script was supposed to open a directory then read it
 resize the images without losing quality and displays it on screen.

 ok, here is what I am trying to do and its now working:

If it's working, then what's the question???


?
 $dir = imagestrips;
 if($abre = opendir($dir)) {


  while($arq = readdir($abre))
{ $filename = imagestrips/ . $arq;
if(is_file($filename))
 {
$neww = 100;
$newh = 100;
header(Content-type: image/jpeg);
$dst_img=imagecreate($neww, $newh);
$src_img=imagecreatefromjpeg($filename);


imagecopyresized($dst_img,$src_img,0,0,0,0,$neww,$newh,imagesx($src_img),ima
gesy($src_img));imagejpeg($dst_img);


 }
  }
}

closedir($abre);
?

It look to me, this can't work. You are sending one header, then a jpeg,
then a header, then a jpeg. Don't you get a broken image? The browser
expects a header, then one image.

You're resize script will have to look like this:

resize.php
?
if ( !file_exists( $_GET['filename'] )
{
header( 'HTTP/1.0 404 Not Found' );
exit;
}
$new = imagecreate( 100, 100 );
$im = imagecreatefromjpeg( $_GET['filename'] );
if ( !$im )
{
header( 'HTTP/1.0 404 Not Found' );
exit;
}
imagecopyresampled( $new, $im, 0, 0, 0, 0, 100, 100, imagesx( $im ),
imagey( $im ) );
imagejpeg( $new );
?

You can invoke this with http://domain/resize.php?filename=img.jpg. You
can create a nice directory listing this way, just call the resize.php
script for every image on the page. Create the directory listing with the
opendir function you used above, but let it print a img src='resize script
url' width='100' height='100' instead of an image!

HTH
Erwin


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




[PHP] Re: help me please.

2002-10-04 Thread Erwin

 got a problem here people.
 What I want to do is upload a file and store its name in a database.
 For some reason I cant.

What version of php are you using? Did you check the register_globals in
php.ini???
O...in the process script, you have $usefile, but in the submit script, it's
$useRfile

If register_globals is On, then skip the Change to: parts

 Process the form:
 ?
 require(../Cart.php);
 Root();
 DBinfo();

 mysql_connect($DBHost,$DBUser,$DBPass);
 $UploadURL = ../images/;
 if ($usefile==none)

Change to:
if ( $_FILES['userfile']['name'] == none )
or
if ( is_uploaded_file( $_FILES['userfile']['tmp_name'] ) )

 {
 echo Error: no file uploaded;
 exit;
 }
 //Connect to DB
 $mysql = mysql_connect($DBHost,$DBUser,$DBPass);
 if(!$mysql)
 {
 echo Cannot connect to database.;
 exit;
 }

 mysql_query(INSERT INTO Items (ImageName) WHERE ItemID = '$II'
 VALUE('test'));

This query is wrong. An insert query can't have a WHERE clause...check the
MySQL documentation about that.


 $upfile = $UploadURL.$userfile_name;

Change to:
$upfile = $UploadUrl . $_FILES['userfile']['name']

 if ( !copy($userfile, $upfile))

Change to:
if ( !copy( $_FILES['userfile']['tmp_name'], $upfile ) )
OR
if ( !move_uploaded_file( $_FILES['userfile']['tmp_name'], $upfile ) )

 {
 echo Error: Could not move file into directory;
 exit;
 }
 ?

HTH
Erwin


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




Re: [PHP] Unix passwd file

2002-10-04 Thread Erwin

 Username is no problem, the Unix encrypted
 password is the one I am trying to work out.  If the user has a
 password of:  phprocks and in /etc/passwd
 that encrypted password works out to be:  !#@KJCKMSD, then I
 validate the user, they enter the correct username and password,
 will PHP be able to validate that the password they entered matches
 the encrypted password.

Just as Peter said, you can use crypt to check the passwords, it'll be
something like:

if ( '!#@KJCKMSD' == crypt( 'phprocks', substr( 'phprocks', 0, 2 ) ) )
{
// Validation succeeded
}
else
{
// Invalid password
}

Crypt can not be unencrypted, but you can of course compare the crypted
passwords...

HTH
Erwin


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




[PHP] Re: Stuck at PHP4 installation( with Apache2 )

2002-10-04 Thread Erwin

Kramer wrote:
 hi,

 I've Apache 2 running fine in my Windows 2000 machine. I installed PHP
 4.2.3( from the zip-file method ).
 I copied php4apache.dll and php4apache2.dll to /WINNT/system32 and
 /WINNT as well( to be safe ).

 In my httpd.conf, either of the following startments are causing the
 Apache to not start...
 LoadModule php4_module F:/Progra~1/php-4.2.3-
 Win32/sapi/php4apache2.dll LoadModule php4_module
 D:/WINNT/system32/php4apache2.dll

Don't copy php4apache2.dll to the \winnt\system32 or \winnt directory,
because it's not required, but copy php4ts.dll to the system32 directory
instead. If you're using any extensions that require external libraries
(take a look in your php installation directory, subdirectory dlls), then
they should be copied to.

HTH
Erwin


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




[PHP] Re: Undefined index:

2002-10-02 Thread Erwin

Voisine wrote:
 Hi,

 I'm learning php from a book but because of global off I have have
 several Undefined index message! I don't want to change the default
 setting in my php.ini because I want to learn the good way.
 What I'm doing wrong?

 Undefined index: categorie
 if ($_POST['categorie'] == New) {

You're not doing anything wrong. The problem here is that error_reporting
has notices on. The $_POST['categorie'] is not defined.
Change the error_reporting to excluse ERR_NOTICE, or use:

if ( isset( $_POST['categorie'] )  $_POST['categorie'] == 'New' ) }
// Your code here
}

HTH
Erwin




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




[PHP] Re: quotes in text strings

2002-10-02 Thread Erwin

Javier Montserat wrote:
 Hi

 Single quote's in strings entered via a text input field are
 subsequently appearing with what appears to be an escape character -

 comm\'ents

 how can i correct this?  I've tried
 htmlspecialchars($string, ENT_QUOTES);
 and
 htmlentities($string, ENT_QUOTES);

 but these don't seem to work (maybe its me).

Probably you have magic_quotes_gpc set to On in php.ini...you can change
this to Off, or you can use stripslashes() on the $string variable...

HTH Erwin


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




[PHP] Re: PHP Include Help

2002-10-01 Thread Erwin

 On line 6, I have the list of musicians in the song.
 Example (ignore the quotes): Doyle Lawson -- lead vocal; Dale Perry -
 - bass vocal
 Is there a way to make it so that, when I include line 6 in my PHP
 template, the ; will be replaced with a line break so I get one
 musician per line in the HTML output?

You could use str_replace on the line you've just read...
http://www.php.net/str_replace

 Lines 7 and so on are the lyrics. The text file has one line per line
 (makes sense, right?) and a blank line between sections of the song.
 I have the script set up to read all the lines from 7 on, but it
 jumbles them all together, ignoring the line breaks. Is there a way
 to script PHP to add the line breaks, or should the line break HTML
 just be inserted everywhere needed in all my separate files?

Use nl2br: http://www.php.net/nl2br
This function replaces all \n (newlines) with BR\n (HTML break with
newline)

HTH
Erwin


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




Re: [PHP] Apache 1.3.26 + PHP 4.2.3

2002-10-01 Thread Erwin

James Mackie wrote:
 Since I installed apache from source and not an RPM I do not have an
 rc file that the service command would use. I start apache in the
 rc.local file. -USR1 should be the 'NICE' way to reload the
 configuration files as per the apache documentation and has worked
 for many versions. Its just with PHP 4.2.3 that it stops working.

Is apachectl graceful an option?
apachectl resided in the apache installation dir.

Grtz Erwin

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




[PHP] Re: 4.0.2 = 4.2.3, form vars are empty?

2002-09-27 Thread Erwin

Qmail List wrote:
 Hello List,
 
 I'm putting a php app that has been off-line for about 18 months back
 on-line. During my absence from php I had heard about some security
 issues, so figured I'd try the latest 4.2.3 release.
 
 Sessions and the DB are fine, but GET/POST vars are continually
 empty. I mean a form submission from .html to .php (about the
 simplest thing possible) the variables are not getting populated with
 their form values. 

Turn register_globals = On in the php.ini file...

HTH
Erwin

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




[PHP] Re: shouldn't $_SERVER['PHP_SELF'] include the get info?

2002-09-26 Thread Erwin

Noodle Snacks wrote:
 I was using a redirect using $_SERVER['PHP_SELF'] from the previous
 page (a login for a site) and it didn't include this from the url:
?aid=12.

 shouldn't it? It caused a SQL error. (which I have included a catch
 for so the error will be friendly)

 instead of the variable to be: /co2_busters_mk2/full_article.php I
 want it to be: /co2_busters_mk2/full_article.php?aid=12.  (like it
 would appear in the address bar).

 is it sposed to be like that or is it a bug? Also what is the best
 way to include all get data in the url?

It is supposed to be like that...the PHP_SELF points to this file, and the
filename has no arguments, thus the PHP_SELF variable don't have them
either.

You will have to use the $_GET array for the aid=12 part.

Grtz Erwin


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




[PHP] Re: Including variables

2002-09-26 Thread Erwin

 I'm having quite a dumb problem with PHP... It's probably more a
 result
 of brain freeze than anything else, but if anyone could help it'd be
 very much appreciated.

 Basically, I need to include() the contents of a variable. Saving the
 contents to a temporary file and then using include() would be
 inconvenient.

Try using eval (http://www.php.net/eval),

You could also write the contents to a file generated in a tempfile.
Generate the filename with tempnam (http://www.php.net/tempnam), open it,
fill it with the contents of the variable, close it, include it and delete
it (with unlink, http://www.php.net/unlink).

HTH
Erwin


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




[PHP] Re: Tar Files and send back to browser

2002-09-26 Thread Erwin

Sascha Braun wrote:
 Hi,

 I want to make some people download files the server tar's on demand.

 But i don't know really how to send the files back to the browser.

 I used the following command for taring the file:

 ?
 $command = 'tar -c '.$arrResult['name'].'.tgz
 ../images/'.$arrResult['image'];
 system($command);
 ?

 This command starts taring, I think, but fills the browser window
 with the pure code of the tar file I belive. How can I make it behave
 different. When I search for the tar on the webserver I can't find it
 anywhere.

You have to send the appropriate headers to the browser, or PHP will send
the default (text/plain) header. For a tar file the correct header is
application/x-tar, send it with

Header( 'Content-Type: application/x-tar' );

HTH
Erwin


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




[PHP] Re: shouldn't $_SERVER['PHP_SELF'] include the get info?

2002-09-26 Thread Erwin

Noodle Snacks wrote:
 Erwin [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Noodle Snacks wrote:

 [snipped]


 It is supposed to be like that...the PHP_SELF points to this file,
 and the filename has no arguments, thus the PHP_SELF variable don't
 have them either.

 You will have to use the $_GET array for the aid=12 part.

 yeh, I figured that. But is there some easy way to print *all* of the
 get data parsed? (In this case, the variable names, number of vars
 etc varies alot. And this has rissen from a bug in a 250kb+ source
 plus project.

 I am wondering if there is a smart way. or do I have to examine the
 $_GET array for all vars and pass them on manually?

Ah, I didn't understand your question (my mistake). Answer to your question
(I hope): there is a smart way: $_SERVER['QUERY_STRING']

HTH Erwin


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




Re: [PHP] Re: Tar Files and send back to browser

2002-09-26 Thread Erwin

 Now I tried to use your script:

 $_REQUEST['image'] is =
 '../images/2002/09/jpg/ls006022_pettersson_johan.jpg';

 ?
 Header('Content-Type: application/x-gzip');
 $command = 'tar -cf - ../images/' . $_REQUEST['image'] . ' | gzip -
 cf'; system( $command );
 ?

 It opens the download dialog again and lets me download the archive,
 but it's named
 download.gz (How can I change it to ls006022_pettersson_johan.gz?)

Add another header (another one???) ;-))
Header( 'Content-Disposition: attachment;
filename=ls006022_pettersson_johan.gz' );

 And if I open it with winrar it says, the content is named 'download'
 Size is about
 160 bytes, seems to be correct. when I try to extract the files
 there pops up
 an error message which says: Unexpected end of archive.

 Have you got a sollution on that?

Yes...my mistake, use passthru( $command ) instead of system( $command )

Grtz Erwin



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




Re: [PHP] Finding out when a Web page has changed

2002-09-26 Thread Erwin

Marek Kilimajer wrote:
 Hope the sites have no banners :),  they change all the time

But the URL to the banners will be the same, so that's no change in the HTML
code ;-))

 [SNIP]


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




Re: [PHP] Re: Tar Files and send back to browser

2002-09-26 Thread Erwin

Sascha Braun wrote:
 Seems to work not that bad, but I got another Question.

 Why isn't there anything in the archive?

It works in here (just tested it), I don't know why it's empty (don't stop
reading here!!! :-) )


 This is my code yet:

 ?
 Header('Content-Type: application/x-tar');
 Header(Content-disposition: attachment;
 filename=.$_REQUEST['name']..tar);
 $command = 'tar -cf - ../images/' . $_REQUEST['image'];
 passthru($command);
 ?

Nothing wrong with this...

By the way, make sure there is no newline in the second Header:

Header(Content-Disposition: attachment;
filename=.$_REQUEST['name']..tar);

I don't know if the mailingprogram breaks this line, but it's one line (just
in case).

 I did put away the gzip routine couse I find it a little nerving if i
 always have to open
 two files ;)

;-))

 The source pictures size is 406 KB, the download is about 340 KB in
 size, isn't it wrong a bit?

That's wrong...tar doesn't compress...a tar archive does have a small
footprint (about 1k-2k with one file), so the tar file should ALWAYS be
bigger than the source file(s)...

H...thinking about this...I'm sure you would like compression instead of
archiving. Use gzip only instead of tar:

- Set the header back to application/x-gzip
- Change the command to gzip -c filename

I'm very curious if you get any (correct) output then...

 Greetings

 Sascha

Greets back :)
Erwin

 PS.: Isn't it wrong, when I write greetings in english? Sounds so
 german, what could i write else? Thank you very much.

Try Greets or Thanks in advance ;-))
Greetings sounds (to me) more like what you say at the start of a
conversation.


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




Re: [PHP] Re: Tar Files and send back to browser

2002-09-26 Thread Erwin

Sascha Braun wrote:
 Ok, somebody told me, the archive contains the Image, only winrar
 seems not to show the image, grrr.

;-))
That's why...i did see the image too!

 I tried the gzip method and it did not work that fine for me.

Hmz...too bad, because you will get smaller downloads then (use Winzip ;-) )

Grtz Erwin


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




Re: [PHP] Re: Tar Files and send back to browser

2002-09-26 Thread Erwin

Sascha Braun wrote:
 Do you know how to exclude the path informations in the tar archive?

Yes, first chdir to the ../images directory
http://www.php.net/getcwd
http://www.php.net/chdir

Grtz Erwin

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




[PHP] Re: PHP Installation under WinXP Apache 2.0.39

2002-09-25 Thread Erwin

Sascha Braun wrote:
 I have a small problem I'm not able to solve.

 I wanted to install PHP 2.2.3 under WinXP together with an
 Apache 2.0.39, but after installation and reconfiguration of
 all Ini's and conf files the service did not start again.

Isn't it PHP 4.2.3? ;-))

 After starting the Apache manually from command´line it
 stops with the following error (translatet from german) :

 Syntax Error on line 174 of C:/Webverzeichnis/bin/apache/conf: Cannot
 load C:/Webverzeichnis/bin/php/sapi/php4apache2.dll into server:
 Procedure could not be found.

I think this problem is related with the interface change of Apache2. Since
version 2.0.39 (?) the interface changed a bit, so some functions don't
work. You'll have to compile the php4apache2.dll from PHP 4.3.x and use that
with your Apache2.

I'll send you one trough e-mail, and hope it works for you.

HTH
Erwin


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




[PHP] Re: problems with opendir()

2002-09-25 Thread Erwin

Man In The Box wrote:
 hmm i seem to be having a problem with opendir(). perhaps one of you
 could shed some light on the subject.

 here is the line of code (practically right out of the documentation)

 if ($handle = opendir('$_SERVER[DOCUMENT_ROOT]/files/$dir')) {

 blah blah blah;
 }

Because you are using single quotes (') the line don't get parsed, and the
directory you're pointing at is:
$_SERVER[DOCUMENT_ROOT]/files/dir

That doesn't seems correct to me, because the $_SERVER part won't be
replaced by the actual value. Use
$_SERVER['DOCUMENT_ROOT'] . '/files/dir'OR
$_SERVER['DOCUMENT_ROOT']/files/dir instead

HTH
Erwin


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




[PHP] Re: looping through array with list()/each()

2002-09-25 Thread Erwin

 Please cast an eye over the following code and output and tell me why
 $k and $v are not being set:
 
 
 Code:
 -
 
 $ser = array( 'first', 'second', 'third', 'fourth', 'fifth' );
 
 reset($ser);
 while ( list($key, $val) = each($ser) );
 {
 echo \$key = $key, \$val = $valbr;
 }

Small typo:

while ( list($key, $val) = each($ser) );

change into:

while ( list($key, $val) = each($ser) )

Remove the ;

HTH
Erwin

P.S.: Take a break ;-))

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




[PHP] Re: why manual says 'don't use session_register'?

2002-09-24 Thread Erwin

Giancarlo Pinerolo wrote:
 The manual has many cautions that say 'do not use session_regiister,,
 session_is_registered, session_unregister, when the ini setting is
 register_globals=off.

 But they still do work, it seems.
 Or how exactly  do these function work differently than with
 reg_globals On?
 Can I still continue to use them with reg_globals=off, as they seem to
 work anyway?

If you have register_globals set to off, the $_SESSION array is defined.

The functions session_is_registered, session_unregister and session_register
use the session file, not the $_SESSION array. That means that the function
session_unregister or session_register affects the session file, but not the
$_SESSION array!

That can lead to unwanted results if you check that value later on (in the
same php file). If you use unset($_SESSION['key']) instead of
session_unregister('key'), the value will be removed from the $_SESSION
array AND from the session file.

I recommend following the manual and don't use the session_unregister,
session_is_registered and session_register functions anymore.

HTH
Erwin


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




[PHP] Re: MySQL Access

2002-09-20 Thread Erwin

Christian Calloway wrote:
 Can anyone suggest a strategy for importing data from MySQL to Access
 (it sucks I know, but I have to do it for my work). I was thinking of
 using a text-delimited file as an intermediate, but I am not quite
 sure on the logistics.

You can use the Mysql-ODBC driver, which can be downloaded from
www.mysql.com, and then import the tables with access

Grtz
Erwin


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




[PHP] Sessions

2002-09-20 Thread Erwin

Hi all,

I'm having a problem with sessions. I use PHP version 4.2.2.
The project I'm working on, only uses the global variables, $_GET, $_POST
and $_SESSION.

When I store something in the $_SESSION variable, everything goes well. I
can print the contents of this array with print_r, and every variable I
stored is there. But when I leave the page with the header(...) directive
(or any other way), the session is empty!

The session file contains no data (so it is created!), the $_SESSION
variable is empty...

Some extra information:
- I've tried this on PHP 4.1.2, and that works OK
- I've tried output_buffering (on and off)
- I've tried registered_globals (on and off)
- I've tried using session_write_close() before leaving the page
- I've checked the session_start() statement (Yes, it's there :-) )

I hope someone can help me with this...

Thanks in advance,

Erwin


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




Re: [PHP] Sessions

2002-09-20 Thread Erwin

John Holmes wrote:
 You have session_start() on the second page, too, right??


Yes...the session_start() statement is in a global include file, which is
included in all files which require it

Grtz Erwin

 -Original Message-
 From: Erwin [mailto:[EMAIL PROTECTED]]
 Sent: Friday, September 20, 2002 5:45 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Sessions

 Hi all,

 I'm having a problem with sessions. I use PHP version 4.2.2.
 The project I'm working on, only uses the global variables, $_GET,
 $_POST
 and $_SESSION.

 When I store something in the $_SESSION variable, everything goes
 well. I
 can print the contents of this array with print_r, and every variable
 I
 stored is there. But when I leave the page with the header(...)
 directive
 (or any other way), the session is empty!

 The session file contains no data (so it is created!), the $_SESSION
 variable is empty...

 Some extra information:
 - I've tried this on PHP 4.1.2, and that works OK
 - I've tried output_buffering (on and off)
 - I've tried registered_globals (on and off)
 - I've tried using session_write_close() before leaving the page
 - I've checked the session_start() statement (Yes, it's there :-) )

 I hope someone can help me with this...

 Thanks in advance,

 Erwin


 --
 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] Auto-increment value

2002-09-18 Thread Erwin

Scott Houseman wrote:
 Hi there.
 
 You can use the function mysql_insert_id( [link id] ).
 
 I'm using postgresql.

Not if you're using PostGreSQL

Grtz Erwin

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




[PHP] Re: COOKIE Question.

2002-09-17 Thread Erwin

 First I set the cookie like so:
 setcookie (Access, Test_Value,time()+31536000);
 
 Then I check my Cookies in Netscape and I can see that I have the
 cookie stored. But when I go to the page that has
 
 print $HTTP_COOKIE_VARS[Access];
 print $_COOKIE[$Access];
 and even
 print $Access;

What about $_COOKIE[Access] ???

Grtz Erwin

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




[PHP] Re: How to choose a crypt-standard in crypt()?

2002-09-17 Thread Erwin

Uwe Birkenhain wrote:
 Hi,
 is it possible to tell php which crypting it should use in crypt()?

 My problem:
 The program is running on a linux-server (of course) and there is DES
 available and MD5; crypt() uses MD5.
 At home I'm developing on a win98 machine and there seems only DES to
 be available.

 Of course it would be usefull to use both times the same encryption -
 but how to tell the server to use DES??

You should use a 2 character string as salt, to tell PHP that it should use
DES instead of MD5.

Quote from http://www.php.net/crypt: Some operating systems support more
than one type of encryption. In fact, sometimes the standard DES-based
encryption is replaced by an MD5-based encryption algorithm. The encryption
type is triggered by the salt argument. At install time, PHP determines the
capabilities of the crypt function and will accept salts for other
encryption types. If no salt is provided, PHP will auto-generate a standard
two character salt by default, unless the default encryption type on the
system is MD5, in which case a random MD5-compatible salt is generated. PHP
sets a constant named CRYPT_SALT_LENGTH which tells you whether a regular
two character salt applies to your system or the longer twelve character
salt is applicable.

HTH
Erwin


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




[PHP] Re: error handling

2002-09-13 Thread Erwin

Mattia wrote:
 I'm writing a web app with php, and would like to do the following:
 when an error occures (a php/apache error or an application error)
 the error is logged to a log file. The user is displayed a page that
 says 500 internal server error, and nothig more. I have access to
 .htacces and no access to php.ini.

Take a look at 
http://www.php.net/set_error_handler

That's the easiest way to create your own error_handler class!

HTH
Erwin


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




[PHP] Re: user and password for socket connection

2002-09-12 Thread Erwin

 $hostname=https://www.url.com;;
 $port=443;
 $loginmessage=GET / HTTP/1.0\r\nHost: www.php.net\r\n\r\n;
 $timeout=30;
 $fp = fsockopen ($hostname, $port, $errno, $errstr, $timeout);
 if (!$fp) {
 echo $errstr ($errno)br\n;
 } else {
 fputs ($fp, $loginmessage);
 while (!feof($fp)) {
 echo fgets ($fp,128);
 }
 fclose ($fp);
 }

You could try using 
$url = https://$user:$[EMAIL PROTECTED];

I haven't tried this yet ;-))

HTH 
Erwin


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




[PHP] Re: what is wrong?

2002-09-12 Thread Erwin

Meltem Demirkus wrote:
 Hi,
 I want to understand what is wrong with this code?I am trying to
 understand when an empty inputs come from form and I will then give a
 warning message.. 
 
 if($_POST[new_password1] ==)
 
 echo empty input;

And as final addition, you probably have to use

$_POST[new_password1]

Besides that, I would use the form of Lallous:

if ( empty( trim( $_POST[ new_password1 ] )
echo Empty!;

HTH
Erwin


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




Re: [PHP] A question about .php file extension

2002-09-12 Thread Erwin

Adam Williams wrote:
 make a directory called phptest and put a file, index.php in
 it...never 
 tried it tho.

In that case you will have to call http://localhost/phptest/?id=22

Grtz Erwin



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




[PHP] Re: Displaying PDF file

2002-09-12 Thread Erwin

Joseph Szobody wrote:
 I've made a website for a real estate appraiser, who wants to put all
 his appraisals for his clients online. I have stored these PDF
 documents in a folder outside of the webserver folder, for security.
 When a client successfully logs in and clicks the link to biew the
 PDF, I have a PHP script that does the following:

 ?
 Header(Content-type: application/pdf);

 include(../pdfs/whatever.pdf);
 ?

Include is the statement used for including other php files. That means that
the pdf you're including will be parsed by the parser. I have no idea why
some document don't give errors.

You will have to use readfile instead:

readfile( ../pdfs/whatever.pdf);

HTH
Erwin


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




[PHP] Re: Displaying PDF file

2002-09-12 Thread Erwin

Joseph Szobody wrote:
 Thanks Erwin, that helps but I'm still not getting it to work.
 Should I still use the  
 
 Header(Content-type: application/pdf);
 
 line?
 
 I tried using readfile() keeping the header. When I click the link to
 the PHP script that should show me the PDF, the IE status bar says
 something like Downloading from site .blah, then says Done.
 Nothing happens. I'm still on the previous page. No error, no pdf
 file... nothing.
 
 I removed the Header line, and IE prompted me to download the file.
 That's not what I want. 
 
 What am I doing wrong?

That's weird, you should keep the 
Header( Content-Type: application/pdf );
line...

You could also try to add the 
Header( Content-Disposition: attachment; filename=whatever.pdf);
and
Header( Content-Disposition: filename=whatever.pdf );

HTH
Erwin


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




[PHP] Re: php nuke problem

2002-09-12 Thread Erwin

Ryan A wrote:
 Hey guys,
 I just setup php nuke (damn,thats a big package) but the problem is
 that i cannot create a super user ,go the admin, or do anything

 when i go to index.php it tells me to create a super user by clicking
 the link,after i click that link i go to admin.php and when i fill
 that form,it just displays the same form over and over again...the
 super user/ admin user does not get created...

Probably it requires register_globals to be turned On??? Did you checked
that?

HTH
Erwin


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




[PHP] Re: mysql_insert_id

2002-09-11 Thread Erwin

Clemson Chan wrote:
 Hi guys,

 I never can get mysql_insert_id?
 Is this broken with PHP4?
 Please let me know if you can get it to work. or work around.

It works here, but it returns only an ID if the table in which you add a
record has a AutoIncrement column, because it will returns the value of the
AutoIncrement column.

HTH
Erwin


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




  1   2   >