Re: [PHP] does PHP have a equivalent to the C++ #ifndef #define?

2003-08-14 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Sun, 10 Aug 2003 at
15:51, lines prefixed by '' were originally written by you.
 I'm coding a really large web page in PHP.  One of the problems I
run
 into is I'll create a function in file inc.function.something.php
and
 will need a function included in inc.function.somethingelse.php.
If I
 require() somethingelse.php in something.php and it's already been
 required in main.php, I get an error about the function being
defined
 twice.

You can use the require_once() and include_once() functions
instead of require() and include() to avoid this happening.

All the best,

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/
Free PHP error handling script: www.phpmachine.com/error-handler/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/

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



Re: [PHP] drawing problem

2003-08-14 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Fri, 8 Aug 2003 at
14:29, lines prefixed by '' were originally written by you.
 I'm able to draw simple figures like squares and circles using
 ImageCreate(),
 gd_lib is installed properly as far as I know.
 But sometimes the result is a little square with a red cross
instead
 of a
 generated jpg or png.
 No error messages are shown.
 Can anyone help me out?

You will have an error in your code, if you comment out your
header(Content-Type: ); line and type the address of your image
directly into the browser address bar you will see your error
message.

.. or you could use PHPs error handling functions and create an
error handler that outputs as an image, that could be useful during
development.

All the best,

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/
Free PHP error handling script: www.phpmachine.com/error-handler/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/

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



Re: [PHP] HTML equivalents of accented characters

2003-08-14 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Mon, 11 Aug 2003 at
19:18, lines prefixed by '' were originally written by you.
 I don't think this has been discussed, although I'm not really
sure
 what you would call these accented characters, so I haven't been
able
 to do a complete search of the archives, so apologies if this has
been
 previously discussed.
 Is there a function that not only turns  into ,  into ,
 and the like, but also turns é into é and likewise with other
 accented characters? I know I could easily write one, but why if
one
 already exists?

  echo htmlentities(é); // outputs eacute;

See http://php.net/htmlentities

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/
Free PHP error handling script: www.phpmachine.com/error-handler/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/

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



Re: [PHP] array method attributes (OO)

2003-08-14 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Fri, 8 Aug 2003 at
14:18, lines prefixed by '' were originally written by you.
 I wish to pass a session variable into an object and have it
available
 as
 an attribute.  I have what I thought I needed below as a code
segment
 but
 it douse no work.  Has anybody got any idea how I should achieve
this.
 Ben
 ...
 class Contacts{
  var $db;
  array $SESSION;
  function Contacts( $SESSION, $db ) {
  $this-$SESSION = $SESSION;
  $this-$db  = $db;
  }

That will work fine for reading from the variable, are you wanting to
write to it and have the changes made available outside of your
class? if so pass the array in by reference...
function Contacts( $SESSION, $db )

HTH,

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/
Free PHP error handling script: www.phpmachine.com/error-handler/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/

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



Re: [PHP] Formatted text from mySQL DB

2003-08-14 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 5 Aug 2003 at
14:18, lines prefixed by '' were originally written by you.
 Astrum Et Securis!
 I had a question..
 When I create any field and let data be sent into my mySQL DB
through
 it.. it goes ok. But when I retrieve it.. the data comes
completely
 unformatted.
 That is.. let's say I fed this in a textarea..
 The
 Man
 Cool.
 If I view the data from my phpMyAdmin or even Command Line mySQL..
the
 data has gone just this way..
 But when I use mysql_fetch_array() to get the data back from
mySQL, it
 prints as ..
 The Man Is Cool.
 The newline disappears, and I have to use br's while feeding the
 data
 to have the line gaps. What am I doing wrong?

The newlines will be there if you view the source of your page.
Browsers do not render newlines in the source as newlines in the
browser display, as you have found out you have to convert the
newlines to BRs.

HTH

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/
Free PHP error handling script: www.phpmachine.com/error-handler/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/

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



Re: [PHP] Simple cookie question

2003-08-14 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Sun, 10 Aug 2003 at
00:24, lines prefixed by '' were originally written by you.
 This may be a stupid question, but I'm trying to set up a system
where
 I can
 take a poll from visitors to my website and then set a cookie so
that
 they
 can't vote more than once (until they clear their cookies at
least).
 Problem is, I don't want to put it at the top of my page, because
what
 somebody opens up a poll but decides not to vote, then later
changes
 his
 mind.  The cookie will prevent him from voting.  I want the cookie
to
 be set
 right after the user clicks the vote button, but every time I do
that,
 I get
 an error about headers already being sent.  Is there any way
around
 this?

You cannot send any headers after you have sent output as this is how
HTTP works, a set of headers are sent, double newline, then all the
content.  You can't go back in time and add more headers.

There are two ways round your problem...

1. Set your cookie right at the top of the script, so as your first
line have something like:
if(isset($_POST['vote'])){ setcookie(); }

2. Use output buffering, this will make PHP buffer all of your
content and not send it till you tell it to (or until it reaches the
end of the file).
Read more at:
http://uk.php.net/ref.outcontrol

All the best,

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/
Free PHP error handling script: www.phpmachine.com/error-handler/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/

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



Re: [PHP] find string

2003-08-11 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Mon, 11 Aug 2003 at
00:25, lines prefixed by '' were originally written by you.

 Isn't there an in_array function you can use?
 If (in_array($action, array(a1,a2,a3,a4)) {
 // do something
 else {
 // do something else
 Carl.

Make sure that your string values are in quotes or PHP will belooking
for constants with those names, i.e. array('a1','a2','a3','a4')

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/
Free PHP error handling script: www.phpmachine.com/error-handler/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/

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



Re: [PHP] Allowed mem size exhausted

2003-08-11 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 5 Aug 2003 at
16:45, lines prefixed by '' were originally written by you.
 I have the following code that generates the following error.  I
am
 using
 this code to prepare a zip or tar.gz file as an email attachment.
Can
 someone suggest a better / more efficient way to do this and maybe
 avoid the
 error???
 I believe that the file that generated this error was about 1.8MB.
 6 $fp = fopen($path.$filename, r);
 7 $content = fread($fp, filesize($path.$filename));
 8 $attachment = base64_encode($content);
 9 $attachment = chunk_split($attachment);
 Fatal error: Allowed memory size of 8388608 bytes exhausted at
 (null):0
 (tried to allocate 2228273 bytes) in
 /home/user/public_html/dir/subdir/include/functions.php on line
9

Either increase your memory limit in your php.ini or maybe try some
alternatives to chunk_split and see if they do the job any better
(probably unlikely to help but worth a try), maybe wordwrap() (with
the force parameter set to true) or a while loop using substr()?

All the best,

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/
Free PHP error handling script: www.phpmachine.com/error-handler/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/

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



Re: [PHP] Allowed mem size exhausted

2003-08-10 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 5 Aug 2003 at
17:57, lines prefixed by '' were originally written by you.
 I would prepare the file on disk instead of memory. If you do
 increase the memory to handle bigger files, what happens when you
 get 10 requests at the same time?  about 80MB of memory used.

Correct me if I am wrong but would it not be better to use the
functions he is currently using (which prepare the data in volitile
memory) for as long as they allow for this.  The OS should then
realise when it does not have enough physical RAM for each of the
requests and handle swapping onto disk itself as and when it is
needed.  This would mean you haven't got the overheads of writing
lots of data to disk, just to delete it again when you do only have
one request at a time and have plenty of RAM spare to take care of
the operation.

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/
Free PHP error handling script: www.phpmachine.com/error-handler/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/

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



Re: [PHP] array method attributes (OO)

2003-08-09 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Fri, 8 Aug 2003 at
15:54, lines prefixed by '' were originally written by you.
 array $SESSION; near the beginning gives the error
 Parse error: parse error, unexpected T_ARRAY, expecting
T_OLD_FUNCTION
 or
 T_FUNCTION or T_VAR or '}' in
 d:wwwrootstwerburghs.orgobjcontacts.obj.php on line 6
 Fatal error: Cannot instantiate non-existent class: contacts in
 d:wwwrootstwerburghs.orgcmslist_contacts.php on line 9
 At 14:44 08/08/2003 +0100, David Nicholson wrote:

Ah, didn't spot that, just use var instead of array, if you want it
to start off as a blank array, use:
var $SESSION = array();

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/
Free PHP error handling script: www.phpmachine.com/error-handler/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/

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



Re: [PHP] How to run PHP from a MySQL DB

2003-08-08 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Wed, 6 Aug 2003 at
15:17, lines prefixed by '' were originally written by you.

 I have a database of code pages and was wondering if their is a way
to
 actually run the code from the Database as if it was part of a
page.
 Thanks,
 Jeremy

http://uk2.php.net/eval will do the trick.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/
Free PHP error handling script: www.phpmachine.com/error-handler/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/

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



Re: [PHP] snippet

2003-08-07 Thread David Nicholson
** CORRECTION BELOW **

Hello,

This is a reply to an e-mail that you wrote on Tue, 5 Aug 2003 at
11:14, lines prefixed by '' were originally written by you.

 $sFont =submit(font) ? SITE_ROOT . PROG_PATH .
submit(font) : ;

it is the same as:
if(submit(font)){
$sFont = SITE_ROOT . PROG_PATH;
} else {
$sFont = ;
}

(see http://uk.php.net/language.operators.comparison)

submit() is a user defined function, if it evaluates to **TRUE**
then
$sFont will contain the value of those two constants put togetherm
otherwise it will be set to an empty string.

HTH

David.


--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/
Free PHP error handling script: www.phpmachine.com/error-handler/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/

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



Re: [PHP] How can I change ? to %3F

2003-08-06 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 5 Aug 2003 at
23:16, lines prefixed by '' were originally written by you.

 Is it possible to change the ?, :,  and / characters to their
 respective
 hex(?) values automatically?  That is without having to use
 str_replace for
 each one?  Anyone know how?
 Chris

http://uk2.php.net/urlencode

If you want *only* the ?:/ characters changed then it can be done
with a regular rexpression, the e modifier, and the ord(), hex() and
strtoupper() functions, post back if you would like an example.

HTH

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/
Free PHP error handling script: www.phpmachine.com/error-handler/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/

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



Re: [PHP] snippet

2003-08-05 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 5 Aug 2003 at
11:14, lines prefixed by '' were originally written by you.

 $sFont =submit(font) ? SITE_ROOT . PROG_PATH .
submit(font) : ;

it is the same as:
if(submit(font)){
$sFont = SITE_ROOT . PROG_PATH;
} else {
$sFont = ;
}

(see http://uk.php.net/language.operators.comparison)

submit() is a user defined function, if it evaluates to false then
$sFont will contain the value of those two constants put togetherm
otherwise it will be set to an empty string.

HTH

David.


--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/
Free PHP error handling script: www.phpmachine.com/error-handler/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/

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



Re: [PHP] preventing output dump of passthru()

2003-08-05 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Wed, 6 Aug 2003 at
00:56, lines prefixed by '' were originally written by you.
 Hello,
 Trying to prevent the output dumping of passthru() and instead
store
 the
 output in a variable.
 I read an article that suggested this:
 ob_start();
 passthru(command);
 $output =3D ob_get_contents();
 ob_end_clean();
 But that didn't work. Is there *ANY* way to achieve what I want?

What you put above should work, but how about...

$output = array();
exec(command,$output);
$output = implode(,$output);

(see http://uk.php.net/implode and
http://uk2.php.net/manual/en/function.exec.php)

All the best,

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/
Free PHP error handling script: www.phpmachine.com/error-handler/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/

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



Re: [PHP] using exec to run a shell script

2003-08-04 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Mon, 4 Aug 2003 at
23:14, lines prefixed by '' were originally written by you.
 Hello. I'm attempting to run the exec function to run a shell
script
 that
 will restart a service on my Red Hat server. The script says it
has
 failed
 shutting down and restarting the service everytime I run it from a
 browser.
 Any suggestions on why it might be failing? I can send more
details if
 needed.

I expect it is because the shell script is running with the
permissions as of webserver and your webserver does not have
permission to restart the service.

HTH

David.


--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/
Free PHP error handling script: www.phpmachine.com/error-handler

Professional Web Development by David Nicholson -
www.djnicholson.com

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/

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



Re: [PHP] Values from forms

2003-08-04 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 5 Aug 2003 at
00:05, lines prefixed by '' were originally written by you.
 $team2, etc. they are there, I just can't figure out how to get
the
 values inputted into my database. In the loop below, what would I
put
 the second values section to get the values of $team1, $team2,
etc.
 for($i=1; $i  $count + 1; $i++) {
   mysql_query(insert into manager (idn, name) values
 ('$i','???'));
 TIA

${'team'.$i} will work but it would lead to tider code if you got
your data into the script using an array...

input name='test[0]'...
input name='test[1]'...
input name='test[2]'...
etc...

All the best,

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/
Free PHP error handling script: www.phpmachine.com/error-handler

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/

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



Re: [PHP] Values from forms

2003-08-04 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 5 Aug 2003 at
00:39, lines prefixed by '' were originally written by you.
 Thanks for the info. The first suggestion doesn't work,

What error did you get?

 and the second
 may work - but the problem is I need the array to start at '1' -
and
 arrays in general start at 0.

Arrays can have whatever you want as the keys, if you want them to
start at one, start them at one!

HTH

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/
Free PHP error handling script: www.phpmachine.com/error-handler/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/

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



Re: [PHP] connecting access (*.mdb) database with PHP

2003-08-02 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Sat, 2 Aug 2003 at
15:31, lines prefixed by '' were originally written by you.
 how can I connect access database(*.mdb) with php?  what is the
code?
  I
 will be happy if you write php code.

Windows Control Panel  Administrative Tools  Data Sources (or
something like that!)

This window will let you setup an ODBC DSN for any mdb file.  You
should then be able to use PHPs ODBC functions to run queries on it
http://uk.php.net/odbc.

I have never tried this though, so apoligies if it does not work.

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Undefined variable problem

2003-08-01 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Fri, 1 Aug 2003 at
14:47, lines prefixed by '' were originally written by you.

 Notice: Undefined variable: email1 in
 c:phpdevwwwbwhprojectcompare.php
 on line 117

 $$tmp.= $value;  /* This is the error line 117*** */

You are trying to append to the variable instead of create it, change
this line to:
$$tmp = $value;

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] preg, patern quantifier limit

2003-08-01 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Fri, 1 Aug 2003 at
20:35, lines prefixed by '' were originally written by you.
 Hi, i did a standard preg [A-Za-z0-9]{1,65536}
 What i am simply trying to do is to validate the a form that will
 insert
 into my TEXT database field. So i just want to prevent a larger
insert
 then expected.
 PHP trows me this error preg_match(): Compilation failed: number
too
 big in {} quantifier at offset 19 ...
 So it appears that quantifiers are limited. Anybody knows what
that
 limit is ?

I can't help with your actual question, but I just thought I would
mention you can do what you are trying to do with...

if(strlen($text)65536){
// too big
}

http://php.net/strlen

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] weird php error

2003-08-01 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Sat, 2 Aug 2003 at
00:10, lines prefixed by '' were originally written by you.
 Hello,
   I'm getting a weird warning message from a php script that I'm
 working
 on.  Right now the script does not contain any include or require
 statements and is basically a very simple straight forward script.

 But
 when I try to execute via the browser I get the following error:
 Warning: Failed opening '/var/www/main/htdocs/login.php' for
inclusion
 (include_path='.:/usr/share/pear') in Unknown on line 0
 Any clues?  I can send a copy of the script if anybody would
like.

You have your auto_prepend_file value set to a file that does not
exist in your php.ini file or a .htaccess file.  I just tested it and
it gives this exact error.

HTH

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] PHP or CGI in C/C++

2003-07-31 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Thu, 31 Jul 2003 at
13:38, lines prefixed by '' were originally written by you.
 Greetinx,
 I'm a newbie and wondering which PHP script or CGI in C/C++
generally
 can
 run/respond faster via http from the same server doing the same
tasks.
 I appreciate your comments in advance.

I would expect compiled C/C++ to be faster as there is no need for
the code to be interperated and compiled on each request.  You will
need to do your own benchmarking to see if the difference bothers you
though.

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Is there an easier way?

2003-07-31 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Fri, 1 Aug 2003 at
02:04, lines prefixed by '' were originally written by you.
 Hi,
 This is what i am doing, querying a database via a select
statement
 (getting
 max 5 records), then dumping everything into an associative array.
And
 then
 assign the arrays value to a variable for easier readibility and
 usability
 like so:
 if(!($rs = mysql_query($q))) // querying
   { echo Query failed. mysql_error(); exit; }
$n = 0;
   while ($line = mysql_fetch_assoc($rs)) { //dumping into an
array
 foreach ($line as $field = $value) {
   $data[$field][$n] = $value;
 }
 $n++;
   }
 and this is how i use the arrays values (blah is the field name):
 $blah1=$data['blah'][0];
 $blah2=$data['blah'][1];
 $blah3=$data['blah'][2];

The logic you are using is a bit messed up.  You should be aiming to
get an array like...
$data[0]['field1']
['field2']
 [1]['field1']
['field2']
..and this can be done like this...
  $data = array();
  while ($line = mysql_fetch_assoc($rs)) {
  $data[] = $line;
  }

HTH

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Updating a table after a successful download

2003-07-30 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Wed, 30 Jul 2003 at
13:46, lines prefixed by '' were originally written by you.
 The problem I am having is that when the download is canceled by
the
 user
 the document still shows up as being checked out. Is there a way
to
 know if
 the document has been successfully downloaded before I update the
 database.

The connection handling section of the manual may help you...
http://uk.php.net/manual/en/features.connection-handling.php

You could possibly use register_shutdown_function() and
connection_aborted() to set the status back if the connection was
cancelled.

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Updating a table after a successful download

2003-07-30 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Wed, 30 Jul 2003 at
14:43, lines prefixed by '' were originally written by you.
 I tried changing the code to:
 // send headers to browser to initiate file download
   header (Content-Type: application/octet-stream);
   header (Content-Disposition: attachment; filename=$realname);
   readfile($filename);
   if(connection_aborted()==0)
   $query = UPDATE $table_data SET status = '$SESSION_UID'
 WHERE id = '$id';
   $result=$conn-Execute($query);
 But it still doesn't work as expected. What am I doing wrong?

It is executing your if(connection_aborted()==0) as soon as it
gets to it when parsing the code instead of when the connection with
the broswer terminates.  You need to use
register_shutdown_function() as well.  I tested this code...

?php
register_shutdown_function(myshutdown);

header (Content-Type: application/octet-stream);
readfile(verybigfile.mpg);

function myshutdown(){
if(connection_aborted()==0){
exec (net send ZXC connection_aborted()==0);
} else {
exec (net send ZXC connection_aborted()!=0);
}
}

?

..and it worked fine.  Notice I used net send ZXC (ZXC is my
Windows computer name) as you cannot echo after the connection has
closed.

HTH

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Simple date question

2003-07-30 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Wed, 30 Jul 2003 at
19:18, lines prefixed by '' were originally written by you.

 If I have:
 $firstdate = 2003-06-28;
 then how can I get $firstdate plus 4 days?
 Thanks!

date(Y-d-m,mktime(0,0,0,substr($firstdate,5,2),substr($firstdate,8,2),substr($firstdate,0,4))
+ (60*60*24*4));

Should do the trick, you can probably use strtotime instead of all
the substr()'s but at a guess I would expect the above to be quicker
(not that I have benchmarked it).

HTH

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] How can I add records to database every 60 minutes???

2003-07-29 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 29 Jul 2003 at
10:54, lines prefixed by '' were originally written by you.
 I'm not sure if this is possible in PHP, but Apache's Cron should
take
 care of this.

Cron is a feature of most unix based OSes rather than a feature of
Apache.  It will do the trick for you though, you can use it to call
a PHP script either using the PHP binary on your system (if you have
one) or by calling a script through a command line program such as
lynx or wget.

HTH

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] wheres the problem?

2003-07-29 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 29 Jul 2003 at
16:52, lines prefixed by '' were originally written by you.
  now i restarted my localhost machine and its not
 working
 now more

Sounds like you have made a change in your php.ini file previously
without restarting the webserver so now you have restarted your
computer the change has kicked in.  Did you make a php.ini backup
last time you changed it? if so restore the backup.

Disabling register globals, or turning up error reporting are two
candidates that could cause the errors you posted.

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Bizarre SQl, if issue....

2003-07-29 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 29 Jul 2003 at
18:25, lines prefixed by '' were originally written by you.
 If the SQL statement returns an empty set, shouldn't $result be
equal
 to 1?
 Instead, I'm getting $result = 4.

If the query fails, e.g. because you have an error in your SQL
$person will contain FALSE.

If the query executes succesfully (whether it is an empty set or not)
$person could contain any number at all which represents the result
resource.

I think you want...

$numrows = mysql_num_rows($person);
if($numrows===0){
// result set was empty
}

HTH

David

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Bizarre SQl, if issue....

2003-07-29 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 29 Jul 2003 at
18:57, lines prefixed by '' were originally written by you.
 Off hand, I would agree.  And that is what I would expect.
 However, the *exact* same setup on a different server gives me a
 result of
 'FALSE' properly.  The other server has php 4.3.3 on it - the one
 giving the
 improper response has php 4.1.2.
 Could this be the issue?
 -Mike

mysql_query() returns FALSE if the query fails and a resource ID if
it suceeds in both of those versions. The best way to see if it
failed or not is...

$queryid = mysql_query($sql);
if($queryid !== FALSE){
  // this will be evaluated if mysql_wuery did not return FALSE
  // and it is type-sensitive so (int)0 does not count as FALSE.
}

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Bizarre SQl, if issue....

2003-07-29 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 29 Jul 2003 at
19:46, lines prefixed by '' were originally written by you.
 I did!  Look at this again:
 $which_person = mysql_query(SELECT ID FROM tblItems WHERE
number =
 $place);
   $vthere = mysql_num_rows($which_person);
   if ($vthere == '0') { True } else { False }
 Yet it still returns as if this is FALSE (i.e. it executes the
else
 {}. :

As long as your query is returning 0 rows that code should work ok,
but it is incorrect for correctness,
if ($vthere == '0')
should be
if ($vthere == 0)
As $vthere will contain an integer, not a string, but as you are
using the == comparison operator instead of === PHP should
convert them both to the same type before comparing.

Can we see the snippet of the actual code that you are using?

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Bizarre SQl, if issue....

2003-07-29 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 29 Jul 2003 at
19:59, lines prefixed by '' were originally written by you.
 Actually, what you see is *exactly* the code being used. Nothing
has
 changed
 about it.

No.  It is not the code you are using.
if ($vthere == 0) { True } else { False }
would give a parse error.

 Is there any way possible that this could be the client's server?
 I
 had to
 beg to get 'em to recompile to 4.1.2 from 4.0.3.  There are using
a
 version
 of Linux I don't recognize (it isn't redhat or mandrake), but it
looks
 like
 their kernel is up to date.

IMO, if you want to find out what is wrong you need to stop looking
for things out of your control that could be breaking it.  Chances
are PHP is doing exactly as it is documented to do, no matter what
PHP version, linux distro, kernel version or anything else in use.
Follow your code through exactly as it would be when it is
interpreted and be on the lookout for your mistake, not your excuse
and you will find the error in your code!

Right now though I think everyone is very confused about your problem
so if you need more help from the group I would reccomend a new post,
a code extract, what you expect to happen and what is actually
happening.

HTH,

David.


--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Weird Problem

2003-07-29 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 29 Jul 2003 at
20:40, lines prefixed by '' were originally written by you.
 I have the following chunk of code:
   $sql = SELECT setting from settings where
name='display_rows';
   include(connect.inc.php);
   print $sql;
   $row = mysql_fetch_row($result);
   $path = $row[0];
   print $path;
 It always prints out 1
 But if I run the code at the sql command prompt, it prints out
25,
 which is the correct value.
 Does anyone have any ideas why im having this problem??
 - ---

Unless it is done within connect.inc.php you have not executed your
query.  Maybe the last query you executed has a row containing the
value 1 ready to be fetched?

Try adding $queryid = mysql_query($sql); before $row =
mysql_fetch_row($result);

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Array transform date and put in a session

2003-07-29 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 29 Jul 2003 at
21:42, lines prefixed by '' were originally written by you.
 Hi All,
 Can you please help me with the following:
 I've got a form with a field called datebirth[];

According to the rest of your code, it should be called datebirth,
not datebirth[].

 After submitting the form; it must put the datebirth field (or
fields)
 into the mysql format -mm-dd and after that put it in a
session:
 $date_array = split(-, $_POST['datebirth']);
 $mysqldate =
$date_array[2].-.$date_array[1].-.$date_array[0];
 $_SESSION['datebirth'] = array();
 $_SESSION['datebirth'] = $mysqldate;
 This is my code till now but i'm stuck (when proccesing it i'm
only
 getting Array... as output).. Can someone help me?


--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Array transform date and put in a session

2003-07-29 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 29 Jul 2003 at
22:15, lines prefixed by '' were originally written by you.
 Hi David,
 Thanks for your reply... This makes no sense;
 According to the rest of your code, it should be called datebirth,
 not datebirth[].
 Let me put in the whole code
snip

Your $_POST array will be looking something like this...
$_POST['datebirth']=array('xx-xx-','xx-xx-',...);

So you will need something like this...
foreach($_POST['datebirth'] as $thisdatebirth){
$date_array = split(-, $thisdatebirth);
$mysqldate =
$date_array[2].-.$date_array[1].-.$date_array[0];
}

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] how to make a global scope array

2003-07-25 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Fri, 25 Jul 2003 at
23:51, lines prefixed by '' were originally written by you.

 [EMAIL PROTECTED]
 Jack Lee:
  //I have an array a[] like this:
  ?php
  $a[]=0;
  //How to define and use it in a function like this?
  function myfunc(something)
  {
  echo $a[0];  //got error here Notice: Undefined
variable:
  }
  //Thanks for any help.!!!
 global $a;

.. or echo $GLOBALS['a'][0];

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] how to make a global scope array

2003-07-25 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Sat, 26 Jul 2003 at
00:50, lines prefixed by '' were originally written by you.
 Ouch!
 Sometimes I wish global didn't exist

Yes, it can be better to pass in a variable (by reference if you need
to write to it from within a function and not have it as the value
that you return), e.g.

function doSomething($a){
$a = 20;
return true; // to signify success
}

$a = 10;
doSomething($a);
echo $a; // prints 20


--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Problem with MySQL Query

2003-07-23 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Wed, 23 Jul 2003 at
22:28, lines prefixed by '' were originally written by you.
 As per your suggestion
   $dbqueryshipping1 = select * from tempuserpurchase where
 (usersessionid=$User_Shopping_Id) and day=1 and
type!='Meal
 Plans'
 $resultshipping1 =
mysql_db_query($dbname,$dbqueryshipping1);
 if(mysql_error()!=){echo mysql_error();}
$result1 = mysql_num_rows($resultshipping1);
 It is still not excluding Meal Plans from the listing.

Try

  $dbqueryshipping1 = select * from tempuserpurchase where
(usersessionid=\$User_Shopping_Id\) and day=\1\ and
type'Meal Plans'

David

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Problem with MySQL Query

2003-07-23 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Wed, 23 Jul 2003 at
22:54, lines prefixed by '' were originally written by you.

$dbqueryshipping1 = select * from tempuserpurchase
where
  (usersessionid=$User_Shopping_Id) and day=1 and
  type'Meal Plans'
 Tryed both methods and it is still not excluding anything matching
 Meal
 Plans

Is the data you are wanting to exclude exactly 'Meal Plans' (case
sensitive).  If not, use:

type NOT LIKE 'Meal Plans'

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] £ outputting £ signs

2003-07-22 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 22 Jul 2003 at
15:01, lines prefixed by '' were originally written by you.
 My suggesstion would be as your adding the data to the database
 convert the
 £ to pound;

I wouldn't do that, it will eman extra CPU cycles if at a later date
you decide you want to use the data in your database for anything
other than a HTML page.  Also it is 6 bytes of wasted disk space per
record - in a very large database that would show.

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] XX outputting X signs

2003-07-22 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 22 Jul 2003 at
16:01, lines prefixed by '' were originally written by you.
 Would it not make sese to store the number as a decimal and have
the
 '£'
 added at output?

I had assumed that the original poster was storing currency ammounts
within a sentence that had an entire text field to itself, but yes,
if it is only the amount being stored in the field use a decimal and
add the pound symbol when creating your page.

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Arrays and Alphabetical order

2003-07-22 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 22 Jul 2003 at
17:40, lines prefixed by '' were originally written by you.
 I need it to echo
 out a
 table with all the A's first, then a blank line, then all the B's,
a
 blank
 line and so on. I could write 26 different queries, one for each
 letter of
 the alphabet, but surely there is a tidier way.

How about:
for($i=a;$i=z;$i++){
echo H1Items beginning with the letter $i/H1;
$arrayposition = 0;
while(strtolower(substr($data[$arrayposition],0,1))==$i){
echo $data[$arrayposition] . BR /;
$arrayposition++;
}
}

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Redirect output of include() for mailing

2003-07-22 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 22 Jul 2003 at
18:37, lines prefixed by '' were originally written by you.
 But how can I instead capture the output of the include to
variable
 and mail
 it, something like
 $msg = include('myscript.php?foo=bar)

Use output buffering...

ob_start() // see http://uk2.php.net/ob_start

include(youfile.php);

$mailthis = ob_get_contents() // see
http://uk2.php.net/manual/en/function.ob-get-contents.php

ob_end_clean() // see
http://uk2.php.net/manual/en/function.ob-end-clean.php


HTH

David

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Redirect output of include() for mailing

2003-07-22 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 22 Jul 2003 at
18:57, lines prefixed by '' were originally written by you.
 Thanks.
 Will the same method works for a dynamically generated image using
 php?
 Suppose that myscript.php output JPEG instead of HTML.
 RDB

Yes that will work fine.

BTW: I just noticed I missed off the ';' at the end of most of the
lines of code that I posted, I really should start proof-reading
before clicking send!

David

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] magic quotes

2003-07-22 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 22 Jul 2003 at
20:36, lines prefixed by '' were originally written by you.
 Hello,
 I am running a test server and a live system. both do have the
same
 php
 version running.
 The test system however does not report a db error if I try to
insert
 string containing a '
 The live system does.
 As I learned from php.ini magic quotes are turned off on both
systems.
 what could be the cause?


Are you escaping all strings that are used in db queries with the
appropiate function for your database server, e.g. for mySql,
mysql_escape_string()
http://uk2.php.net/mysql_escape_string

David


--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] bug in addslashes command?

2003-07-22 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 22 Jul 2003 at
20:51, lines prefixed by '' were originally written by you.
 Hello there,
 I am running php 4.2.1 on a linux machine. Not sure, but I think
there
 might
 be a bug in there.
 While putting data into the db I do get an error in a verry rar
case.
 All
 values are escaped by addslashes commands.
 This is the original string:
 the 'capitol-' of Kefalonia
 This is the string after addslashes:
 the 'capitol-' of Kefalonia
 Which leaves the last ' unescaped.

On my PHP 4.3.2 installation, echo addslashes(the 'capitol-' of
Kefalonia); displays:
the 'capitol-' of Kefalonia
which appears to be correct.

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] magic quotes

2003-07-22 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 22 Jul 2003 at
20:53, lines prefixed by '' were originally written by you.
 I just found, that one server pulls the data out of the db and
leaves
 the
 slashes inside the text, while the other one does not.
 both of the phpinfo look same to me. However I might have
overlooked
 something.

Sounds like one server is adding the slashes twice then, possibly
once by magic quotes and once by your call to addslashes.  Double
check your php.ini and phpinfo() output to see if magic quotes is
on.

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Fwd: Re: [PHP] bug in addslashes command?

2003-07-22 Thread David Nicholson
-
NOTE: This is a forwarded message, the message being
referred to can be found at the bottom of this e-mail.
-

Hello,

My mail client removed the backslashes from my mail.

The output had a backslash before each single quote.

David.


===8===Original message
information===
From: David Nicholson [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Date: Tue, 22 Jul 2003, 20:58
Subject: Re: [PHP] bug in addslashes command?
===8==Original message
text===
Hello,

This is a reply to an e-mail that you wrote on Tue, 22 Jul 2003 at
20:51, lines prefixed by '' were originally written by you.
 Hello there,
 I am running php 4.2.1 on a linux machine. Not sure, but I think
there
 might
 be a bug in there.
 While putting data into the db I do get an error in a verry rar
case.
 All
 values are escaped by addslashes commands.
 This is the original string:
 the 'capitol-' of Kefalonia
 This is the string after addslashes:
 the 'capitol-' of Kefalonia
 Which leaves the last ' unescaped.

On my PHP 4.3.2 installation, echo addslashes(the 'capitol-' of
Kefalonia); displays:
the 'capitol-' of Kefalonia
which appears to be correct.

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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

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



Re: [PHP] php function on php.net

2003-07-22 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 22 Jul 2003 at
21:15, lines prefixed by '' were originally written by you.
 Hi there,
 I am wondering how on php.net the search for functions is done.
You
 can add
 any function just behind the php.net
 like php.net/phpinfo and it will point you right through it. I
know
 how to
 redirect this as a 404 error in apache to another file, but then
the
 url is
 changing. In the php.net case the url stayes the same.
 Does anybody know how this is done?
 Thanx, Merlin

Use a path relative to your httpdocs for your error document, e.g.

ErrorDocument 404 /myerrorpage.php

instead of

ErrorDocument 404 http://mysite/myerrorpage.php

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] SQL select

2003-07-21 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Mon, 21 Jul 2003 at
11:08, lines prefixed by '' were originally written by you.

 heloo,
 i have got a MySQL table:
 id_comp id_goods type
 has somebody some idea hot to select?

This is off topic for this list but here goes...

SELECT * FROM tablename GROUP BY id_comp

will probably do it.

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] regex help?

2003-07-21 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Mon, 21 Jul 2003 at
08:59, lines prefixed by '' were originally written by you.
 Can't seem to get this to work...
 trying to yank stuff xxx from
 TD class=a8b noWrap align=middle width=17
bgColor=#ccxxx/td

Try this:

preg_match(/td[^]*(.*)/TD/i, $l, $regs);

HTH

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] what is the problem?

2003-07-19 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Sat, 19 Jul 2003 at
15:25, lines prefixed by '' were originally written by you.

Two things...

 form method=post action=takeform.php
 input type=text value=sentence
 /form

Your input does not have a name attribute.

 .
 takeform.php is this:
 echo $sentence;
 .

This line of code will onyl work if the name of your input tag is
sentence and register globals is switched on.

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Question about Include_once

2003-07-19 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Sat, 19 Jul 2003 at
19:15, lines prefixed by '' were originally written by you.
 Does file called by Include_once  stay with the client's
session or
 just for operations in the page where it is stated?

just for operations in the page where it is stated

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] MySQL datetime extraction

2003-07-19 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Sat, 19 Jul 2003 at
19:16, lines prefixed by '' were originally written by you.

 Given a date in MySQL datetime format, how do I extract the
elements?
 That is get the month, day, year, hour, ...
 Thanks,
 Yasir

Bit off topic for this list, but see the DATE_FORMAT() function at
http://www.mysql.com/doc/en/Date_and_time_functions.html

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Setting total db size to a variable.

2003-07-19 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Sun, 20 Jul 2003 at
00:42, lines prefixed by '' were originally written by you.
 I have a question in regards to finding the total db size and
setting
 it to a variable.
 How would I go about this?

For mysql this will do the trick...

$info = mysql_fetch_array(mysql_query(show table status from
$databasename  = '$tablename'));
$sizeinMB = $info[Data_length]/1024/1024;

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] bcc on php

2003-07-17 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Thu, 17 Jul 2003 at 13:09, lines
prefixed by '' were originally written by you.
  be aware that BCC header some times don't works properly on Windows
  platforms and the recipient can see the BCC header from the source of
 mail!

I am using PHP 4.3.2 on Windows and just did some testing...

I sent a mail with a Bcc header, none of the recipients could see the Bcc line
in the message source.  I also had my packet sniffer running at the time PHP
sent the mail and what it sends to the mail server is correct so if what you
are describing happens it is because of an error in the code or the SMTP server
you are using has messed up.

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Parsing POP3 Mailbox

2003-07-17 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Thu, 17 Jul 2003 at 14:04, lines
prefixed by '' were originally written by you.
 Ok, this is what I want to do.  I would like to parse a mailbox and
 forward
 the returned mail in it to other users.  For instance, if I send an
 e-mail
 to [EMAIL PROTECTED] and [EMAIL PROTECTED] doesn't exist it is
 going
 to send the return to [EMAIL PROTECTED].  I want to parse
 [EMAIL PROTECTED] and
 send the e-mail to whoever is in the Disposition-Notification-To
 header of
 the e-mail.  Anyone know where I can find a good script to parse mail
 boxes
 or maybe give me an idea of where to start?  I checked hotscripts and
 some
 others but they are complete web based e-mail systems.  I'd like to
 run this
 as a cron job if possible and I don't want to tear another system all
 apart

If you have the imap php extensions installed you could use them (they support
POP too) I normally work on systems without the imap enxtensions though so I
chose to make my own class to deal with POP3 related tasks.  Here are some
snippets that you may find useful...

class POPClient {

..

function Connect(){
// connect to server
if(!$this-[EMAIL PROTECTED]($this-server, $this-port)){
$this-error = Could not connect to
{$this-server}:{$this-port};
return FALSE;
}
// login to server:
fputs($this-sock, USER {$this-user}\r\n);
$buf = fgets($this-sock, 1024);
if($buf[0] != '+'){
$this-error = Invalid username: {$this-user};
return FALSE;
}
fputs($this-sock, PASS {$this-pass}\r\n);
$buf = fgets($this-sock, 1024);
if($buf[0] != '+') {
$this-error = Invalid password;
return FALSE;
}
$this-connected = TRUE;
return TRUE;
}

snip

function MessageCount(){
if($this-connected){
fputs($this-sock, STAT\r\n);
$buf = fgets($this-sock, 1024);
$buf = fgets($this-sock, 1024);
$statbits = split(' ', $buf, 3);
if(isset($statbits[1])){
return $statbits[1];
} else {
return 0;
}
} else {
$this-error = Not connected to server;
return FALSE;
}
}

snip

function RetrieveMsg($id, $headonly=FALSE){
if($this-connected){
if($headonly){ $command=TOP; $param= 0; } else {
$command=RETR; $param=; }
fputs($this-sock, $command $id$param\r\n);
$buf = fgets($this-sock, 1024);
if($buf[0] != '+') {
$this-error = Mail server would not let me retrieve message
$id;
return FALSE;
}
$message=;$thisline=;
while ($thisline!=.\r\n){ // .\r\n signifies the end of the
message
$thisline = fgets($this-sock, 1024);
$this-messagesource .= $thisline;
}
return TRUE;
} else {
$this-error = Not connected to server;
return FALSE;
}
}

snip

}


--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Parsing POP3 Mailbox

2003-07-17 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Thu, 17 Jul 2003 at
15:10, lines prefixed by '' were originally written by you.
 Forgive me for bothering you again with such a silly question, but
say
 want to connect as localhost with password PASS.  How could I
call
 the
 function?

No problem, very basic usage (with no error checking) would be as
follows...

$popclient = new POPClient(serveraddress,username,password);
$popclient-Connect();
$messagecount = $popclient-MessageCount();
for($i=0;$i$messagecount;$i++){
$messageheaders = $popclient-RetrieveMsg($i, TRUE);
// do something with the headers here
}

The above code assumes you have a constructor function in the class
(the one I posted originally didn't include it).  Add this function
to the class to make it work...
function POPClient($server, $user, $pass, $port=110){
$this-server = $server;
$this-user = $user;
$this-pass = $pass;
$this-port = $port;
$this-connected = FALSE;
$this-messagesource = ;
}

HTH,

David

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] get size of variable n bytes

2003-07-16 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Wed, 16 Jul 2003 at 14:52,
lines prefixed by '' were originally written by you.
 Hi List
 Sorry, tried to find it in manual...
 I'd like to query a db and and see how big the result is in bytes. How
 can I do that?
 Thanks

One way would be to assume that 1 character takes 1 byte to store so...
  $sizeinbytes = strlen($field);

Obviously the amount of disk space that your database server takes to
store the field is going to vary from this so if you need to know that
exact value you will have to look for a function within your database that
will calculate it for you.

HTH,

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] get size of variable n bytes

2003-07-16 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Wed, 16 Jul 2003 at 15:31,
lines prefixed by '' were originally written by you.
 One way would be to assume that 1 character takes 1 byte to store
 so...
   $sizeinbytes = strlen($field);

Also, this will only work with text data as numbers types, bool types etc
will be stored differently.

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] get size of variable n bytes

2003-07-16 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Wed, 16 Jul 2003 at 16:35,
lines prefixed by '' were originally written by you.
 Yes, well, that complicates things.
 You see, I'm trying to determine the size that the $_POST variable
 will be
 in bytes, because there is a byte limit in the php.ini file for POST
 variable size, so I was hoping for something easy like
 bytes_size($_POST)...
 Would also be handy to calculate how much memory your script will
 use/need.
 So, you say there is no such function or no way to determine it?

The POST data is all sent as text anyway so what I said about assuming 1
character = 1 byte will be the best way of calculatuing the size of the
entire request (remember to include all variable names, ?,  and =
characters as well though).

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] PHP explodes without using isset()

2003-07-16 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Wed, 16 Jul 2003 at 17:37,
lines prefixed by '' were originally written by you.
 I've tried checking if $_POST and $_GET vars are set with just
 if($_POST['yuck'])
 When 'yuck' is not present my code always explodes with
 *Notice*: Undefined index: yuck on the page output.
 I never see any mention in the codes examples referencing a php
 function that instructs the preprocessor not to output
 such messages, but I've seen this used a lot of places.
 I'm forced to use isset() with everything.  Now, if there is
 a switch to set in php.ini, this will do my no good since I
 only have access to it on my dev box.  Am I missing out
 on something here, or do people just accept such messages (doubt it).

If you have error reporting set to E_ALL this is the expected behaviour
as you are trying to utilise an array index that does not exist.  It is
the better coding style to check the variable with isset() but if you do
not want to do that you will have to turn down error reporting.

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] PROBLEMS WITH STRINGS SQL DATABASE

2003-07-16 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Thu, 17 Jul 2003 at 01:13,
lines
prefixed by '' were originally written by you.
 This my problem:
 I have this insert statement in my code that works fine for all
 strings
 except strings that include the following characters:
 ' 

Have yo escaped the data correctly for the database server that you are
using?

For example, if you are using mysql, do this to any sata you intend to use as
data within fields in the query:
$data = mysql_escape_string($data);
or generally, this should also work:
$data = addslashes($data);

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Need Help: Please click on Test Link

2003-07-16 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Thu, 17 Jul 2003 at 02:02, lines
prefixed by '' were originally written by you.
 I need your help.
 Can you please visit a site
 http://sspsoft.com/test/ip2ll.php (in case if you cannot get it,
 please
 click on http://ns1.webhostdns.us and then click on the website link.)
 which should identify your Country, State, City. Please click on one
 of the
 buttons to provide feedback.
 I am trying to get hits from different parts of the world to make sure
 that
 it works.
 Planning to develop a webservice from this.

Did not work for me, it was just blank.  I use the free IP to country database
at http://ip-to-country.com whenever I need country stats and I have never had
a problem with it (obviously never rely on results from a database like this to
make your site work correctly though and let the user override the country
settings if it effects how they can use your site).

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] socket programming

2003-07-15 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 15 Jul 2003 at 09:33,
lines prefixed by '' were originally written by you.
 Hi to all,
 Is it possible to run php in the web running in a specified port
 without
 installing apache in Linux?
 Can anyone give a sample code for this? I'm searching this for a week
 but i
 really can find one. Please help us.

You could use inetd and the command line PHP binary. How to do it varies
between linuz distros, basically it allows you to assign a port number to
any program in the system and all the program has to do is send it's
output to the standard output (use echo in the case of PHP).

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] variable sized arrays global vars - another newbie question

2003-07-15 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 15 Jul 2003 at 15:19,
lines prefixed by '' were originally written by you.
 Can i ask another question? What if i want to increment a global
 counter from within a function. at the moment i am trying to declare
 the variable normally:
 $counter=0;
 then within the function:
 function (){
 global $counter;
 $counter++;
 but then when i go to echo $counter outside of the function its value
 hasnt changed?

For me, the following code:

===
$counter=0;

function IncCounter(){
global $counter;
$counter++;
}

IncCounter();
echo $counter; // 1 is displayed
===

works fine, maybe it is a problem with your particular code?

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] simple imap functions

2003-07-15 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 15 Jul 2003 at 20:49,
lines prefixed by '' were originally written by you.
 Does anyone have any good examples of simple imap functions?
Basically
 am just looking to return the number of new messages for a few folders
 my account. I would like to modify it later to show the headers (from,
 subject) but just a new message count is sufficient.
 I would like to have this in a page that refreshes every 20-30 seconds
 so, will there be any problems with this?

You could compile PHP with the IMAP functions and use them:
http://uk2.php.net/imap

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] How can I display an image within a script?

2003-07-15 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 15 Jul 2003 at 21:14,
lines prefixed by '' were originally written by you.
 Ok, assuming that the image files are outside the public web tree and
 you can read them with a script. You will have to write a php script
 that will read the file (sending the appropriate headers).
 So your script will generate html like
 img src=/showimage.php?file=filename.jpg
 then showimage.php will do something:
 header('content-type: appropricate/type');
 // content-length would be good
 readfile($file);

My addition to this advice would be to make sure you do some sort of
validation of $_GET['file'] before you use it within the readfile()
function or you have a security problem.  For example people could send a
request for /showimage.php?file=yourscript.php and they would be
presented with the source code to your PHP script.

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Exec command not working through php

2003-07-15 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 15 Jul 2003 at 21:30,
lines prefixed by '' were originally written by you.
 I have the following exec command in php:
 exec(/bin/sed -f $GLOBALS[TMP_MAIL_DIR].cmdfile
 $GLOBALS[TMP_MAIL_DIR].$mailid 
 $GLOBALS[TMP_MAIL_DIR].$mailid.tmp,$results);
 Which does a search and replace using the sed command file:
 s/'/'/g
 s///g
 Now, executed command line, this works beautifully, the input file is
 parsed
 and the results go to the output file - BUT when run via php, the
 output
 file is blank, empty, no data at all.
 Permissions are not the problem, I went so far as to 777 the directory
 and
 file, still the same results.
 Running PHP 4.1.2 on Linux Redhat something or another.
 I am sure that it is something simple, but it is driving me crazy!
 Oh, and yes, globals are on here - if I print out the exec line with
 the
 dynamically generated paths, etc, then execute that through the
 terminal, no
 problem.
 If anyone has run into this with exec commands before or can suggest a
 different way to run this command, I would love to hear it!

Put this line of code in your script:

echo /bin/sed -f $GLOBALS[TMP_MAIL_DIR].cmdfile
$GLOBALS[TMP_MAIL_DIR].$mailid 
$GLOBALS[TMP_MAIL_DIR].$mailid.tmp;

and check that it contains what you expect it to.

All the best,

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Exec command not working through php

2003-07-15 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Tue, 15 Jul 2003 at 23:17,
lines prefixed by '' were originally written by you.
 if I print out the exec line with the
 dynamically generated paths, etc, then execute that through the
 terminal, no
 problem. 
 From the first email meaning that I did just like you suggested
 already and
 it works in the terminal and contains exactly what I expect it to.
 But thanks :)

Sorry, I jumped over that in your original mail! I amy as well try and be
of help again then...

Does the user on the system that your webserver runs as have permission to
execute the program you are trying to execute?

Do you expect the program to have any output, if so is it appearing in
your $results array? is anything being put in the $results array?

Also, you could try using the third optional paramater for the exec
function to retrieve the return status of the command you are executing.

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] socket programming

2003-07-15 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Wed, 16 Jul 2003 at 01:34,
lines prefixed by '' were originally written by you.
 I've already opened opened port for
 this as
 what David said  but i cant see the output in the web.
 He'res what i've did in my Redhat linux 6.x
snip
 Am I in a right track? or is it possible with this? Do i missed
 something
 here?

I am not very familiar with *nix administration at all so if anyone wants
to jump in and correct anything I have said wrong feel free.

Maybe try and have the command inetd is set to execute as
/usr/local/bin/php -q /usr/local/mikecarel/samples
instead of using a shebang line and having your PHP file executable and
see if that works?

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] BigEndian to integer

2003-07-14 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Mon, 14 Jul 2003 at 09:00,
lines prefixed by '' were originally written by you.
 A bit off topic
 Im trying to figure out how to convert BigEndian byte words to
 integers.
 For example -
 0 0 0 18  =  18
 The only way I know how to convert this is by writing down on paper,
 and
 writing  8 4 2 1 above the numbers and adding up the values.

Never heard of a BigEndian number beofre, but this should do it...

function BigEndiantoInt($bigendian){
$bits = split( ,$bigendian);
$bits = array_reverse($bits);
$value = 0; $columnvalue = 1;
foreach($bits as $thisbit){
$value = $value + ($columnvalue * $thisbit);
$columnvalue = $columnvalue * 2;
}
return $value;
}

HTH

David

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] How do I dump a blob or text into a mySQL Database?

2003-07-14 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Mon, 14 Jul 2003 at 18:48,
lines prefixed by '' were originally written by you.
 I'm trying to split up a file and dump it into a mySQL database BLOB.
 Wherever I run the query:
 mysql_query(INSERT INTO table (field) VALUES ('{$buffer}'));
 Nothing ever shows up in the table whethere field is a text or a
 blob
 and whether I dump in text or binary.  Oddly enough when I run the
 query
 I get no error, and can print it and run it through a mySQL terminal,
 and it works.

Change your line of code to something like this:
mysql_query(INSERT INTO table (field) VALUES ('{$buffer}')) or
die(mysql_error());
to find out what is going wrong.

Has the data in $buffer been escaped, reay to go straight into the
query? if not add the line:
$buffer = mysql_escape_string($buffer);
beofre the one that you mentioned above.

HTH

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Eval var from query

2003-07-14 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Mon, 14 Jul 2003 at 20:03,
lines prefixed by '' were originally written by you.
 How can I evaluate a var that is from a text field of a database?
 Example:
 MySQL field `name` = hi my name is $name
 In my script I have:
 $name = Shawn;
 After fetching a query result as an associative array I have the
 contents of
 the `name` field in $data
 If I echo $data I get:  hi my name is $name
 I would like to get:  hi my name is Shawn

Use eval($data)

See http://uk.php.net/eval for more info.

All the best,

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] What is wrong??????

2003-07-14 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Mon, 14 Jul 2003 at 19:58,
lines prefixed by '' were originally written by you.
 Every time i run this script i got this error:( my apache server is
 very well cofigured)
 Warning: Cannot send session cookie - headers already sent by (output
 started at c:apachehtdocsproiect_gsmlogin.php:11) in
 c:apachehtdocsproiect_gsmlogin.php on line 81

Can't see any problem within the snippet that you posted, check that you
do not output anything at all anywhere above the snippet that you posted
or in any included files before the session_start(); line.  You may have
accidentally sent a space or a newline if ?php isn't at the very
beginning of all of your files.

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Eval var from query

2003-07-14 Thread David Nicholson
Hello,

This is a reply to an e-mail that you wrote on Mon, 14 Jul 2003 at 20:15,
lines prefixed by '' were originally written by you.
 eval($data)
 returns Parse error: parse error, unexpected T_STRING in
 C:appsapache2htdocstestquery.php(23) : eval()'d code on line 1

What are the exact contents of data?

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Replacing newlines (n) with smething else

2003-07-13 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Sun, 13 Jul 2003 at 23:12,
lines prefixed by '' were originally written by you.

Maybe the browser you are using to fill in the form field is using a
different type of line break. Although I have never seen it done, r by
itself can be used to cause a line break and if that is being done your
code will not be detecting it.

David

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Unknown Syntax

2003-07-11 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Fri, 11 Jul 2003 at 13:55,
lines prefixed by '' were originally written by you.
 Does anybody recognize this:
 !==
 with 2 '='
 Ive known != to mean not equal to but i'm just looking at someone
 elses
 script and they use this instead. Does anyone know if this works or
 any
 problems with it?
 Cheers

This compares type as well as content, for example:
2 !== 2 evaluates to true but
2 != 2 evaluates to false

David.


--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Writing to files

2003-07-11 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Fri, 11 Jul 2003 at 19:56,
lines prefixed by '' were originally written by you.
 Is there a way to write to a beginning of a file without it
 overwriting
 data that's already there or do I have to write to the end of the file
 in order to preserve data?  I ask because it would be much easier to
 print the lines of the file out in order of last added first if I
 could
 add lines at the top of the file.

Not without reading the entire file into a variable first then appending
that variable to the data you wish to add and saving the entire file again
(which will obviously take longer than appending to the end of the file).

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Writing to files

2003-07-11 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Fri, 11 Jul 2003 at 20:37,
lines prefixed by '' were originally written by you.
 Any ideas on how I can print the lines of my file in reverse order,
 then?

How about...

$fp = fopen(yourfile.txt,r);
$filecontents = ;
while(!feof($fp)){
$filecontents.=fgets($fp,1024); // read entire file into
$filecontents
}

$filelines = split(\n,$filecontents); // split file into individual
lines

for($i=(count($filelines)-1);$i=0;$i--){ // loop through array in
reverse order
echo $filelines[$i] . \n;
}

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Get previous folder

2003-07-10 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Thu, 10 Jul 2003 at 13:04,
lines prefixed by '' were originally written by you.
 Anyone know how I can stip off the end of a folder location, so that
 it will
 be a folder in the next level up?  I want to turn something like
this:
 /path/to/folder/MyFolder/
 into somthing like this:
 /path/to/folder/
 I just need to strip off the last folder and that is it.  Can anyone
 help me
 out?  I appreciate it.  Thanks.
 Matt

Try

$folder = /path/to/folder/MyFolder/;
$upOneLevel = dirname($folder); // $folder now contains
/path/to/folder/

For more info look at:
http://uk2.php.net/manual/en/function.dirname.php

HTH

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] newbie array question

2003-07-10 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Thu, 10 Jul 2003 at 15:30,
lines prefixed by '' were originally written by you.
 If i have a valid sql query that returns three the records
 'john','jack' and 'mary' and i want to put that into an array where
 array[0]-john,array[1]-jack etc how do i do this? Im trying to use
 sybase_fetch_array as follows:
 $query = select name from names (where age '23'');
 $numero= sybase_connect(database , user , password )
 or die (Unable to connect to database server);
 $result=sybase_query($query,$numero );
 $names=sybase_fetch_array($result);

sybase_fetch_array will fetch one row of the result, if you want all
three rows in one array you will need something like this...

$allnames = array();
while($thisname = sybase_fetch_row($result)){
$allnames[] = $thisname[0];
}

I have never used the sybase db functions though so I may be incorrect.

All the best,

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] nlist

2003-07-10 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Fri, 11 Jul 2003 at 00:17,
lines prefixed by '' were originally written by you.
 Is there a local filesystem-based function comparable to the ftp-based
 'nlist' that lists files in a directory?
 Johnny

In PHP 5 you can use scandir()
http://uk.php.net/manual/en/function.scandir.php

In lower versions AFAIK you will have to use the system function to call
either ls (on *nix) or dir (on windows).

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Antithesis to array_unique

2003-07-09 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Wed, 9 Jul 2003 at 14:55,
lines prefixed by '' were originally written by you.
 Having STFM I am wondering if anyone knows of a quick antithesis to
 array_unique? We have an array in which we need to return all
 duplicate
 values instead of the non-duplicates.=20

How about:

$array1 = array(dupe,dupe,another item);
$valuecount = array();
foreach($array1 as $value){
if(isset($valuecount[$value])){
$valuecount[$value]++;
} else {
$valuecount[$value] = 1;
}
}
$dupes = array();
foreach($valuecount as $value=$count){
if($count1){
array_push($dupes,$value);
}
}
// $dupes now contains all duplicate values.

There may be a quicker way of doing it though...

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] linking with home directory path

2003-07-09 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Wed, 9 Jul 2003 at 12:51,
lines prefixed by '' were originally written by you.
 // Path to script files (absolute file path)
 $HomeDir = c:/inetpub/wwwroot/MyScript/;
 // Name of style folder
 $ThemeFolder = default;
 //-Then later in the page, I link the style sheet like this ---//
 echo 
 link rel='stylesheet' type='text/css'
 href='.$HomeDir.themes/.$ThemeFolder./style.css'

Doing this will mean that your script will only work correctly when viewed
on webserver computer.  Remote browsers will not be able to access the
style sheet as you are referencing it as a file on your server machine.
Is this what you intended?

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Returning values from functions

2003-07-09 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Wed, 9 Jul 2003 at 23:40,
lines prefixed by '' were originally written by you.
 auth_user($_SESSION['login']);
 var_dump($username);

You are not collecting the value that your function returns. Try:
$username = auth_user($_SESSION['login']);
var_dump($username);

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] proxy... of a sorts.

2003-07-09 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Thu, 10 Jul 2003 at 00:14,
lines prefixed by '' were originally written by you.

Just a few things I picked up on while scanning your code...

   $alltext = ereg_replace('img src='.$web, 'img src=',
$alltext);

Some parts of the URL will be case insensitive i.e. the domain name and
protocol. The lazy way around this is to just use a case insenstive
regular expression here.

   $alltext = ereg_replace('img src='.$web, 'img src=',
$alltext);
   $alltext = ereg_replace('img src= ', 'img src=',
$alltext);
   $alltext = ereg_replace('img src =', 'img src=',
$alltext);
   $alltext = ereg_replace('img src = ', 'img src=',
$alltext);
   $alltext = ereg_replace('img src=', 'img
src='.$iproxy.$web.'/',
 $alltext);

This could all be done in one line, something like...
/(img.+src)( )*(=)( )*([\'])?($web)([^ ']).*()/i
but it is getting late here so that proably won't work exactly like that.

Also check for a BASE HREF= tag, this can be used to set the first
part of the URL for any links, pictures etc that are not referenced by a
full URL anywhere in the page.

 /*IMAGE.PHP*

You may want to record the headers the remote server gives you for the
images and send them on, or take a guess at them from the file name and
send them using the header() function.

All the best,

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] how to force variables declaration??

2003-07-08 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Wed, 9 Jul 2003 at 02:10,
lines prefixed by '' were originally written by you.
 hi to all.
 i would like to know how to force to php to declare everything
 variable,
 example
 var $var;
 $var = bla,bla..
 var $var2 = array();
 $var2 = bla,bla..
 and issue error when a variable is instanced without declare, some
 idea???:

Check out:
http://uk2.php.net/error_reporting

You want to use E_ALL to do what you described.

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] echo not working!!!

2003-07-06 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Sun, 6 Jul 2003 at 16:57,
lines prefixed by '' were originally written by you.
 ?php echo (h1PHP is running./h1); ?
 it displays the string AND the closing double quote, paren, semicolon,
 question mark, and  on a new line.  What the hell is going on here?
 PHP is running.
 );?

At a guess I would say that your PHP is not being parsed as PHP, if you
view the source of your output you will probably see ?php echo
(h1PHP is running./h1); ? but your browser is treating ?php
echo (h1PHP is running./h1 as a tag that it does not understand and
displaying the ); ? as text.

If this is the case you need to check your httpd.conf.

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] __FILE__ plus variables?

2003-06-28 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Sat, 28 Jun 2003 at 13:16,
lines prefixed by '' were originally written by you.
 I have a password protected site. If you go to an inside page before
 logging in, it redirects you to the log in page. I would like to grab
 the URL that a user tries to access and send them back there after
 they
 log in. I'm using __FILE__ to get the file name (secondary.php
for
 example) but that doesn't return the variables
 (secondary.php?cat_id=267). Is there a way for me to get the full
URL
 not just the filename?
 Sam

Using my Apache installation it is in $_SERVER['REQUEST_URI'].

At a guess I would say most other web servers will put it there too.

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] print array

2003-06-27 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Fri, 27 Jun 2003 at 12:10,
lines prefixed by '' were originally written by you.
 I would off course like it even better when i was able to print to the
 values
 (word and number) in an HTML table structure, or each new word on a
 new line
 for instance, and without the [ ]  and =. Is this possible, and if
 so, how
 do i solve this?

See www.php.net/foreach

echo TABLE\n;
foreach($yourarray as $word=$count){
echo TRTD$word/TDTD$count/TD/TR\n;
}
echo /TABLE\n;

HTH

David.


--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] SORRY

2003-06-27 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Fri, 27 Jun 2003 at 14:08,
lines prefixed by '' were originally written by you.
 i'm really sorry i have to send this email to the php list.
 I received a reply to my email about printing the elements in an array
 an html table structure, i believe by someone called daniel.
 i accidently deleted your message, before i had copied your idea
 So, to the person who was so kind to help me with my problem, could
 you PLEASE
 send me that email again!?

I replied to you, and all my replies are copied to the group so you can
find it again in the groups archive at:

http://marc.theaimsgroup.com/?l=php-generalm=105671320623391w=2

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] q: extract() and get_defined_vars()

2003-06-27 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Sat, 28 Jun 2003 at 01:41,
lines prefixed by '' were originally written by you.
 If I call extract() inside of a function, then the variables it
 creates will
 be local to that function, correct?  OK, so, is there a way to get
 extract()
 to define those variables as global, from within a function?

Yes it is, you must tell the function to treat the relevant variables as
globals though, here is a way of doing it:

function Foo(){
$theArray = array('var1'='testing', 'var2'='testing2');
foreach($theArray as $varname=$value){
global $$varname;
}
extract($theArray);
}

Foo();
echo $var1BR /$var2;

The above code outputs testingBR /testing2.

All the best,

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] q: extract() and get_defined_vars()

2003-06-27 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Sat, 28 Jun 2003 at 02:01,
lines prefixed by '' were originally written by you.
 Pretty sneaky.  But at this point, why bother with the extract() at
 all?
 wouldn't this do the same thing:
 function Foo(){
 $theArray = array('var1'='testing', 'var2'='testing2');
 foreach($theArray as $varname=$value){
 $GLOBALS[$varname] = $value;
 }
 Which is what I am already doing...

Yes, good point.  Also that avoids using variable variables which produces
much easier to read code.

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] twodimensional array / word-frequencylist

2003-06-26 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Thu, 26 Jun 2003 at 12:26,
lines prefixed by '' were originally written by you.
 # i would like a similar function that removes interpuntuation like
 . etc.
 # all i want remaining in the array are the separate words, all in
 lower
 case

This is not tested but should work:
$words = preg_split(/[^A-Z0-9]/i,$originaltext);

 # i would like a function that pushes this word into a second array.
 # before pushing, it has to check whether or not the same word is
 already
 in the array.
 # if it is: do not push word into array, but add 1 to the number of
 occurrences
 of that word
 # if it is not: push this new word into array
 # all of this has to result into a word - frequency array (content
 analysis
 of free text)
 # question 1: how do i produce such an array?
 # question 2: how do i get the two elements (word and number of
 occurrences)
 # together out of the array and print them to the screen?
 # f.e.: the word computer occurred two times in this text.

Try using the words as the key to the array and the number of times it
occoured as the value, so...

foreach($words as $thisword){
if(in_array($thisword, $array)){
$array[$thisword]++;
} else {
$array[$thisword]=1;
}
}

foreach($array as $word=$count){
echo The word $word occoured $count times\n;
}

HTH

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] twodimensional array / word-frequencylist

2003-06-26 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Thu, 26 Jun 2003 at 12:36,
lines prefixed by '' were originally written by you.
 foreach($words as $thisword){
 if(in_array($thisword, $array)){
 $array[$thisword]++;
 } else {
 $array[$thisword]=1;
 }

Just realised my own mistake...

The if statement shoud be if(isset($array[$thisword])) as the word is the
key and not a value in the array.

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] default time

2003-06-25 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Wed, 25 Jun 2003 at 15:30,
lines prefixed by '' were originally written by you.
 Hi everyone, I want to assign the current time to a variable.
 Currently
 I am using:
 $myTime = time()
 But this displays the time as:
 1056551047 when it is in fact 15:25
 How do I get the proper format for time? I looked on the web site but
 couldn't understand any of it :(
 Thanks in advance

Take a look at www.php.net/date and all will be explained.

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Generating Message-ID when sending messages

2003-06-25 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Wed, 25 Jun 2003 at 23:11,
lines prefixed by '' were originally written by you.
 I am trying to make it so that my PHP script generates it's own
 Message-ID's when sending mail through Sendmail. For some reason
 it is not working as I hoped. I have tried the mail() command by
 using:
 mail([EMAIL PROTECTED],Subject,message,Message-ID:
 [EMAIL PROTECTED]);
 That doesn't seem to work when I look at my e-mail client it seems
 to have it's own message-id for the e-mail i sent, can anyone help
 me on this?

Maybe it is the MTA on your system that won't allow this, or if you are
using a relaying SMTL server maybe that is forcing it's own message ID for
some reason.  I have used the method you described to add message IDs to
e-mails in a number of PHP applications both on Windows (using a relaying
SMTP server) and on FreeBSD (using sendmail).

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Command line php output redirection.

2003-06-25 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Wed, 25 Jun 2003 at 23:48,
lines prefixed by '' were originally written by you.
  php parser.php  temp
  temp only contains
  Content-type: text/html
  X-Powered-By: PHP/4.3.2

Maybe try using the -q parameter? what do you get then?
  -q   Quiet-mode.  Suppress HTTP Header output.

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



  1   2   >