php-general Digest 27 Oct 2002 05:26:21 -0000 Issue 1668

Topics (messages 121529 through 121576):

Re: passthru problems generating WAVs with mpg123
        121529 by: Justin French

Re: upload files
        121530 by: Chad Cotton

PHP Manual Book
        121531 by: Stephen
        121539 by: Jason Wong

Re: mysql_fetch_row options
        121532 by: Monty

Re: parsing conundrum
        121533 by: Monty

Re: extract($_POST)
        121534 by: Monty
        121535 by: Monty
        121546 by: John W. Holmes
        121552 by: Monty
        121555 by: John W. Holmes
        121556 by: Monty
        121558 by: John W. Holmes
        121564 by: Monty
        121567 by: John W. Holmes
        121570 by: . Edwin

Mail Delivery errors when posting here ???
        121536 by: Monty

Problem with session and register_globals=off
        121537 by: Alexandre
        121543 by: John W. Holmes

Problem wih Session and register_globals
        121538 by: Jacques Marques

Problem with Session and register_globals
        121540 by: Jacques Marques

Re: Best way to set global params for entire site??
        121541 by: Lance Lovette

Re: <script language=php???
        121542 by: John W. Holmes
        121544 by: John Nichel
        121565 by: Jason Porembski
        121568 by: John W. Holmes
        121574 by: Chris Garaffa

Getting the "From: [EMAIL PROTECTED]" to work
        121545 by: Andre Dubuc
        121547 by: John W. Holmes
        121548 by: John Nichel
        121549 by: Andre Dubuc
        121550 by: Monty
        121551 by: David McInnis
        121553 by: dwalker
        121554 by: John Nichel

blogger with ODBC support?
        121557 by: jaxon

Re: php and databases
        121559 by: Andrew Hill

Referral Site...
        121560 by: Ken Kirtley
        121561 by: eNetwizard Developers Team
        121562 by: Monty

Question!
        121563 by: Trasca Ion-Catalin
        121569 by: Justin French

Flash / PHP Question
        121566 by: Stephen
        121572 by: . Edwin

Sessions Sessions. Lovely Sessions.
        121571 by: Mohamed S.

predifined functions
        121573 by: DaRk--ObJeCtS
        121575 by: Jason Wong
        121576 by: Justin French

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
I'm SURE you've got a good reason, but why are you wanting to generate a WAV
on demand?  The loss in file quality occurs going from WAV > MP3, so then
later going back to WAV would only result in a bigger file size, with ZERO
benefit in audio quality.

Just asking :)


Justin


on 26/10/02 4:53 PM, [EMAIL PROTECTED] ([EMAIL PROTECTED]) wrote:

> I've written a little script for VoiceXML applications to generate a WAV
> from an MP3 on demand:
> 
> #file wavwrapper.php
> <?
> header('Content-Type: audio/wav');
> $filename = $_GET['filename'];
> 
> $mp3dir="/var/www/mp3s/";
> $playercmd="/usr/local/bin/mpg123 -m -w - -q -4 --8bit";
> passthru("$playercmd $mp3dir/$filename 2> /tmp/playererror");
> ?>
> 
> 
> I request it as wavwrapper?filename=song.mp3, and the browser reads the
> MIME type properly, prompts me to play or download the song.  I download
> it, and save it as a WAV file.  However, Mozilla downloads about 1.5M of
> data, saves it all to a file, and then displays the downloaded size as
> 1k.  And then when I try to play it back, it won't play; it's like an
> empty file.  Same thing happens if I try to play it directly.  But if I
> redirect the output of mpg123 from standard out (so it goes across the
> web connection) to a file and then download the file, the file plays
> just fine.  I figure there's something to do with the way PHP dumps back
> the binary data that just isn't working right, but I don't know what it
> is.  Anyone have any ideas?

--- End Message ---
--- Begin Message ---
I just wrote a file upload script and all the information that I needed was
here in the manual:

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

There were a couple of "common pitfalls" that it points out, which you
should check.  Make sure you've defined the various configuration variables
'correctly'  some are:
upload_files
upload_tmp_dir
upload_max_filesize
and post_max_filesize

also check your form to make sure you have an input defined for
MAX_FILE_SIZE and that in the <form ... > tag you have the proper encoding.
My form used '<form enctype="multipart/form-data"  >' and this made a
difference.  Something worth checking.

Chadly


"Cyrille Andres" <[EMAIL PROTECTED]> wrote in message
news:FA432D4D6C2EC1498940A59C494F1538035E2860@;stca207a.bus.sc.rolm.com...
>
>
>
>  Hello everybody,
>
>
> I want to allow the client to upload a text file on my web server, so I
use
> this code :
>
> <html>
> <head></head>
> <body>
> Uploaded files details<br>
>
> <?php
> printf("Name : %s <br>", $HTTP_POST_FILES["userfile"]["name"]);
> printf("Temporary Name : %s <br>",
> $HTTP_POST_FILES["userfile"]["tmp_name"]);
> printf("Size : %s <br>", $HTTP_POST_FILES["userfile"]["size"]);
> printf("Type : %s <br>", $HTTP_POST_FILES["userfile"]["type"]);
>
> if (copy
>
($HTTP_POST_FILES["userfile"]["tmp_name"],"temp/".$HTTP_POST_FILES["userfile
> "]["name"]))
> {
> printf("File successfully copied");}
> else{
> printf("Error: failed to copy file");}
>
>
> ?>
>
> </body>
> </html>
>
> the $http_post_files doesn't return me anything, anybody would have a clue
> ?? ( roughly speaking I am not able to retrieve the field the client try
to
> send me).
>
> Thanks a lot.


--- End Message ---
--- Begin Message ---
Hello,

I was just wondering if the entire PHP manual at php.net was published into a book or 
not. I was going to print it out once but it turned out to be about 1000+ pages...

Thanks,
Stephen Craton
http://www.melchior.us
http://php.melchior.us
--- End Message ---
--- Begin Message ---
On Sunday 27 October 2002 02:45, Stephen wrote:
> Hello,
>
> I was just wondering if the entire PHP manual at php.net was published into
> a book or not. I was going to print it out once but it turned out to be
> about 1000+ pages...

It would be out of date as soon as it's published and before it even gets to 
the shops!

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
Bradley's Bromide:
        If computers get too powerful, we can organize
        them into a committee -- that will do them in.
*/

--- End Message ---
--- Begin Message ---
I use the following function to do this...

function countRecords($query, $dbcon=0) {
    if ($dbcon==0) { $ dbcon = connDbase(); }
    $query = "SELECT COUNT(*) ".$query;
    $res = mysql_query($query, $ dbcon);  // Query DB.
    return mysql_result($res, 0, "count(*)");
}

Here's how it's used:

$count = countRecords("FROM mydb WHERE id = 1001");

All I have to do is provide the query starting with FROM as the function
creates the SELECT COUNT(*) part. Also, the optional second parameter is to
pass the database connection resource ID to the function if I've already
established one before calling this function. This prevents the function
from having to establish a second DB connection for the count. If the second
param is left empty then a DB connection will be made using another
function: connDbase().

$count will contain the number of records that match the query and only
requires me to type one line of code.

Monty


> From: [EMAIL PROTECTED] (James Taylor)
> Newsgroups: php.general
> Date: Sat, 26 Oct 2002 03:23:23 -0700
> To: <[EMAIL PROTECTED]>
> Subject: mysql_fetch_row options
> 
> There's got to be a better way to go about this: I am constantly doing mysql
> queries where I am doing
> a count(), so a sample query would be like this: "select count(*) from
> database".  I'm expecting only
> ONE value back exactly, and that's the count results.  However, to get this
> data into a variable, i'm
> having to write code like this:
> 
> $result = mysql_query("select count(*) from database", $db);
> $myrow = mysql_fetch_row($result);
> $staticvar += $myrow[0];
> 
> $staticvar will never be an array, it's just a simple variable storing a
> number.  I *could* do it like this:
> 
> $result = mysql_query("select * from database", $db);
> $staticvar += mysql_num_rows($result);
> 
> However, the mysql query will be much, much slower if I do it like this.
> 
> Basically, what I'm asking, is how to do something like:
> 
> $staticvar += mysql_fetch_row($result);
> 
> I want to eliminate step two, and I don't want to involve any temporary
> arrays when there's always just one
> value.  Any suggestions? Thanks a bunch!
> 

--- End Message ---
--- Begin Message ---
I'm not attempting to solve this puzzle, but, regarding the output from
print_r(), try this for nicely formatted output:

echo "<pre>";
print_r($myarray);
echo "</pre>";

Looks much better.

Monty


> From: [EMAIL PROTECTED] (Peter Harkins)
> Newsgroups: php.general
> Date: Sat, 26 Oct 2002 02:37:51 -0700
> To: [EMAIL PROTECTED]
> Subject: parsing conundrum
> 
> If you know what recursion is and like a challege, here's a puzzle
> to keep you up nights. If not, you'll probably just want to mutter to
> yourself "what a poor, unlucky bastard" and pass on by.
> 
> I'm parsing some data files into a PHP array and am stumped. I'm at
> a loss for how to do this without grinding through character by character.
> That would work, but my subconcious is nagging at me that there's got to be
> a more elegant way to do it that I'm just not seeing, so I'm going to
> describe the problem and ask for help before I start grinding.
> 
> The app I'm getting this from has 4 data types: int, string, array
> and mapping (associative array).
> 
> Ints and strings are pretty straightforward, but there's no way to
> tell 0 from null int or null string. This is an annoying limitation of the
> app that just has to be ignored and dealt with by whatever gets this data
> from us. This (among other reasons) make me glad PHP is weakly-typed.
> 
> Arrays are indexed from 0 and values can mix ints and strings
> freely.
> 
> To start, mappings are arrays indexed by ints or strings. Mappings
> aren't just arrays, though, they have a "width" (which is really a nested
> array that I'm pretty certain is an ugly historical artifact.) Width allows
> multiple values for one key and must be the same for all values in a
> mapping, though the values (both of keys and their values) don't have to be
> of the same type. Mappings can also mix ints and strings.
> 
> The tough part is that arrays and mappings can nest inside of each
> other and the only characters quoted in strings are \, " and \n. This means
> recursion must be used, but I just can't figure out a way to find the
> boundaries of each element. Anyone with a clean way to do this (probably
> with some kind of crazy regexp) will recieve my awe and gratitude.
> 
> Here's an example file[1]:
> 
> null_string 0
> some_string "Fourscore and seven years ago..."
> unset_int 0
> an_int 42
> negative_int -12
> null_array ({ })
> null_mapping ([ ])
> easy_array ({9,22,"test",})
> easy_mapping (["string":3,"foo":"bar",[12]:"I am not a crook!",])
> medium_array ({"a string, containing a comma and a \"",23,})
> medium_mapping (["str\"ing":3;5;7, 9:"Read my lips.";11;13;,])
> hard_array ({"comma, string",({3,4,5,}),({"'\"str'",4,({3,4,({ }),}),}),})
> hard_mapping ([17:"str";15,"foo":([ ]);17,"b'l\\a\nh":19;([21:23,]),"tour de
> force":({29,31});({([ ])}),])
> 
> You may notice the last one is pathological[2]. Yes, PHP will really
> let you use " and \n in array keys. The real data do sometimes get about
> this complex; consider this a compressed version. As a fun fact, I've
> learned vim's % command doesn't work when there's an odd number of double
> quotes between your parens/braces.
> 
> Calling print_r on the array this generates would return:
> 
> Array
> (
> [null_string] => 0
> [some_string] => "Fourscore and seven years ago..."
> [unset_int] => 0
> [an_int] => 42
> [negative_int] => -12
> [null_array] => Array
> (
> )
> 
> [null_mapping] => Array
> (
> )
> 
> [easy_array] => Array
> (
> [0] => 9
> [1] => 22
> [0] => test
> )
> 
> [easy_mapping] => Array
> (
> [string] => 3
> [foo] => "bar"
> [12] => "I am not a crook!"
> )
> 
> [medium_array] => Array
> (
> [0] => a string, containing a comma and a "
> [1] => 23
> )
> 
> [medium_mapping] => Array
> (
> [string] => Array
> (
> [0] => 3
> [1] => 5
> [2] => 7
> )
> 
> [9] => Array
> (
> [0] => Read my lips.
> [1] => 11
> [2] => 13
> )
> 
> )
> 
> [hard_array] => Array
> (
> [0] => comma, string
> [1] => Array
> (
> [0] => 3
> [1] => 4
> [2] => 5
> )
> 
> [2] => Array
> (
> [0] => '"str'
> [1] => 4
> [2] => Array
> (
> [0] => 3
> [1] => 4
> [2] => Array
> (
> )
> 
> )
> 
> )
> 
> )
> 
> [hard_mapping] => Array
> (
> [17] => Array
> (
> [0] => str
> [1] => 15
> )
> 
> [foo] => Array
> (
> [0] => Array
> (
> )
> 
> [1] => 17
> )
> 
> [b'l\a\nh] => Array
> (
> [0] => 19
> [1] => Array
> (
> [21] => 23
> )
> 
> )
> 
> [tour de force] => Array
> (
> [0] => Array
> (
> [29] => 31
> )
> 
> [1] => Array
> (
> [0] => Array
> (
> )
> )
> 
> )
> 
> )
> 
> )
> 
> The truly eagle-eyed will note that print_r doesn't really escape \n
> when outputting, which is ugly and should probably have a bug report filed
> on it. I've ignored this behavior of print_r to produce more readable
> output.
> 
> Anyone who gets the 'tour de force' can contact me for the 'victory
> lap' puzzle if it didn't occur to them while solving this one. It's equally
> frustrating.
> 
> [1] Brownie points to anyone who recognizes the app that outputs this data
> format. Yep, I'm doing web integration. Feel free to contact me off-list if
> you've any ideas/code to share or would like to see what I'm doing. Yes,
> technically, mappings can be indexed by an array or mapping. I've ignored
> this because 1. PHP can't do this and 2. Anyone doing this will be dragged
> out into the street and shot.
> 
> [2] http://tuxedo.org/~esr/jargon/html/entry/pathological.html

--- End Message ---
--- Begin Message ---
> Well, one way you can avoid similar things to happen is, you can do
> something like, say, create a user that can only SELECT. If the user can
> only SELECT then it cannot DELETE.

This is a great suggestion from Rick. I already use this method. I have
several MySQL users set up for various functions: one that can only SELECT,
which is the one I use the most, another that can SELECT, UPDATE and INSERT,
and another that can do all of the following plus DELETE.

Monty


--- End Message ---
--- Begin Message ---
Rick Emery wrote:

> You can still use extract($_POST).
> It is as safe/vulernable as $_POST['isAdmin'].
> 
> In either case, use only variables that you know are yours and be certain
> these contain values which you believe to be safe. For instance, if you expect
> a variable called $firstname to contain a name to be stored in a SQL database,
> be certain it does not contain SQL commands which can damage your database.
> 

Okay, I know I can use strip_tags() and/or htmlspecialchars() to strip out
or modify HTML and PHP code in a string, but, how does one do the same with
MySQL code in a string to prevent tampering?

Monty

--- End Message ---
--- Begin Message ---
> > You can still use extract($_POST).
> > It is as safe/vulernable as $_POST['isAdmin'].
> >
> > In either case, use only variables that you know are yours and be
> certain
> > these contain values which you believe to be safe. For instance, if
you
> expect
> > a variable called $firstname to contain a name to be stored in a SQL
> database,
> > be certain it does not contain SQL commands which can damage your
> database.
> >
> 
> Okay, I know I can use strip_tags() and/or htmlspecialchars() to strip
out
> or modify HTML and PHP code in a string, but, how does one do the same
> with
> MySQL code in a string to prevent tampering?

You pass a string or an number to your query. You have to make sure the
data you're passing is a string, or a number. 

If you're expecting a number, and use a query like:

WHERE id = $id

Then make sure $id is a number. You can use is_int, or (int), or
whatever.

If you're passing a string

WHERE username = '$name'

Then make sure $name has all single quotes escaped within it. If all of
them are escaped, then it's just a string and can't do any harm. If they
aren't escaped, then the user can break out of your own SQL and put
their own.

---John Holmes...


--- End Message ---
--- Begin Message ---
John W. Holmes wrote:
 
> Then make sure $name has all single quotes escaped within it. If all of
> them are escaped, then it's just a string and can't do any harm. If they
> aren't escaped, then the user can break out of your own SQL and put
> their own.

I'm confused about when I should escape single or double quotes. Should all
quotes be stored as \" or \' in a database as well?

Regarding your suggestion above, is this what I should do? ...

    $name = "John AND fname = 'Mary'";

    $name = addslashes($name);

    // $name now holds: "John AND fname = \'Mary\'"

This forces MySQL to read \' as a character rather than as the beginning of
a variable value. So, in essence, this would produce a mySQL error instead
of executing the query, is that correct?

Monty

--- End Message ---
--- Begin Message ---
> I'm confused about when I should escape single or double quotes.
Should
> all
> quotes be stored as \" or \' in a database as well?

Escape both, just use addslashes. The key here is that if you are
inserting a variable into a string (which is all a query is), then you
want to make sure that the contents of that variable don't unexpectedly
terminate the string.

> Regarding your suggestion above, is this what I should do? ...
> 
>     $name = "John AND fname = 'Mary'";
> 
>     $name = addslashes($name);
> 
>     // $name now holds: "John AND fname = \'Mary\'"
> 
> This forces MySQL to read \' as a character rather than as the
beginning
> of
> a variable value. So, in essence, this would produce a mySQL error
instead
> of executing the query, is that correct?

It depends on what you're doing with $name. Remember, you're just
creating a string that has to be logical when it's sent to MySQL

SELECT * FROM table WHERE name = '$name'
SELECT * FROM table WHERE name = "$name"

Either way you do it, you want to make sure that the contents of $name
don't have a quote that'll end the name string. 

If you have

$name = "John AND fname = 'Mary'";

and you don't escape quotes, then you have a query like

SELECT * FROM table WHERE name = 'John AND fname = 'Mary'
SELECT * FROM table WHERE name = "John AND fname = 'Mary'

Where the first one will cause an error and the second one will just not
match any rows, more than likely.

If you have

$name = "John' AND fname='Mary";

and you don't escape quotes, you'll get

SELECT * FROM table WHERE name = 'John' AND fname='Mary'
SELECT * FROM table WHERE name = "John' AND fname='Mary"

Where the first is a valid query and could return rows you didn't
normally intend for it to return. The second will probably not match any
rows again.

Now, don't think that double quotes are any safer. You can change $name
to use double quotes to manipulate the queries, too.

Bottom line is that you want to use addslashes() or magic_quotes_gpc()
on any variable you're going to insert into a query string. If you're
inserting a variable that should be a number, make sure it is one.

---John Holmes...



--- End Message ---
--- Begin Message ---
John W. Holmes wrote:

> Then make sure $id is a number. You can use is_int, or (int), or whatever.

It appears that any numeric values passed via the URL (..?param=10001) are
automatically treated as strings. If I pass ?param=1001 to the following
script...

    $type = '';
    if (is_string($param)) { $type = 'string'; }
    if (is_int($param)) { $type = 'integer'; }
    echo 'Type: '.$type;

... I get the following result:

    Type: string

But, it should be integer because 10001 is meant to be a number. How does
this work for $_GET values?

Monty

--- End Message ---
--- Begin Message ---
> > Then make sure $id is a number. You can use is_int, or (int), or
> whatever.
> 
> It appears that any numeric values passed via the URL (..?param=10001)
are
> automatically treated as strings. If I pass ?param=1001 to the
following
> script...

So turn it into an integer.

$param = (int)$_POST['param'];

It'll be turned into an integer or anything after a string part will be
chopped off.

10001 => 10001
1000f => 1000
f1000   => 0

Validating can be that simple. You may also want to check the range of
the number. Again, validating is unique to your application. What do you
expect the value to be? If the value is XXX, how does that affect my
application?

---John Holmes...


--- End Message ---
--- Begin Message ---
John W. Holmes wrote:
> 
> Bottom line is that you want to use addslashes() or magic_quotes_gpc()
> on any variable you're going to insert into a query string. If you're
> inserting a variable that should be a number, make sure it is one.

If I have magic quotes turned on, do I still need to worry about using
addslashes?

Monty

--- End Message ---
--- Begin Message ---
> > Bottom line is that you want to use addslashes() or
magic_quotes_gpc()
> > on any variable you're going to insert into a query string. If
you're
> > inserting a variable that should be a number, make sure it is one.
> 
> If I have magic quotes turned on, do I still need to worry about using
> addslashes?

No, it's automatic. You may want to program in a check that sees if
magic_quotes is on or off, though, and act accordingly.

---John Holmes...


--- End Message ---
--- Begin Message ---
Or,

You can use this:

  http://www.php.net/manual/en/function.is-numeric.php

- E

"John W. Holmes" <[EMAIL PROTECTED]> wrote:

> > > Then make sure $id is a number. You can use is_int, or (int), or
> > whatever.
> > 
> > It appears that any numeric values passed via the URL (..?param=10001)
> are
> > automatically treated as strings. If I pass ?param=1001 to the
> following
> > script...
> 
> So turn it into an integer.
> 
...[snip]...
--- End Message ---
--- Begin Message ---
For some reason I get the following e-mail every time I make a post here
recently and not sure why:

-------

This message was created automatically by mail delivery software (Exim).

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

  [EMAIL PROTECTED]
    SMTP error from remote mailer after MAIL FROM:
    <[EMAIL PROTECTED]> SIZE=6478:
    host yun.yagibdah.de [192.168.0.1]: 550 rejected:
    administrative prohibition

-------

This is followed by a copy of my posting to the newsgroup which does get
posted. Not sure why it's being rejected and where this is coming from. Any
clues??

Monty

--- End Message ---
--- Begin Message ---
Hello,

When I try the code below and register_globals=On, its work fine, the
counter variable is incremented each time that I load the page, but, when
register_globals=Off, its does not work, the counter variable is save just
in first time and never more.

<?php session_start();
   // register a session variable
   session_register('counter');
   $counter = $HTTP_SESSION_VARS["counter"];
   // increment and display the value of the counter
   $counter++;
   echo("You have visited this page $counter times! Don't you have
   anything else to do, you bum?!");
?>

How can I fix this? With out to turn register_globals=On.

Thanks,


--- End Message ---
--- Begin Message ---
$counter is not related to the session at all with register_globals OFF.
Use $HTTP_SESSION_VARS['count']++;

---John Holmes...

> -----Original Message-----
> From: Alexandre [mailto:alexandre@;cmsmedical.com.br]
> Sent: Saturday, October 26, 2002 2:42 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Problem with session and register_globals=off
> 
> Hello,
> 
> When I try the code below and register_globals=On, its work fine, the
> counter variable is incremented each time that I load the page, but,
when
> register_globals=Off, its does not work, the counter variable is save
just
> in first time and never more.
> 
> <?php session_start();
>    // register a session variable
>    session_register('counter');
>    $counter = $HTTP_SESSION_VARS["counter"];
>    // increment and display the value of the counter
>    $counter++;
>    echo("You have visited this page $counter times! Don't you have
>    anything else to do, you bum?!");
> ?>
> 
> How can I fix this? With out to turn register_globals=On.
> 
> Thanks,
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



--- End Message ---
--- Begin Message ---
Hello,

When I try the code below and register_globals=On, its work fine, the
counter variable is incremented each time that I load the page, but, when
register_globals=Off, its does not work, the counter variable is save just
in first time and never more.

<?php session_start();
   // register a session variable
   session_register('counter');
   $counter = $HTTP_SESSION_VARS["counter"];
   // increment and display the value of the counter
   $counter++;
   echo("You have visited this page $counter times! Don't you have
   anything else to do, you bum?!");
?>

How can I fix this? With out to turn register_globals=On.

Thanks,


--- End Message ---
--- Begin Message ---
Hello,

When I try the code bellow with register_globals=On, it work was expected,
the counter variable is incremented each time that I load the page, but,
when I try with register_globals=Off, it doesn´t work, the counter variable
is incremented just in the first time, the session variable is not update.

<?php session_start();
 // register a session variable
 session_register('counter');
 $counter = $HTTP_SESSION_VARS["counter"];
 // increment and display the value of the counter
 $counter++;
 echo("You have visited this page $counter times! Don't you have
 anything else to do, you bum?!");
?>

How can I fix this?


--- End Message ---
--- Begin Message ---
If you are not running PHP under a Windows platform the most efficient way
to solve your problem is with a PHP extension I developed. It handles
constants and provides a type of persistent variable too. It has been
immensely useful for my projects.

http://pwee.sourceforge.net/

Lance

> -----Original Message-----
> From: Monty [mailto:monty3@;hotmail.com]
> Sent: Tuesday, October 22, 2002 3:27 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Best way to set global params for entire site??
>
>
> I'm building a site with PHP and most scripts need access to certain
> site-wide global parameters, such as paths and default settings,
> etc. What's
> the best way to load this information so that it's globally
> available to all
> scripts? I have a func.php file that is included in all scripts -
> do I just
> load them every time for each script in there? Or is there a more
> efficient
> way of doing this with environment variables or some other way?
>
> Thanks!!
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
You can't have both. Either the script is parsed by PHP or it's parsed
by ASP. 

---John Holmes...

> -----Original Message-----
> From: Jason Porembski [mailto:jporembs@;optonline.net]
> Sent: Friday, October 25, 2002 11:30 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] <script language=php???
> 
> Hey folks.  I am attempting to run PHP code with <script
language="php">
> and
> it doesn't work.  Any ideas as to why and how I can fix that?  Also
what
> is
> the best way to run a snippet of PHP code in an ASP page?  Thanks in
> advance.
> 
> Jason "Gluten Mifflin" Porembski
> http://www.world-gaming.com
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



--- End Message ---
--- Begin Message ---
So if you have...

<?php

some code;
some more code;

?>

and

<%

asp junk;
m$ junk;

%>

....it your server will parse both the php and asp code?

Jason Porembski wrote:

Yes it does. But I need the php to work in an ASP page =(
----- Original Message -----
From: "John Nichel" <[EMAIL PROTECTED]>
To: "Jason Porembski" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Saturday, October 26, 2002 12:03 PM
Subject: Re: [PHP] <script language=php???



Does it work when you do it like this....

<?php

some code;
some more code;

?>

Jason Porembski wrote:

Hey folks. I am attempting to run PHP code with <script language="php">

and

it doesn't work. Any ideas as to why and how I can fix that? Also what

is

the best way to run a snippet of PHP code in an ASP page? Thanks in
advance.

Jason "Gluten Mifflin" Porembski
http://www.world-gaming.com











--- End Message ---
--- Begin Message ---
Ok then without asp how do I get <script language="php"> to work?  I
checked out a PHP book today and it did mention running PHP scripts that
way, without a .php extension.

-----Original Message-----
From: John W. Holmes [mailto:holmes072000@;charter.net] 
Sent: Saturday, October 26, 2002 4:28 PM
To: 'Jason Porembski'; [EMAIL PROTECTED]
Subject: RE: [PHP] <script language=php???


You can't have both. Either the script is parsed by PHP or it's parsed
by ASP. 

---John Holmes...

> -----Original Message-----
> From: Jason Porembski [mailto:jporembs@;optonline.net]
> Sent: Friday, October 25, 2002 11:30 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] <script language=php???
> 
> Hey folks.  I am attempting to run PHP code with <script
language="php">
> and
> it doesn't work.  Any ideas as to why and how I can fix that?  Also
what
> is
> the best way to run a snippet of PHP code in an ASP page?  Thanks in 
> advance.
> 
> Jason "Gluten Mifflin" Porembski
> http://www.world-gaming.com
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php




--- End Message ---
--- Begin Message ---
> Ok then without asp how do I get <script language="php"> to work?  I
> checked out a PHP book today and it did mention running PHP scripts
that
> way, without a .php extension.

No, it still has to have a .php extension, or an extension that your web
server recognizes as PHP. The extension is the only way the web server
is going to know to send it though the PHP parser before it returns the
results.

---John Holmes...


--- End Message ---
--- Begin Message ---
On Saturday, October 26, 2002, at 09:45 PM, John W. Holmes wrote:
Ok then without asp how do I get <script language="php"> to work?  I
checked out a PHP book today and it did mention running PHP scripts
that
way, without a .php extension.
No, it still has to have a .php extension, or an extension that your web
server recognizes as PHP.
It might be worth pointing out that this behavior is customizable in any decent HTTP server. I know Apache lets you specify what extensions get parsed by which parser.
Being that you're wanting to use ASP, I'm assuming you're also using IIS. Good luck finding out how to do that.

Your original question (I think, I'm just coming into this thread) was using PHP and ASP in the same page. You can't do that, but this is how close you can get: (Note that it's very inefficient and resource-intensive):
Say you wanted ASP to parse the file first, then PHP. Have the ASP file be called, do your ASP voodoo there, and then call the PHP file (like with a HTTP redirect or form submission). Pass variables back and forth via the querystring.

Not that I'm recommending this. I'm just saying it's possible, if you absolutely have to do it this way.

--- End Message ---
--- Begin Message ---
Perhaps some kind guru can spare me some time. I've tried to get the "From: 
xxxx" field pre-filled for a registration/confirmation email that I send out.

I've managed to get the "To: ' field working great, but no matter where I 
stick the 'From:' code, it doesn't send the email. Any ideas what I'm doing 
wrong? Right now, the "From:'  field is filled with my IP's address -- not 
exactly very cool to see!


Here's the code I've used (POP3):

$mail = $_SESSION['smail'];
$fname = $_SESSION['sfname'];
$sname = $_SESSION['ssname'];
$_SESSION['name_mail'] = "".$fname." ".$sname." <".$mail.">";

/* tried this -- it didn't work 

$reg_first = "Registration";
$reg_last = "[EMAIL PROTECTED]";
$_SESSION['from_name'] = "".$reg_first." <".$reg_last.">";
*/

/* Begin Confirmation Required script */

.... other code

/* Begin MAIL() */


$to = $_SESSION['name_mail'];
$from = "[EMAIL PROTECTED]";  /* I tried this head-on-direct approach -- no go, 
either */
$subject = "Please Confirm Your Registration";

$message = "Thank you for registering as a {$_SESSION['level']} at 
Xsite.com
To complete your registration, please click the 'Confirmation' URL below.
https://www.Xsite.com/all-confirm.php?unique_id={$_SESSION['unique_id']}";

if(@mail($to, $from, $subject, $message))

***********************************************

If I remove the $from everything works but with my IP's 'From: '
Where should the $from variable go in the mail() function?

Any hints or ideas gratefully appreciated,
Tia,
Andre
--- End Message ---
--- Begin Message ---
[snip]
> if(@mail($to, $from, $subject, $message))

Go back to the manual. The parameters for mail are
mail(to,subject,message,headers).

You have to pass the From: address in the headers.

$to = "[EMAIL PROTECTED]";
$subject = "Your email";
$message = "Your email is good";
$headers = "From: [EMAIL PROTECTED]\r\n";

mail($to,$subject,$message,$headers);

Read the manual on other headers you can send. 

---John Holmes...


--- End Message ---
--- Begin Message ---
http://www.php.net/manual/en/function.mail.php

>>if(@mail($to, $from, $subject, $message))

There is no 'from' field.  This must be put in the headers.

Andre Dubuc wrote:

Perhaps some kind guru can spare me some time. I've tried to get the "From: xxxx" field pre-filled for a registration/confirmation email that I send out.

I've managed to get the "To: ' field working great, but no matter where I stick the 'From:' code, it doesn't send the email. Any ideas what I'm doing wrong? Right now, the "From:' field is filled with my IP's address -- not exactly very cool to see!


Here's the code I've used (POP3):

$mail = $_SESSION['smail'];
$fname = $_SESSION['sfname'];
$sname = $_SESSION['ssname'];
$_SESSION['name_mail'] = "".$fname." ".$sname." <".$mail.">";

/* tried this -- it didn't work
$reg_first = "Registration";
$reg_last = "[EMAIL PROTECTED]";
$_SESSION['from_name'] = "".$reg_first." <".$reg_last.">";
*/

/* Begin Confirmation Required script */

.... other code

/* Begin MAIL() */


$to = $_SESSION['name_mail'];
$from = "[EMAIL PROTECTED]"; /* I tried this head-on-direct approach -- no go, either */
$subject = "Please Confirm Your Registration";

$message = "Thank you for registering as a {$_SESSION['level']} at Xsite.com
To complete your registration, please click the 'Confirmation' URL below.
https://www.Xsite.com/all-confirm.php?unique_id={$_SESSION['unique_id']}";

if(@mail($to, $from, $subject, $message))

***********************************************

If I remove the $from everything works but with my IP's 'From: '
Where should the $from variable go in the mail() function?

Any hints or ideas gratefully appreciated,
Tia,
Andre



--- End Message ---
--- Begin Message ---
Thanks John,

I had the maual in front of me, but I didn't understand that you had to put 
the 'From:' stuff in a 'header'. That's why it wasn't working. I presumed 
(wrongly again) that 'headers' were optional, and I got sidetracked by the 
success of the "To:" field.

Thanks for clearing that up.
Regards,
Andre


On Saturday 26 October 2002 04:42 pm, John W. Holmes wrote:
> [snip]
>
> > if(@mail($to, $from, $subject, $message))
>
> Go back to the manual. The parameters for mail are
> mail(to,subject,message,headers).
>
> You have to pass the From: address in the headers.
>
> $to = "[EMAIL PROTECTED]";
> $subject = "Your email";
> $message = "Your email is good";
> $headers = "From: [EMAIL PROTECTED]\r\n";
>
> mail($to,$subject,$message,$headers);
>
> Read the manual on other headers you can send.
>
> ---John Holmes...
--- End Message ---
--- Begin Message ---
Andre Dubuc wrote:

> Perhaps some kind guru can spare me some time. I've tried to get the "From:
> xxxx" field pre-filled for a registration/confirmation email that I send out.

To add to John's reply, here's how to do a multi-parameter Header. Also note
the \r\n at the end of each of these lines. If you don't do this, the header
won't be formatted properly. It took me some time to eventually figure this
out when I first did this because I was using just \n which doesn't work in
the header, but, does work in the body.

 $headers = "From: [EMAIL PROTECTED]\r\n"
           ."Reply-To: [EMAIL PROTECTED]\r\n"
           ."X-Mailer: PHP/4.0.2";

You can also add other mail headers such as 'Importance: High' to the
headers list.

--- End Message ---
--- Begin Message ---
You need to build your header and include that in your mail() call:


 $lc_headers  = "From: $lc_from_name <$lc_from_email>\n";
 $lc_headers .= "X-Sender: <$lc_sender>\n";
 $lc_headers .= "X-Mailer: PHP\n"; // mailer
 $lc_headers .= "Return-Path: <$lc_return>\n";  // Return path for errors
 $lc_headers .= "Mime-Version: 1.0\n";

 mail($lc_recipient, $lc_subject, $lc_message, $lc_headers);


----- Original Message -----
From: "Andre Dubuc" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, October 26, 2002 1:40 PM
Subject: [PHP] Getting the "From: [EMAIL PROTECTED]" to work


> Perhaps some kind guru can spare me some time. I've tried to get the
"From:
> xxxx" field pre-filled for a registration/confirmation email that I send
out.
>
> I've managed to get the "To: ' field working great, but no matter where I
> stick the 'From:' code, it doesn't send the email. Any ideas what I'm
doing
> wrong? Right now, the "From:'  field is filled with my IP's address -- not
> exactly very cool to see!
>
>
> Here's the code I've used (POP3):
>
> $mail = $_SESSION['smail'];
> $fname = $_SESSION['sfname'];
> $sname = $_SESSION['ssname'];
> $_SESSION['name_mail'] = "".$fname." ".$sname." <".$mail.">";
>
> /* tried this -- it didn't work
>
> $reg_first = "Registration";
> $reg_last = "[EMAIL PROTECTED]";
> $_SESSION['from_name'] = "".$reg_first." <".$reg_last.">";
> */
>
> /* Begin Confirmation Required script */
>
> .... other code
>
> /* Begin MAIL() */
>
>
> $to = $_SESSION['name_mail'];
> $from = "[EMAIL PROTECTED]";  /* I tried this head-on-direct approach -- no
go,
> either */
> $subject = "Please Confirm Your Registration";
>
> $message = "Thank you for registering as a {$_SESSION['level']} at
> Xsite.com
> To complete your registration, please click the 'Confirmation' URL below.
> https://www.Xsite.com/all-confirm.php?unique_id={$_SESSION['unique_id']}";
>
> if(@mail($to, $from, $subject, $message))
>
> ***********************************************
>
> If I remove the $from everything works but with my IP's 'From: '
> Where should the $from variable go in the mail() function?
>
> Any hints or ideas gratefully appreciated,
> Tia,
> Andre
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>


--- End Message ---
--- Begin Message ---
How would you then build into the headers an 'invisible' BCC  (blind carbon
copy)?


-----Original Message-----
From: Monty <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Saturday, October 26, 2002 3:53 PM
Subject: [PHP] Re: Getting the "From: [EMAIL PROTECTED]" to work


>Andre Dubuc wrote:
>
>> Perhaps some kind guru can spare me some time. I've tried to get the
"From:
>> xxxx" field pre-filled for a registration/confirmation email that I send
out.
>
>To add to John's reply, here's how to do a multi-parameter Header. Also
note
>the \r\n at the end of each of these lines. If you don't do this, the
header
>won't be formatted properly. It took me some time to eventually figure this
>out when I first did this because I was using just \n which doesn't work in
>the header, but, does work in the body.
>
> $headers = "From: [EMAIL PROTECTED]\r\n"
>           ."Reply-To: [EMAIL PROTECTED]\r\n"
>           ."X-Mailer: PHP/4.0.2";
>
>You can also add other mail headers such as 'Importance: High' to the
>headers list.
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Add this to the header string...

"Bcc: [EMAIL PROTECTED]\r\n";

Andre Dubuc wrote:
Perhaps some kind guru can spare me some time. I've tried to get the "From: xxxx" field pre-filled for a registration/confirmation email that I send out.

I've managed to get the "To: ' field working great, but no matter where I stick the 'From:' code, it doesn't send the email. Any ideas what I'm doing wrong? Right now, the "From:' field is filled with my IP's address -- not exactly very cool to see!


Here's the code I've used (POP3):

$mail = $_SESSION['smail'];
$fname = $_SESSION['sfname'];
$sname = $_SESSION['ssname'];
$_SESSION['name_mail'] = "".$fname." ".$sname." <".$mail.">";

/* tried this -- it didn't work
$reg_first = "Registration";
$reg_last = "[EMAIL PROTECTED]";
$_SESSION['from_name'] = "".$reg_first." <".$reg_last.">";
*/

/* Begin Confirmation Required script */

.... other code

/* Begin MAIL() */


$to = $_SESSION['name_mail'];
$from = "[EMAIL PROTECTED]"; /* I tried this head-on-direct approach -- no go, either */
$subject = "Please Confirm Your Registration";

$message = "Thank you for registering as a {$_SESSION['level']} at Xsite.com
To complete your registration, please click the 'Confirmation' URL below.
https://www.Xsite.com/all-confirm.php?unique_id={$_SESSION['unique_id']}";

if(@mail($to, $from, $subject, $message))

***********************************************

If I remove the $from everything works but with my IP's 'From: '
Where should the $from variable go in the mail() function?

Any hints or ideas gratefully appreciated,
Tia,
Andre


--- End Message ---
--- Begin Message ---
hi,

does anyone know of a blogger with ODBC support?

cheers,
jaxon

--- End Message ---
--- Begin Message --- Or, more simply - set up an ODBC DSN on the Windows box to the MySQL database, and simply link the tables into Access.

Best regards,
Andrew Hill
Director of Technology Evangelism - OpenLink Software
Universal Data Access and the Virtuoso Universal Server
http://www.openlinksw.com/virtuoso/whatis.htm

On Friday, October 25, 2002, at 12:43 PM, Jay Blanchard wrote:

[snip]
Is there anyway to have php convert a database from mySQL to Access via a
webpage? I have a couple of people here who use Access to do mail merging
things with word and it would make my life a ton easier if I did not have to
convert the db's everytime they want the info. If anyone has any thoughts on
how to go about this it would be greatly appreciated. Thanks in advance.
[/snip]

Open and read the data via mysql_ ..() functions into an array. Then open an
ODBC connection to the acce$$ database and insert the data from the array.
Shouldn't be too hard.

HTH!

Jay



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




--- End Message ---
--- Begin Message ---
I'm new to PHP and so this may be something of a newbie question.  My bad if
it is.  I've spent a week now looking for information on capturing the
referral site with php so that I can store it with some session information.
If any of you have any idea how to accomplish this I would greatly
appreciate any information.

Thanks in advance...Ken


--- End Message ---
--- Begin Message ---
$HTTP_REFERER

$_SERVER["HTTP_REFERER"]



Samuel | http://enetwizard.net

-----Original Message-----
From: Ken Kirtley [mailto:kdkirtley@;earthlink.net] 
Sent: Saturday, October 26, 2002 5:47 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Referral Site...

I'm new to PHP and so this may be something of a newbie question.  My
bad if
it is.  I've spent a week now looking for information on capturing the
referral site with php so that I can store it with some session
information.
If any of you have any idea how to accomplish this I would greatly
appreciate any information.

Thanks in advance...Ken



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





--- End Message ---
--- Begin Message ---
Ken Kirtley wrote:

> I'm new to PHP and so this may be something of a newbie question.  My bad if
> it is.  I've spent a week now looking for information on capturing the
> referral site with php so that I can store it with some session information.
> If any of you have any idea how to accomplish this I would greatly
> appreciate any information.

You want the $_SERVER superglobal. Here's more info...

http://www.php.net/manual/en/reserved.variables.php#reserved.variables.serve
r


--- End Message ---
--- Begin Message ---
If I have a php file who calls another php file which change some letters on
the first file, why my php code on the first file won't work anymore?
I hope I was explicit enough in my question.

--
Trasca Ion-Catalin


--- End Message ---
--- Begin Message ---
That's impossible to answer!!  My guess is that the "few letters" you change
affect the way the script runs, so it's probably causing an error.

Without seeing *WHAT* you change, I can only guess.


Justin


on 27/10/02 10:31 AM, Trasca Ion-Catalin ([EMAIL PROTECTED]) wrote:

> If I have a php file who calls another php file which change some letters on
> the first file, why my php code on the first file won't work anymore?
> I hope I was explicit enough in my question.
> 
> --
> Trasca Ion-Catalin
> 
> 

--- End Message ---
--- Begin Message ---
I'm tyring to follow a DevArticle tutorial on creating a online users script in flash. 
Problem is, I can't find where the actions properties are to enter things like this:

loadVariablesNum("count.php?RND="+random(999), 0); 

Please help!! I'm using Flash MX, same as the tutorial. I've also posted a message in 
the tutorial's forum place but no reply...

Thanks,
Stephen Craton
http://www.melchior.us
http://php.melchior.us
--- End Message ---
--- Begin Message ---
Hello,

I'm afraid that your question is more of a "How can I use Flash MX?"
question.

Maybe you should get a good book about Flash MX or just google for some more
other tutorials...

- E

"Stephen" <[EMAIL PROTECTED]> wrote:

> I'm tyring to follow a DevArticle tutorial on creating a online users
> script in flash. Problem is, I can't find where the actions properties
> are to enter things like this:
>
> loadVariablesNum("count.php?RND="+random(999), 0);
>
> Please help!! I'm using Flash MX, same as the tutorial. I've also
> posted a message in the tutorial's forum place but no reply...
>
> Thanks,
> Stephen Craton
> http://www.melchior.us
> http://php.melchior.us
>
--- End Message ---
--- Begin Message ---
Ok.

I've had to wrestle with some peculiar issues with my sessions...

1) If at any point, I give my session a name different than the default
using session_name('XYZ'), my session won't be created. Is there a limit to
the number of characters a session name can have? Capitalization? ANYTHING?

2) If at any point, I use the funcion session_set_cookie_params(), my cookie
does not set! This is becoming frustrating...

using php4.2.3 on apache1.3.26 on a FreeBSD machine.
php.ini is the default.


--- End Message ---
--- Begin Message ---
alright i wanna know where i could see the source of predifened functions
like session_register. Thx.
--
Dark |++| Darkobjects.com


--- End Message ---
--- Begin Message ---
On Sunday 27 October 2002 10:40, DaRk--ObJeCtS wrote:
> alright i wanna know where i could see the source of predifened functions
> like session_register. Thx.

the manual?

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
The years of peak mental activity are undoubtedly between the ages of four
and eighteen.  At four we know all the questions, at eighteen all the answers.
*/

--- End Message ---
--- Begin Message ---
on 27/10/02 2:31 PM, Jason Wong ([EMAIL PROTECTED]) wrote:

> On Sunday 27 October 2002 10:40, DaRk--ObJeCtS wrote:
>> alright i wanna know where i could see the source of predifened functions
>> like session_register. Thx.
> 
> the manual?

errr, no the SOURCE... download it from php.net... did around, do some
multi-file search thingies...

justin

--- End Message ---

Reply via email to