RE: [PHP] Re: Hostname

2004-12-15 Thread Boget, Chris
> > In earlier versions of PHP, you could use the $HOSTNAME global 
> > variable to get the server/machine name that is running Apache/PHP.  
> > However, that variable is no longer working and I can't seem to find a 
> > replacement in any of the super global variables.  Is there one?  How 
> > can you get the server/machine name?
> $_SERVER['HTTP_HOST']
> $_SERVER['SERVER_NAME']

Interesting.  When I do:

print_r( $_SERVER )

both of the above print out the site name and not the host
name.  For example, the site name is 'mysite.mydomain.com' 
and the servername is 'machinebob'.  Each of the above print
out 'mysite.mydomain.com' and not 'machinebob', which is 
what I was expecting.

thnx,
Chris


RE: [PHP] call_user_method_array

2003-01-01 Thread Boget, Chris
> On my system, the function works as expected (at least as I 
> understand it): myFunc receives the parameters "Hello!" and 
> array("this"=>"that"), which is what you pass to it in the 
> first place. 

See, that's not what I'm getting... :|

> Were you expecting it to expand $myArrayVar into individual 
> parameters? 

No.  Just pass those parameters by value, just as they are.

> Also, call_user_method_array is now deprecated--you should 
> use call_user_func_array instead 

This isn't my choice.  What I'm trying to do is use the PEAR
Cache class.  Actually, one of the containers therein.  And
the class is using call_user_method_array().  Sure, I could
change it manually but if I ever upgrade PEAR, all my changes 
are gone.  As such, I'm just leaving as is.

The functionality I'm trying to create is to cache a call to
a SOAP service.  It seems like it should be easy enough since
I'm just caching a call to a method of the SOAP class I'm using.
To see exactly what I'm doing, you can go do the following page:

http://www.melancholy.org/test/xml/soap/soap_client.phps

and to run the page to see the results, just remove the trailing
's'.  The SOAP service is here:

http://www.melancholy.org/test/xml/soap/db_service.phps.

And if you aren't familiar with PEAR, you can see the class I'm
trying to use here:

http://pear.php.net/package-info.php?pacid=40

Anyways, what's happening in the Cache_Function class is that
it's executing this line of code:

$result = call_user_method_array($method, $$object, $arguments);

using the values I pass on this line of my soap_client.php script:

$xmlStr = $cache->call( 'soapclient->call', array( 'returnRecordXML',
$parameters ));

"call" is the $method, "soapclient" is the object and the above
defined array is "arguments".  However, as you can see when you
go to the soapclient.php page, arguments is being passed as an
array and not as the individual elements of the array.

And I can't figure out why... :|

If you or anyone else can tell me what's going on, I'd be very happy
to hear!

Chris



[PHP] call_user_method_array

2003-01-01 Thread Boget, Chris
How does this function really work?  I've been
beating my head against the wall for the last
8 hours trying to figure it out.  This is what
I'm trying and it isn't working:
{this is a very simplified version}

class MyClass {
  function myFunc( $stringVar, $arrayVar ) {
echo "$stringVar\n";
echo "\n";
print_r( $arrayVar );
echo "\n";

  }
}

$myClass = new MyClass();

$myStringVar = "Hello!";
$myArrayVar  = array( "this" => "that" );

call_user_method_array( 'myFunc', 
&$myClass,
array( $myStringVar, $myArrayVar ));

What's happening is that the values in the array 
are not being passed individually but instead is
being passed as an array.  Shouldn't it be passing
them individually?  If not, it wouldn't seem as if
you could use this function generically.  You'd have
to specificy write your method so it can (possibly)
be called by this function.  And that just doesn't
seem right.

Any light anyone can shed on this would be very much
appreciated!!

Chris



RE: [PHP] receiving XML stream as server via PHP

2002-12-31 Thread Boget, Chris
> Using PHP with cURL, I am currently able to dynamically 
> create XML documents and HTTP POST to a remote server, 
> receive an XML response, and parse XML as needed.
> What I am having trouble finding information on is doing 
> the reverse. Basically, I am trying to create a PHP script 
> that acts as a server, so

You might want to look into SOAP.  It sounds like it will fit
your needs very well.  PEAR has a SOAP implementation that's
still in testing and there is a class out there called NuSOAP
that's supposedly very good.  I just started toying around with
it recently and it seems to work very well.

Chris



Re: [PHP] Serializing a DOM object

2002-12-31 Thread Boget, Chris
> Try encoding like this:
> $retval = base64_encode(serialize( domxml_open_mem( $xml )));
> and on the next page:
> $xml = unserialize(base64_decode($xml));
> It works via html but don't know enough about soap

Well, you don't have to use soap - you can use sessions and get the
same result.
As for your suggestion, it didn't work. :(  I can do a print_r() and a
var_dump() on the variable before and after I serialize/encode it and
get the save values each time:

var_dump():

object(domdocument)(9) {
  ["name"]=>
  string(9) "#document"
  ["url"]=>
  string(0) ""
  ["version"]=>
  string(3) "1.0"
  ["standalone"]=>
  int(-1)
  ["type"]=>
  int(9)
  ["compression"]=>
  int(-1)
  ["charset"]=>
  int(1)
  [0]=>
  int(14)
  [1]=>
  int(138478176)
}

print_r():

domdocument Object
(
[name] => #document
[url] =>
[version] => 1.0
[standalone] => -1
[type] => 9
[compression] => -1
[charset] => 1
[0] => 14
[1] => 138478176
)


When I try to $DOMobject->dump_mem() before I serialize/encode it, I
get the underlying XML.  However, when I use dump_mem() afterwards, I
am getting those errors mentioned in my previous post.
I just don't understand why.  I'm having no problems serializing and
passing (through sessions or otherwise) other object, I'm just not
having any luck with the internal DOM object.

Chris




RE: [PHP] PHP & PostgreSQL

2002-12-30 Thread Boget, Chris
> Sorry, you've lost me. In your OP you say you wanted the 
> "table name", but now you're talking about the "dbname"? 
> For dbname, you can use (oddly enough) pg_dbname().

Eeep, I'm ever so sorry.  That's what I get for responding
at 4:30a when trying to battle insomnia.
Yes, I am looking for the table name, not dbname.  My
apologies. 

Chris



RE: [PHP] PHP & PostgreSQL

2002-12-30 Thread Boget, Chris
> pg_result_seek() should perform a similar function. In most cases 
> you wouldn't need to use that because if you're going to be using 
> the results more than once you could store them in an array.

Sometimes yes, sometimes no.  But a valid point nonetheless.

> > * For PGSQL, you can get the database name, the field name
> > even the *host name* but you can't get the table name from a
> > particular query?
> Not sure what you're getting at here. Surely for any particular 
> query, _you_ would know what table(s) is/are being used?

That's not necessarily true.  Certainly not if you are using an
abstraction layer to access the database.  Take PEAR for example.
When instantiation on object, you give it the relevant connection
information (user, pw, host and perhaps a dbname that may or may
not be the dbname that gets queried later on).  So sure, you can
access those member variables (except maybe dbname; I don't think
that gets stored) which is also information you can get 
programatically using built in functions.  But let's say you pass
a query to the query() method that doesn't use the dbname that
you used when instantiating the object.  That's certainly valid.
But now, there's no way (ok, there's a way but it isn't necessarily
accurate) to get the dbname for the query that was just run... apart from
requiring the programmer to pass the dbname as another paramter 
to the query() method   You can do this in mysql.  I just don't know 
why you can't do this in pgsql.

Chris



[PHP] PHP & PostgreSQL

2002-12-30 Thread Boget, Chris
I'm switching from a MySQL environment to PGSQL and I'm
going through and trying to learn the differences between the
two.  I've come across some issues that I can't seem to find the
answers to in the docs or on the web.  I'm hoping someone can
help me out.

* MySQL has a function to reset the result set so that it can be
iterated through again - mysql_data_seek().  I don't see that there
is a similar function for PGSQL.  Is that true?  If so, in order to
reset the result set you have to perform the query again?  Isn't
that a waste of resources?

* For PGSQL, you can get the database name, the field name
even the *host name* but you can't get the table name from a
particular query?

Any info would be greatly appreciated!

Chris




[PHP] Serializing a DOM object

2002-12-30 Thread Boget, Chris
Consider the following:

page1.php

test\n";

$retval = serialize( domxml_open_mem( $xml ));

return $retval;

  }

?>

page2.php

http://somepage.php' );
  $xml = $soapclient->call( 'test', $parameters );

  $xml = unserialize( $xml );
  $xml->dump_mem();

?>

In the test function, if I just serialize the $xml, return it and then call
xmldoc_open_mem on the unserialized return string, it works fine.
But it doesn't like it if I do the above.  I'm getting the error:

Warning:  dump_mem() [function.dump-mem]: Underlying object missing or of
invalid type
Warning:  dump_mem() [function.dump-mem]: Cannot fetch DOM object

Why isn't the serialization of the DOM object not working that way?

thnx,
Chris




RE: [PHP] counting with dates (help!)

2002-01-07 Thread Boget, Chris

> $today = date("Ymd", mktime(0,0,0, date(m),date(d),date(Y)));
> $last_week = date("Ymd", mktime(0,0,0, date(m),date(d)-7,date(Y)));
> echo ($today - $last_week);
> The result is a number like 8876 (20020107-20011231 = 8876)
> But in date thinking it should be 7!

No, that's the difference in time represented by the number of seconds.
You still need to work with it a little more.

8876 / 60 = number of hours  /* 60 = number of seconds in an hour */
8876 / 60 / 24 = number of days.  /* 24 = number of hours in a day */

Chris



RE: [PHP] global generation

2002-01-07 Thread Boget, Chris

> Wait until after the for loop has completed.
> for ($i=0; $i< $num_results; $i++) {
> $variable[$i];
> }
> global $variable;

That's not going to work.  The only thing that is doing is
making an already global instance of $variable global 
within the function.
What you want is this instead:

$GLOBALS[$variable] = $variable;

Chris



RE: [PHP] PHP, XML

2002-01-07 Thread Boget, Chris

> Does anyone know of a mailing list for PHP and XML or can I 
> just pose them here??

PHP-XML.  The list address is:

[EMAIL PROTECTED]

Chris



[PHP] Modulus and floating point...

2002-01-04 Thread Boget, Chris

Consider the following:

$number = 102.52;

echo $number % 50;
echo bcmod( $number, 50 );

in both cases, it's spitting out "2".  Why is it not spitting
out "2.52"?  Is there a way I can get that information?
w/o having to parse the string, breaking it up, getting
the modulus and then adding it back into the end result...?

Chris



RE: [PHP] easy quickie..

2002-01-02 Thread Boget, Chris

> I think it is $HTTP_SERVER_VARS['HTTP_REFERER']

Except that the value for this variable isn't always set and can
be spoofed.  This value should not be relied upon.
Oftentimes (though, you'd have to be creative to make this
work in a seperate window), what I use to send the user back
to where they came from is this:

Back 

Chris



RE: [PHP] Re: How do I do this

2001-12-13 Thread Boget, Chris

> This is untested, but something like...
> $str = "[hi] there, this is me [HI] there, this is me";
> $newstring = ereg_replace("(\[[A-Z]*])", "\\1", $str);
> should do it.
> using the Perl regexe's might make it easier, but that should work.

That worked perfectly.  Is there any way I can make it so that
it'll put the  there in every instance except for when it's
preceded by another square bracket.

So this:

[hi] there, this is me [HI] there, this is me
would turn into this:

[hi] there, this is me [HI] there, this is me

(which is the script that you sent me and works beautifully)

but this:

[hi] there, this is me [HI][HI] there, this is me

won't turn into this:

[hi] there, this is me [HI][HI] there, this is me

?

Chris
-still learning regular expressions




[PHP] How do I do this

2001-12-13 Thread Boget, Chris

I've got the following possible (example) strings:

[hi] there, this is me [HI] there, this is me
[ho] there, that is you [HO] there, that is you
[hey] there, where are you [HEY] there, where are you

and so on.  I'm trying to come up with a regex that will
find the capitalized text (only) between the square brackets,
including the brackets (ie, the [HI], [HO], [HEY]) and 
basically put a  right before.  So, after the regex/replace,
it'll look like this:

[hi] there, this is me [HI] there, this is me
[ho] there, that is you [HO] there, that is you
[hey] there, where are you [HEY] there, where are you

Now, the text between the brackets will be unknown, so I can't
just do an instr() or strstr().

Any suggestions?

Chris



RE: [PHP] http referer problems

2001-12-13 Thread Boget, Chris

> if ($efa != "nm" || $HTTP_REFERER !=
> "http://www.globalhealth.org/news/article.php3?id=1526";){
> do this);
> }

Not sure what the exact problem is as you haven't been all that
descriptive as to what the values are or what is happening, but
you should know that $HTTP_REFERER can't be trusted.  You
may not always get that value passed to you.

Chris



RE: [PHP] Re: Script like this for PHP

2001-12-12 Thread Boget, Chris

> The "pop outs" are done using JavaScript. Its something to do 
> with setting the STYLE="visibility: hidden" property of the HTML 
> element. I'm not sure exactly how its done though.

Yeah, and it only works on IE (and maybe NN6+).  It won't work
(the same way) on NN <6.

Chris



RE: [PHP] Logo proposal

2001-12-12 Thread Boget, Chris

> H - "killer" - how about an Orca?  We'll pretend that they 
> get along well with the MySQL dolphin, but PHP is definitely a 
> "killer app".

Yeah, but don't Orcas eat penguins?

Chris



RE: [PHP] Global storage of objects.

2001-11-29 Thread Boget, Chris

> I would like to know if there is a way to store objects 
> globally from a php-page, so that the object can be used 
> from another page.

Yes, using sessions or cookies.

Chris



RE: [PHP] session_set_save_handler()

2001-11-29 Thread Boget, Chris

> When I run the page this is on, I get a parse error at the line where
> function session_open is in the include file (see below)
> Any idea why?  Thanks

Hmm, it doesn't look like there is any reason why you would be getting
an error on that line.  Have you tried going directly to that page using
your browser?  Nothing will actually occur and you'll should see nothing
but at least it'll tell you if the error is really with this include file or
in 
the file that is calling it.  There could be a missing curly brace or some
thing in the calling file and PHP is saying there is an error in the
included
file when, in fact, it isn't.
This has happened to me sometimes.  It might be the case for you.

Chris



[PHP] Coding methods (was RE: [PHP-DB] gzip image files)

2001-11-27 Thread Boget, Chris

> $filename = 'kunden/'.$name.'.png';

I see this all the time and I'm curious:  what takes more
computing power (granted, either would be incredibly little
I'm sure, just curious which requires more work by PHP)?

this:

$filename = "this " . $varname . " that";

or this:

$filename = "this $varname that";

I would think the latter example but am not sure.

Another question, but this is more about personal style:

I almost always use the latter method in my coding practices.  It 
looks cleaner and, IMO, is easier to follow especially when there 
are a number of variables involved.  For those that use the former 
method, why do you?  I'm not trying to be judgemental, just curious
why people do what they do.  In asking, I may actually learn some-
thing. :p

Chris



RE: [PHP] schedule a task

2001-11-19 Thread Boget, Chris

> thanks for a quick response but I have a major problem with that:
> no shell access => can't use cron

Your Windows task manager?  Just set it up to go to that page
every night at your (not the server's) midnight...

Chris



RE: [PHP] Php Array

2001-11-16 Thread Boget, Chris

> How can I send the values inside the array into a function 
> for calculation?

function addValues( $arrayVar ) {
  $reteval = 0;

  foreach( $arrayVar as $element ) {
$retval += $element;

  }

  return $retval;

}

$myArray = array( 1, 2, 3, 4, 4 );

echo addValues( $myArray );

Chris



RE: [PHP] Jump to internal link after $PHP_SELF post

2001-11-15 Thread Boget, Chris

> >It depends on where value is coming from.  If it's coming from the
> >script server side, then you just need to make sure that $value is
> >set before the line "\n";

  $anchorTag = "FOO";
  echo "\n";

  $anchorTag = "BAR";
  echo "\n";

?>

or something along those lines.  You are going to have to set the value
of the form's action on the client side, not the server side.

For the checkbox, I don't know of "OnClick" is the right event.  You
will need to look up that form element in a javascript guide for the
event that you want.

HTH

Chris



RE: [PHP] Jump to internal link after $PHP_SELF post

2001-11-15 Thread Boget, Chris

> > When is $value assigned a value?  Before or after the 
> > script prints out the ", so $value would be "para1"). After posting 
> to SELF a jump to para1 must be made.

It depends on where value is coming from.  If it's coming from the 
script server side, then you just need to make sure that $value is
set before the line "

RE: [PHP] Jump to internal link after $PHP_SELF post

2001-11-15 Thread Boget, Chris

> A large page is generated with data from a MySQL database. The various
> paragraphs inside this page have variable, internal links, 
> also extracted from the database.
> Example: 
> Let's assume that $value represents FOO.

Ok

> Now i want to take the value of this variable to post to $PHP_SELF.
> Example: \n";.
> The HTML-source should show something like  action="/domain/page.php#FOO" method="post">

Seems straightforward enough...

> This does not work... Output on the source is like  action="/domain/page.php#" method="post">, so $value appears 
> to be empty.

When is $value assigned a value?  Before or after the script prints out
the "

[PHP] Getting uploaded filename & directory

2001-11-12 Thread Boget, Chris

In setting up a form to allow a user to upload a file,
upon submission of that form, you can get the actual
file name that is being uploaded by accessing the
variable:

$userfile_name

(assuming the form element's name where the user
specifies the file is "$userfile").

Is there a way to get the full path as well?  ie:

"c:\program files\this directory\uploaded_file.txt"

?  I tried echoing out $userfile to no avail.  I also tried
some javascript that when the form was submitted,
the value for the userfile element was copied to a hidden
form element, but that didn't work either.

Any ideas? Suggestions?

Chris



RE: [PHP] Re: URL variables

2001-10-25 Thread Boget, Chris

> > the only way you may go wrong with this is with scoping, 
> > $yourvar isn't available in a function inside yourpage.php.
> It can be, though.  You just need to tell the function to look for the
> global variable $yourvar:
> function yourFunction() {
> global $yourvar;
> ...
> }

or

function yourFunction() {
$localVar = $GLOBALS[yourvar];
...
}


Chris



RE: [PHP] how can I do this !!

2001-10-25 Thread Boget, Chris

> i have txt file have this words 
> --
> bla bla bla 
> [phpcode]
>  echo 'hello word';
> ?>
> [/phpcode]
> bla bla bla
> ---
> now I want to convert the code that are between [phpcode] and 
> [/phpcode] to colorized code ..
> How I can do that

Copy the file to .phps and access that page via the webserver?

Chris



RE: [PHP] Searching for a word in a string

2001-10-19 Thread Boget, Chris

> How can I search for a certain word in a string?

strpos()  ereg()  preg() and similar functions.

Chris



RE: [PHP] something like alert (javascript)

2001-10-03 Thread Boget, Chris

> Is there any function in PHP that is similar to alert() or 
> confirm() of javascript ? I tried die() but that's not what I need.

What do you want it to do?  Remember, though, that 
PHP = server side while Javascript = client side.  If you 
want alert() or confirm() functionality on the client side
(why would you want this server side; it'll just hang there
until someone on the back end hits a key or something)
use either of those two functions.

Chris 



RE: [PHP] Variable declaration

2001-09-26 Thread Boget, Chris

> I want PHP parser to warn/fail when I try to use a variable 
> not declared before. Like "Option Explicit" on ASP/VBA.

Look here:

http://www.php.net/manual/en/function.error-reporting.php

Chris



RE: [PHP] handling errors

2001-09-26 Thread Boget, Chris

> How do I turn off the error messages that appear at the top 
> of the page?  I have this function below that if an image is 
> not there for $url, it give a "warning".
> $size = GetImageSize("$url");
> Example error message below...
> Warning: getimagesize: Unable to open 'http://www.yahoo.com' 
> for reading. line 28

This should do it:

$size = @GetImageSize("$url");

The "@" symbol suppresses errors.

Chris



RE: [PHP] header() confusion

2001-09-26 Thread Boget, Chris

> > Yes that's what I do but it freeze on netscape 6 ?
> FAFAIK the client's browser can't influence the header() call in
> your script. Are you sure there aren't any errors somewhere else. Eg
> before the header() call or at the start of the page where you
> redirect the user to?

Indeed.  A good way to tell if this might be the case is to view the
source of the page you get stuck at.

Chris



RE: [PHP] Variable naming

2001-09-25 Thread Boget, Chris

> I want to use the value of a variable in a variable name. For 
> instance:
> 
> $id = 1;
> $sql_$id = "hey"; //set variable $sql_1 to hey
> print $sql_1; //should print hey

I *believe* (could be wrong) what you want is this:

print ${$sql_1};

Check out variable variables in the dox.

Chris



RE: [PHP] 2 decimal places

2001-09-25 Thread Boget, Chris

> Yeah, but what if they don't JUST want to print it...

Umm, have you read the documentation on either of
the functions?  They both return a string; they don't
send anything to standard out (like echo or print does).

$myString = printf();
$myString = sprintf();

echo $myString;

Chris



RE: [PHP] 2 decimal places

2001-09-25 Thread Boget, Chris

> What if I want to pad a number with zeros in the other 
> direction?  I.E:
> 524 becomes 00524

printf() / sprintf() is your friend.

Chris



RE: [PHP] dates only in the future

2001-09-25 Thread Boget, Chris

> I'm looking for a function which enables me to allow user 
> only to enter those dates which are still to come. In my head 
> I have three  things... one for day, one for month and 
> one for year. In order to prevent the user from submitting the 
> form with the date which is in past, I need probably Javascript. 
> Am I correct? 

Only if you want to check before the form gets submitted...

> I rather prefer to keep my site Javascript free and therefore it 
> would be great if somebody has already written such a function 
> and would be ready to share it with me/others. If not, any ideas 
> how to start... 

Here is a function I use.  Call after the form is submitted.

function verifyDate( $date_month, $date_day, $date_year, $notprior = "" ) {
  // v. 1.1
  // 1999.11.19 - to check to make sure that the selected dates are
  // within the appropriate range:
  // ie. days cannot exceed 31, months cannot exceed 12 and 
  // years cannot be more than 10 years in the future.

  $retval = 1;

  $today = MkTime(0,0,0, date( "m" ), date( "d" ), date( "Y" ));
  $selected_date = MkTime(0,0,0, $date_month, $date_day,$date_year);

  if(( $date_month > 12 ) || 
 ( $date_day > 31 )   || 
 (( $date_year < ( date( "Y" ) - 95 )) || ( $date_year > date( "Y" 
{
$dategood = 0;

  } else {
$dategood = checkdate( $date_month, $date_day,  $date_year );

  }
  if( !$dategood ) {
$retval = "Date is invalid.  Please make sure that the day selected is
valid for the month selected\n";

  } elseif (( $today > $selected_date ) && ( $notprior )) {
$retval = "Date Selected Is Prior To Today\n";

  }

  return $retval;

} // End function verifyDate();

Chris



RE: [PHP] emails with attachements

2001-09-21 Thread Boget, Chris

> i want to send emails with attachements... can I modify the 
> mail()-function or how can I perform this?

You can get classes that do this very thing at the following site:

http://phpclasses.upperdesign.com/

Chris



RE: [PHP] Merging Arrays

2001-09-21 Thread Boget, Chris

> I've got to different files of words. One on each line.
> What would be the best way to combine both into one file 
> alphabetically?

after you merge the arrays, use asort();

Chris



RE: [PHP] importing text file

2001-09-20 Thread Boget, Chris

> I would even go for $Something and just $SomethingMore
> with $Something really being $Something-$SomethingElse. 
> I don't know if that makes sense. 
> Any help would be greatly appreciated.

Take a look at file(); and just loop through the resulting array
and removing all the blank elements.

Chris



RE: [PHP] Re: Is it *really* an associative array?

2001-09-18 Thread Boget, Chris

> what are you trying to do?
> why do you want to diffirentiate between "99" as a string or 
> as a number?

Because if it is a string, more than likely it means that the key
was user defined and is not PHP defined as an element number.

Again, consider the differences between these two arrays:

array( "This", "That", "Other" );

PHP more or less turns this into an associative arrays because,
as far as I know, all arrays are associative.  If you loop through
this array, you get the following key/value pairs

Key  Value
0   This
1That
2Other

The keys are numbers, integers.  They are also the element numbers.

Now, the second type of array:

array( "1" => "this", "2" => "that", "few" => "other" );

Looping through this array, you get the following key/value
pairs:

Key  Value
1   this
2   that
few   other

Funkiness exists that PHP also sees "1" and "2" as element
numbers.  So if you loop (pseudo)for( $i = 1 to 5 ) and print
out those elements, it will print out only "this" and "that",
ignoring "other".  But that is neither here nor there for the
most part, just something that I need to take into consideration
and something that prevents me from just checking to see
if the the key is the same as the element number because
in some cases, it legitimately can be.
Alas.

As for what I am trying to do, I am looking for a way to
determine if an array is a user defined associative array or
not.  I.E., I want to come up with an algorithm to differentiate
between the two arrays defined above - the normal array
and the associative array.

Again, any help or insight would be greatly appreciated.
Zeev?  Rasmus?

Chris



[PHP] Is it *really* an associative array?

2001-09-13 Thread Boget, Chris

Sample code:



  $array = array( "one", "two", "three" );
  while( list( $key, $val ) = each( $array )) {
if( is_string( $key )) {
  echo "Key is a string\n";
  
}
echo "Key: $key => $val :Val\n";

  }
  echo "\n\n";

  $array = array( "SS" => "one", "15" => "two", "19" => "three" );
  while( list( $key, $val ) = each( $array )) {
if( is_string( $key )) {
  echo "Key is a string\n";
  
}
echo "Key: $key => $val :Val\n";

  }



Because of the loose typing in PHP, essentially all arrays
are associative arrays.  Running the script above produces
the following results:

 BEGIN RESULTS
Key: 0 => one :Val
Key: 1 => two :Val
Key: 2 => three :Val


Key is a string
Key: SS => one :Val
Key: 15 => two :Val
Key: 19 => three :Val
 END RESULTS

Anyways, I want to be able to pass an array to a function.
This array can be defined by me as associative (as the 
second array in the sample) or regular (as the first).  However,
I need to be able to tell one from the other in my function.
As you can see, I can't do it with the is_string() function
because it doesn't realize that the "15" and the "19" I specify
as keys in the second declaration are actually strings that I
added and not actual element numbers.
Is there some way that I can determine if the keys of an array
are user defined (ie, a user defined associative array) and not
the keys PHP defines due to the fact that they are the element
numbers?

Another, somewhat related issue, notice the funkiness that
happens when you run the following, similar, script:



  $array = array( "one", "two", "three" );
  while( list( $key, $val ) = each( $array )) {
if( is_string( $key )) {
  echo "Key is a string\n";
  
}
echo "Key: $key => $val :Val\n";

  }
  echo "\n\n";

  for( $i = 0; $i < count( $array ); $i++ ) {
echo "Printing element: $i -- " . $array["$i"] . "\n";

  }  
  echo "\n\n";

  $array = array( "SS" => "one", "15" => "two", "three" );
  while( list( $key, $val ) = each( $array )) {
if( is_string( $key )) {
  echo "Key is a string\n";
  
}
echo "Key: $key => $val :Val\n";

  }
  echo "\n\n";

  for( $i = 0; $i < 20; $i++ ) {
echo "Printing element: $i -- " . $array["$i"] . "\n";

  }  



Any help anyone can provide would be *greatly* appreciated!!

Chris



RE: [PHP] test for empty $result??

2001-09-10 Thread Boget, Chris

> Then you can use:
> if (mysql_num_rows($result) == 0) {
>   stuff here
> }
> This will check the number of rows returned from your query.  If zero,
> then do somethingmodify as you need.

What I generally do is this:

if(( !$result ) || ( mysql_errno() > 0 )) {
  // error code here
}

OR

if(( $result ) && ( mysql_errno() == 0 )) {
  // it's all good
}

If you want to use the above, precede the mysql_num_rows() function
call with the "@" symbol.  If, for whatever reason, there was an error
or if there was a NULL result, you will get an error on the page saying
that it is an invalid result ID.

Chris



RE: [PHP] adding functions to a class

2001-09-04 Thread Boget, Chris

> the require(morefunctions.php); will ofcource not work but 
> bassicly this is what I want. en all the functions added should 
> be able to use VAR1 VAR2 VAR3 (and the other functions that 
> are allready in the class)
> is there a why to do this ??

Yes, there is.  
Go here:

http://www.php.net/manual/en/language.oop.php

Chris



RE: [PHP] How to get a double to show the .00 in a hole number

2001-08-31 Thread Boget, Chris

> I am trying to get a double data type to display the .00 in a 
> "hole" dollar amount (i.e. 432.00 not 432 or $432.00 not $432).
> Can anyone tell me how to do this?

printf(); or sprintf(); is your friend

Chris



RE: [PHP] PHP_SELF or REQUEST_URI within Function ?

2001-08-31 Thread Boget, Chris

> Cool ...
> Now that we're talking about PHP 
> I'd like to ask a question 
> You know the "overloading" function in C++  Is that 
> possible in PHP ?

No, I do not believe so.
 
> Basically , I'd like to define  more than one function having 
> the same name but different number of variables/parameters ... 
> so PHP would know which one I'm calling depending on the 
> numbwer/type of the variables ... exemple :

You can do this with variable parameters.  Something along
these lines:

function myFunc( $requiredVar, $optionalVar1 = "", $optionalVar2 = "" ) {
  echo "$requiredVar\n";

  if( $optionalVar1 ) {
echo "$optionalVar1\n";

  } 
// etc.
}

Alternately, if you need *alot* of optional vars, consider passing
an array and check that.

Chris



RE: [PHP] PHP_SELF or REQUEST_URI within Function ?

2001-08-31 Thread Boget, Chris

> One of the downside of PHP IMHO is, that you do not have to define
> variables.  This leads to a lot of errors.  At least there should be a
> "option", which forces you to define variables, like maybe so:
>   dim $some_var;

I definitely agree there.  I've been bitten by this bug more times
than I can count.  Granted, it's always been my fault, but it would
have been nice to have something there to say "hey, this variable
hasn't been defined".  I know you can make PHP do this if you set
the error checking very, very high but in doing so, you are also
opening up another bucket of worms that you don't always need
to deal with.

> > variables in a function.  Plus, if the function gets large, 
> > it's easier to see where the value is coming from by using
> > the $GLOBALS variable.
> Now, that's the point I'm arguing here.  I don't think so.

This is definitely a matter of coding style.  Neither of us are
wrong, just a matter of preference.  In replying, I was simply
offering alternatives so that Arcadius would know all options
open to him.  I wasn't trying to say your way was erroneous
and if I came off that way, my apologies.

Chris



RE: [PHP] PHP_SELF or REQUEST_URI within Function ?

2001-08-31 Thread Boget, Chris

> > Or, so you don't have to specify all the variables you are using 
> > as globals (especially if you are using *alot* of them), you can 
> > use:
> > $GLOBALS[SCRIPT_FILENAME];
> What's the gain?  'global ' has 7 characters, whereas '$GLOBALS[]' has
> 10 characters.  So, you don't type less.  And with using global(), the
> code is more orderly, and thus easier to read.

True.  But take the following function:

function processLotsOfFormVars() {
  global $fieldOne, $fieldTwo, $fieldThree, $fieldFour;
  global $fieldFive, $fieldSix, $fieldSeven;
  global $PHP_SELF, $REQUEST_URI;
  global $HTTP_REFERER;

  echo "Field One is: $fieldOne\n";
  echo "Field Two is: $fieldTwo\n";
// etc
}

OR you can do it this way:

function processLotsOfFormVars() {
  echo "Field One is: $GLOBALS[fieldOne]\n";
  echo "Field Two is: $GLOBALS[fieldTwo]\n";
// etc
}

I've done it both ways.  I'm not advocating using 
"$GLOBALS[var_name];" over "global $var_name",
just that it is an alternative if you are using alot of global 
variables in a function.  Plus, if the function gets large, 
it's easier to see where the value is coming from by using
the $GLOBALS variable.
That's all I was saying.

Chris



RE: [PHP] PHP_SELF or REQUEST_URI within Function ?

2001-08-31 Thread Boget, Chris

> So sprach »Arcadius  A.« am 2001-08-31 um 05:27:04 -0700 :
> > $u = $SCRIPT_FILENAME;
> Because you did not define $SCRIPT_FILENAME anywhere.  If you want to
> access the global variable, you've got to say so:
> global $SCRIPT_FILENAME;

Or, so you don't have to specify all the variables you are using 
as globals (especially if you are using *alot* of them), you can 
use:

$GLOBALS[SCRIPT_FILENAME];

Chris



RE: [PHP] Directing A Parked Domain To A Sub Directory

2001-08-30 Thread Boget, Chris

> How can I use PHP to detect if the visitor wanted MainDomain.com (and
> display MainDomain/index.php) or WidgetWorld.com (and then display
> MainDomain/Widgets/index.php).

I *believe* what you are looking for is $HTTP_HOST.

Chris



RE: [PHP] ucwords Except 'The' 'And' etc?

2001-08-13 Thread Boget, Chris

> Is there a prewritten function for capitalizing the first 
> letter of each word in a string except for the common 
> words you wouldn't want to capitalize in a title? Like
> Come Learn the Facts From an Industry Leader 

None that I've seen.
But it wouldn't be hard to write a function that takes a 
string, passes that string to ucwords() and then you can
run through a pre-defined array and just do an ereg_replace()
on those words you want to remain lowercase...

Or something like that...

Chris



RE: [PHP] array through url?

2001-07-27 Thread Boget, Chris

> Is it possible to send an array of numbers into a php file 
> through a url?  
> Like if I have a file that adds numbers together, could I send it
> www.domain.com/add.php?num=2,3,4,5
> $num would be an array.

Sent that last one out prematurely... sorry...

Take a look at the serialize() and urlencode() functions.

Chris



RE: [PHP] array through url?

2001-07-27 Thread Boget, Chris

> Is it possible to send an array of numbers into a php file 
> through a url?  > Like if I have a file that adds numbers together, could
I send it
> 
> www.domain.com/add.php?num=2,3,4,5
> 
> $num would be an array.
> 
> Thanks,
> Pat
> 



RE: [PHP] substr question...

2001-07-26 Thread Boget, Chris

> I am trying to receive file names but can't quite figure out 
> the proper substr to do it:
> jeff.dat
> jeffrey.dat
> chris.dat
> tom.dat
> I want to receive the name to the left of the .dat

$fileName = eregi_replace( "\.dat", "", $fullFileName );

Chris



RE: [PHP] Why doesn't this simple query work?

2001-07-25 Thread Boget, Chris

> Driving me mad.  Works if I put a string in quote marks instead of the
> variable $location.
> $result = mysql_query("SELECT shootID FROM shoots WHERE
> (location=$location)");
> This should work shouldn't it?  If it's a problem with the variable being
> embedded in the query what's the easiest way to overcome this?

$location is a string variable, yes?  If so, then your statement
needs to look like this:

$result = mysql_query("SELECT shootID FROM shoots WHERE
(location=\"$location\")");

Note the escaped quotes around $location.

Chris



[PHP] Getting mail() to work in PHP for Windows

2001-07-25 Thread Boget, Chris

I couldn't find anything in the docs about this...
What do you need to have installed to be able to
use the mail() function (and have mail get sent
out) in PHP for Windows?
If you could point me to the proper place in the
documentation so I can read up on it, I'd be ever
so grateful!

Chris



RE: [PHP] Best way to...

2001-07-24 Thread Boget, Chris

> $numMonths += ( 12 + ( $endMonth - $startMonth ));

This last line should have read:

$numMonths += ( 12 + ( $endYear - $startYear ));

Too much cutting and pasting... :p

Chris



[PHP] Best way to...

2001-07-24 Thread Boget, Chris

get the difference in months between two dates
using a unix time stamp?

I know I can do something like this:

$startMonth = date( "m", $startTimestamp );
$startYear = date( "Y", $startTimestamp );
$endMonth = date( "m", $endTimestamp );
$endYear = date( "Y", $endTimestamp );

$numMonths = $endMonth - $startMonth;
if( $startMonth > $endMonth ) {
  $numMonths += 12;

}
$numMonths += ( 12 + ( $endMonth - $startMonth ));

Is there some better way?

Chris



RE: [PHP] is this right

2001-07-24 Thread Boget, Chris

> this doesn't work,how should it be done?
> insert into test (uid, companyUid)
> values(1, select uid from companysTable where company = "Micrsoft");

If you are using MySQL, it doesn't support sub selects...

Chris



RE: [PHP] a good PHP editor

2001-07-18 Thread Boget, Chris

> I'd like to recommend Allaire HomeSite.

Read their own HS forum before finally deciding.  HS has *alot*
of issues, particularly with memory.
 
> I haven't seen any other programs for Windows you can edit 
> remote files instead of the usual "download, edit, upload". Let 
> me know if there are other good editors with this feature.

The feature I use the most (and need it for the most) is how
it sets up "Projects".  I wish I could find something else that
did that (well).  If I could, I'd move to it in a heartbeat.
 
> There are three bad things about this program though;
> 2, It takes alot of system resources.

Not alot.  ALOT.  Huge, massive amounts of resources.  I'm
getting resource low messages from Windows less than 20
minutes after opening it and it's the only thing running aside
from my mail client.

Chris



RE: [PHP] PHP- something tha i don't understand

2001-07-17 Thread Boget, Chris

> 8:$result = mysql_db_query("users", $query); 
> 9:$r=mysql_fetch_array($result); 
> 10: $count=$r["count"];
> And the error message is 
> Warning: Supplied argument is not a valid MySQL result 
> resource in 
> c:\inetpub\wwwroot\PhpAndMysqlTest\test2\reg1.php3 on line 9

You need to validate that the query returned a value.  Your query
failed somewhere...

Chris



RE: [PHP] Get filename in php command line

2001-07-17 Thread Boget, Chris

> I had that before. 
> OK, seems that my problem is not that simple. The thing is , 
> I have something 
> like this in my file test.php:
> require('my_api.inc');
> echo "This is test.php3";
> Now, in my_api.inc, I want to know that I run test.php3, when I do
> bash$ php test.php3
> and the filename is test.php3 .  __FILE__ will give my my_api.inc 
> instead.  I need it because my_api.inc do all sort of authenticating, 
> session, etc.

__FILE__ will give you the name of the file that uses that constant.
So, based on the above, I believe that you are using __FILE__ only
in my_api.inc (which is pretty much what you said, I'm just looking
for verification).

What you can do instead is this:

in "my_api.inc", have the following code:

echo "Currently Running file is: ";
echo ( $CurrentRunningFile ) ? $CurrentRunningFile : __FILE__;

in test.php

\n";
?>

Define "$CurrentRunningFile" on line one of all your files.  Or
something along those lines...

Chris



RE: [PHP] Get filename in php command line

2001-07-17 Thread Boget, Chris

> Seems that $PHP_SELF is not defined when it's run from the 
> command line.

Try:

__FILE__

Chris



RE: [PHP] return

2001-07-16 Thread Boget, Chris

> Here's my code:
>  function expDate($date) {
> $month = substr("$date", 0, 2);
> $len = strlen($date);
> $year = substr("$date", $len-2, $len);
> return $month;
> return $year;
> }
> expDate("11/2002");
> print "$month $year";
> ?>
> I know this isn't the correct usage of return, but how to I 
> get the $month and $year variables so I can print them 
> after I've called the expDate() function?  Currently, nothing 
> is printed to the browser.

You cannot use "return" twice like that.  The function will
exit immediately after the first valid "return" call it hits.
To do what you want, you can do this:



function expDate($date, $returnMonth, $returnYear ) {
$month = substr("$date", 0, 2);
$len = strlen($date);
$year = substr("$date", $len-2, $len);
$returnMonth = $month;
$returnYear = $year;
}

$month = 0;
$year = 0;

expDate( "11/2002", &$month, &$year );
print "$month $year";

--

The "&" operator passes a variable by reference.

Alternately, you can do:



function expDate($date, $returnMonth, $returnYear ) {
global $month;
global $year;

$month = substr("$date", 0, 2);
$len = strlen($date);
$year = substr("$date", $len-2, $len);

}

$month = 0;
$year = 0;

expDate( "11/2002" );
print "$month $year";

--

Though, I try to use "global" as little as possible.

Chris



RE: [PHP] Export to Excel

2001-07-13 Thread Boget, Chris

> Here's something I found on the PHP Code Exchange:
> Generate Excel files from PHP by Christian Novak on 
> 2000-11-25 11:47:24 (v for 4.0) is 1974 bytes.
> Small function library to generate Excel files/stream 
> directly from PHP.
> http://px.sklar.com/code.html?code_id=488
> I haven't tried it out...it doesn't look terribly sophisticated but it
> might work.

I just tried it and it didn't work.  At least, not for Excel2k.  It
created an .xls file but it wasn't something that could be opened
and read by my version of XL.

Chris



RE: [PHP] referring url

2001-07-11 Thread Boget, Chris

> > Is there a way in PHP to get the referring url when a link is click
> > to get to that page?
> $HTTP_REFERER
> getenv('HTTP_REFERER')

Note that this isn't supported on all browsers and can be turned
off or faked/munged.

Chris



RE: [PHP] Variable Next To Variable?

2001-07-11 Thread Boget, Chris

>   if (!$C_Last_Name$y) {
> The form submitting information to this code has field name like
> C_Last_Name1 C_Last_Name2 depending on how many Children
> are signing up for something. So I need $y to represent the number.

You want this:

if (!{$C_Last_Name}{$y}) {

The {} surrounding the variable name tells PHP that those are
unique entities/variables.  For example, you could use the following:

echo "Hello, {$userInfo->printFirstName()}";

to interpolate a class' method call within a string...

Chris



RE: [PHP] HTML/PHP's static state problem.

2001-07-09 Thread Boget, Chris

> I've done this very thing for a leasing company.  I used 
> PHP and MySQL to create a series of arrays in Javascript.  
> When the user clicked on a value in the first combobox I 
> used onClick to call a function which loaded information 
> into the second box.

A definite possibility.  The only downside being is if there is 
*alot* of data it'll take a while for the user to DL the page.

Chris



RE: [PHP] HTML/PHP's static state problem.

2001-07-09 Thread Boget, Chris

> Basically I mean this: I load the page, it has two comboboxes 
> ( with ).
> The first one contains names of countries, the second names 
> of cities within those countries.
> When I select "Belgium" in the first one, I only want to see 
> all Belgian cities.
> Now with JavaScript this wouldn't really be a problem, I  guess, 
> but I need PHP for going into my database.

What I do is this:

Where I set up the form, for the first combo box, I fill it using
the results from the query:

"SELECT * FROM countries"

and name that combo box "country_name".  I set an event on
this combo box to be "OnChange=form.submit();"

For the second combo box, I use the query:

"SELECT * FROM cities WHERE country=\"$country_name\""

So the combo box will be empty the first time into the page but
each time they select a new country, it gets filled appropriately.

I have some checks to determine where the form submission is
coming from so I know whether or not to actually process the
data.

HTH

Chris




RE: [PHP] Passwords?

2001-05-23 Thread Boget, Chris

> I have some field error checking going on ... and when a user 
> (say) doesn't fill in a field correctly, my error page comes up telling 
> them.  They then must click on their browsers  button 
> and make the changes.
> Now -- I have a password field, and when they click back, 
> they are forced to re-enter their password -- this is annoying.
> My questions are:
> 1. Is there a way to make this stop happening?
> 2. Instead of the user clicking on their browsers  
> button, can I add a
> URL that provides the same functionality -- that will work in IE 
> and Netscape?

Why don't you have the form do it's own error checking.  That
way, if there are errors, the form displays again and you won't
lose any values...

Chris



RE: [PHP] File upload form

2001-05-22 Thread Boget, Chris

> Have you asked what browsers they are using?  

This happens primarily on IE but it also happens
using NS

> Also, what are you using to serve this page?

?
PHP 4.0.4 and Apache.

Chris



[PHP] File upload form

2001-05-22 Thread Boget, Chris

Below is the (very) simple form that I'm using to allow users
to upload files to my site:

---

 
 
Upload Attachment 
 
 
 
 
Upload File 
You are uploading from an unsecure server. 
 
 
 
 
 
 
 


 
 
 
 
 
 
 
 


 
 
Close
Window 
 
 
 

---

The problem that I'm experiencing using the above form is that when
some users (and the problem is consistent for those users) submit the
above form, *none* of the POST variables are getting passed to the
receiving page.  None of the hidden variables, not the "input type = file"
variable, _nothing_.  However, the majority of my users have absolutely
no problem using this form.  Just those very few.

Now, when I change this line:

 

to this:

 

(ie, remove the ENCTYPE="multipart/form-data"),

all of the POST data gets sent to the receiving page for those users.

What is going on?  Why is the POST data not getting sent to the server
when theENCTYPE="multipart/form-data"is included in the form
definition?  And why only for a very small subset of users?

Thanks for any insight you can give!

Chris



RE: [PHP] session and back button

2001-05-22 Thread Boget, Chris

> I'm using sessions and if the user hits the back button an 
> expiration page appears! how can i disable the back button ?
> i tried window.history.forward(1) but it fails !

Even more interesting is that when a user presses the back 
button all the way back to the page that initially started the
session, a new session is started.  As such, all information
previously stored will be lost.
What I did to fix my problem (and I think it'll fix yours) is
that I start the session on a page the user cannot go "back"
to.  To do that, the only code in the file is:



Chris



RE: [PHP] Quotes in GET variables

2001-05-21 Thread Boget, Chris

> Anyway, it's not a big thing if you're _really_ stringent about how you
> check every single variable which is used in a database query,
> system/passthru/exec, or eval command, and your checking methods are
> flawless, but otherwise it's just best to go to the trouble of hacking
> around the input explicitly.

What would you do to go about doing this?  How can you be
_really stringent_ in checking your variables?  Check that they
have a value?

Chris



RE: [PHP] Is there any "sleep" function?

2001-05-18 Thread Boget, Chris

> Is there any sleep function in PHP like in Perl?
> For example, you will define the time in seconds and system 
> will wait for that time to continue running the script?

You read the documentation at all?!?

http://www.php.net/manual/en/function.sleep.php

Chris



RE: [PHP] download successfull... but in binary... why?

2001-05-09 Thread Boget, Chris

> header("Content-type: application/download");

I think you'd need to change this to:

header("Content-type: text/plain");

but I could be wrong...

> and where can I find reference on these header stuff?

Not sure.  I find bits and pieces in this list...

Chris



RE: [PHP] Days between two dates

2001-05-07 Thread Boget, Chris

> Sorry,
> it doesn't work !!

Why do you say that?  I just tested it and it worked.
It returned:

"115.31296296296"

"115" being the number of days
".31296296296" is the fraction of the day that is the 
difference of hours between the two times.

mktime() and date( "U" ) return a unix timestamp 
which is made up of both date _and_ time.

Chris



RE: [PHP] Days between two dates

2001-05-07 Thread Boget, Chris

> Hi,
> How can I calculate days between two dates ?

This should work:

$firstDate = mktime( 0, 0, 0, 1, 12, 2001 );
$secondDate = date( "U" );

$daysInBetween = ( $secondDate - $firstDate ) / 86400;

Chris



[PHP] File upload

2001-05-01 Thread Boget, Chris

>From the manual:

"Handling file uploads Uploading multiple files  
  
Common Pitfalls

Not validating which file you operate on may mean that users 
can access sensitive information in other directories. "


What is meant by the above?  How would you "validate" that
you weren't operating on the wrong file?  As far as I know, 
PHP puts the file in whatever directory you specify and that
is where you would access the file... how could someone make
it so they access information elsewhere?

Chris



RE: [PHP] File upload form

2001-05-01 Thread Boget, Chris

> > Again, any help would be greatly appreciated!
> could be a browser specific issue. have you checked into the 
> possibility that people having problems are all using the same 
> browser?

I don't know what all of them are using, but most are using
IE.  I don't know how feasable it would be to get them to all
change browsers, especially when they are not having this
problem on other sites (Yahoo, for example).  The problem is
originating from my server.  There is some combination of
the ENCTYPE of the form and some setting on our server
that is causing the POST vars not to get sent.

Chris



RE: [PHP] PHP Graph class/library anywhere?

2001-05-01 Thread Boget, Chris

> is there a PHP class/library available anywhere, that supports
> dynamic creation of different graphs? I need 2D bar graph and
> pie graph support.
> i found the VH Graph (http://www.vhconsultants.com/graph/graph.htm),
> but they want $100 for their 2.x version. i'd prefer a free one
> (i'm sure there must be a couple floating around) :)

Funny enough, I just got an email from the PHP Classes site
about a new class that does that.  Try this URL

http://phpclasses.upperdesign.com/browse.html/package/226

That might do what you need.

Chris



RE: [PHP] File upload form

2001-05-01 Thread Boget, Chris

> The problem that I'm experiencing using the above form is that when
> some users (and the problem is consistent for those users) submit the
> above form, *none* of the POST variables are getting passed to the
> receiving page.  None of the hidden variables, not the "input 
> type = file" variable, _nothing_.  However, the majority of my users 
> have absolutely no problem using this form.  Just those very few.
> Now, when I change this line:
>  METHOD=POST name="uploadForm"> 
> to this:
>  
> (ie, remove the ENCTYPE="multipart/form-data"),
> all of the POST data gets sent to the receiving page for those users.
> What is going on?  Why is the POST data not getting sent to the server
> when theENCTYPE="multipart/form-data"is included in the form
> definition?  And why only for a very small subset of users?
> Thanks for any insight you can give!

Another thing of note:

These same users that are having problems with my file upload form
are not having problems with Yahoo!'s email attachment form (a file
upload form as well).  So I copied all the same HTML code from that
form and put it on my site to test.  The only thing I changed was the
ACTION field and I modified their "Done" button to be a submit button.
When they submitted that form, the POST vars didn't come through
either.  The only thing I can think of is that there is an issue with our
Apache or, more likely, our PHP configuration.  However, I'm not 
sure of where to even start looking.

Again, any help would be greatly appreciated!

Chris



[PHP] File upload form

2001-05-01 Thread Boget, Chris

Below is the (very) simple form that I'm using to allow users
to upload files to my site:

---

 
 
Upload Attachment 
 
 
 
 
Upload File 
You are uploading from an unsecure server. 
 
 
 
 
 
 
 


 
 
 
 
 
 
 
 


 
 
Close
Window 
 
 
 

---

The problem that I'm experiencing using the above form is that when
some users (and the problem is consistent for those users) submit the
above form, *none* of the POST variables are getting passed to the
receiving page.  None of the hidden variables, not the "input type = file"
variable, _nothing_.  However, the majority of my users have absolutely
no problem using this form.  Just those very few.

Now, when I change this line:

 

to this:

 

(ie, remove the ENCTYPE="multipart/form-data"),

all of the POST data gets sent to the receiving page for those users.

What is going on?  Why is the POST data not getting sent to the server
when theENCTYPE="multipart/form-data"is included in the form
definition?  And why only for a very small subset of users?

Thanks for any insight you can give!

Chris



RE: [PHP] --enable-trans-sid and forms

2001-04-27 Thread Boget, Chris

> have you checked your PHP.INI file?
> it sais there what links to rewrite.

This is what is in my .ini.  

url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry" ;
added 3/2/01

Am I missing something here that I should have?  
I don't see anything in the docs about the above 
directive.
Also, note, as I said in a problem I posed in another 
thread, there are some links where the SID is added 
while there are some that it isn't added.  This happens 
in different pages, though.  So while there will be pages 
where *all* the links will have the SID added, there
will be pages where *none* of them have the SID included.  
(though, it is never the case where there is a page
where some have the SID included while some do
not)
And this could be one page right after the other.

This is very odd and *very* frustrating.

Chris



RE: [PHP] --enable-trans-sid and forms

2001-04-27 Thread Boget, Chris

> Here is what I see in my FORM with --enable-trans-sid:
> 
>  VALUE="cbf75d263416e77d773b1772f6e1be89">
> PHP is adding the HIDDEN field with the session id. For some 
> reason, it also appends it to the SRC attribute of the image submit 
> button, but doesn't add it in the ACTION url.

I'm not getting that, either...  This is sooo funky.  Sometimes
the --enable-trans-sid works and sometimes it doesn't.  I just
wish there was some consistency about it so I could trouble
shoot where the problem is coming from.
*sigh*.

Chris



RE: [PHP] --enable-trans-sid and forms

2001-04-27 Thread Boget, Chris

>   Its my understanding that PHP appends the SID on the 
> end of the URL regardless of weather its a form or not. If thats 
> not happening for you, check your php.ini and make sure you 
> have  session.use_trans_sid enabled.

It is enabled.  And it's being appended to most URLs (though, not 
all, but that's another problem I posted to another thread).  
However, it's not being appended to any of my form's actions.

Chris



[PHP] --enable-trans-sid and forms

2001-04-26 Thread Boget, Chris

If you have PHP compiled with --enable-trans-sid, 
are the URLs that are part of the form's action supposed
to be modified to include the SID?  So far that's not
been happening and I just want to verify that this is
expected behavior.

thnx,
Chris



RE: [PHP] Lines

2001-04-24 Thread Boget, Chris

> > If you use the file() function to open up the file, it will 
> > put each line of the file into an array.  At that point you 
> > can say:
> But how can i put into a var $total the total lines that i 
> have into the file?

After you've used the file() function as suggestion above,
the total number of lines in the file is:

count( $myFile );

Chris



RE: [PHP] link variables space problem in netscape

2001-04-24 Thread Boget, Chris

> Two words:
> URL Encode.

Actually, one word: urlencode();

heheheh

Chris



RE: [PHP] db to xls

2001-04-24 Thread Boget, Chris

> I want to query an oracle database and push the output to an MS
> Excel spreadsheet . Currently I am dumping it to a csv text file and
> reading into Excel.
> Is there a better way to do this?? Is there a php function for this ??

What I am doing is using PHP to generate an HTML table in the
format that I want to display the db results in.  Then, at the top
of this file, I include the following code:



Header("Content-Disposition: inline; filename=filename.xls");
Header("Content-Description: PHP3 Generated Data");
Header("Content-type: application/vnd.ms-excel; name='excel'");
flush();



The browser will get those headers, see that it's receiving an
excel file and proceed to launch Excel.  And Excel is good enough
to know and process HTML and your data is displayed appropriately.
It's very cool and very easy to implement.

Chris



RE: [PHP] Fatal Errors and Error Handling

2001-04-24 Thread Boget, Chris

> > > > > if (@foo_bar (42, 4711) == ERROR_CODE) {
> > > > >PrintXMLErrorMessage ();


> Well, we both are right. The snippet I suggested (top of this mail) 
> *will* work, because the @ operator doesn't mess with the return 
> value of  the function. 

That is correct.  However, the "== ERROR_CODE" suggests that
an error code will be returned by foo_bar().  However, that code
will be suppressed by the "@" symbol and that is what I was commenting
on... the fact that the above example couldn't be used if you wanted
to print your own error messsage.

> A custom error handling function installed via set_error_handler() 
> will *not* work because it won't get the error code.

Well, it will work and it will still be called.  However, the error code
passed to it will be '0'.

> But I never suggested using set_error_handler() :)

But the issue at hand was the fact that the original poster
was using, and needed to use, set_error_handler to handle
their own errors.

Chris



RE: [PHP] Fatal Errors and Error Handling

2001-04-24 Thread Boget, Chris

> > > standard we are
> > > if (@foo_bar (42, 4711) == ERROR_CODE) {
> > >PrintXMLErrorMessage ();
> > I do not believe the above will work.  When using the "@" symbol
> > in front of an expression, it makes it so that the error 
> > code that is returned is "0".  While writing my error handler class, 
> > in the
> Wrong. From 
> http://php.net/manual/en/language.operators.errorcontrol.php :
> --
> PHP supports one error control operator: the at sign (@). When prepended 
> to an expression in PHP, any error messages that might be generated by 
> that expression will be ignored.
> --
> The @ operator suppresses any error *message*, but leaves the return 
> value intact. Just imagine that with your interpretation in the following 
> snippet
> $conn = @mysql_connect(...)
> $conn would always be set to 0...

Wrong back.  From:
http://php.net/manual/en/function.set-error-handler.php


It is important to remember that the standard PHP error handler is 
completely bypassed. error_reporting() settings will have no effect 
and your error handler will be called regardless - however you are 
still able to read the current value of error_reporting() and act
appropriately. Of particular note is that this value will be 0 if the 
statement that caused the error was prepended by the @ error-control
operator. 


Using your example, $conn wouldn't be '0' but if any error that is
generated by mysql_connect, that error code/number (what you are
going to be looking for) will be '0'.  So if, in the original function
f00_bar(), it tried to return any error code/number, that code/number
would be '0' (zero) by nature of having the "@" operator prepended
to the function call.
You don't have to believe me.  Set up your own error handler and
see for yourself what error number you get when the "@" symbol
is prepended to an expression.

Chris



[PHP] Error Handling

2001-04-24 Thread Boget, Chris

Is there a good write up out there or can anyone offer
some insight to the rest of us as to how error handling
should be properly implemented?
Yes, PEAR has some error handling routines, but it
doesn't have any kind of information as to how it should
be "properly" implemented.  I've just finished writing a
pretty decent error handling class of my own but going
through my code, I see places where I can add the
trigger_error() function, but beyond that, I'm not sure
exactly how to process it all.
Up to now, I've just been doing some generic error
handling.  If a query fails, if a user enters the wrong 
value, I print out a message.  But now that I'm handling
all the errors, I'm finding that I'm getting so many more
messages from PHP than I was before.  For example, if
a variable wasn't "properly" initialized 

(ie, I'll get an error in this case:

$mode = "add";
if( $mode == "add" ) {
  $joe = "bob";

}

if( $joe ) {
  echo "You got here";

}

an error will be thrown by PHP saying that $joe is
uninitialized)

It's not as if that's a big deal.  It isn't.  But since I'm
getting more information than I need to actually give
the end user, it seems like kind of a daunting task to
start handling the errors myself.  It is something we
are going to need to do so I cannot put it off.  But I
am hoping that there is some sort of write up or tutorial
or something out there where I can learn from the
experience of others as to how something like this should
be done "properly".  I'd rather do something of this
magnitude right the first time.

As an aside,  in writing this class and seeing how PHP 
works in this regard, I've so much more respect for 
what PHP actually does behind the scenes with regards 
to error and syntax checking.  It was definitely a learning
experience.

Chris



RE: [PHP] Fatal Errors and Error Handling

2001-04-24 Thread Boget, Chris

> > My problem is that not displaying anything in case of an error is a
> > completely unacceptable solution. I *MUST* return a valid 
> > XML message in a predefined format. If not, I am violating the 
> standard we are
> if (@foo_bar (42, 4711) == ERROR_CODE) {
>PrintXMLErrorMessage ();

I do not believe the above will work.  When using the "@" symbol
in front of an expression, it makes it so that the error code that is
returned is "0".  While writing my error handler class, in the 
function that processes whatever error is triggered, I check to see
if the error code is "0" and if it is, I do nothing because there was
an "@" symbol prepended to the expression.
You can read more about this in the error handling section of the
documentation.

Chris



RE: [PHP] How to find the object name in a class?

2001-04-24 Thread Boget, Chris

> *sigh* I'm thinking so too ;(
> Doh!
> However, I have at least a usable hack around.
> In the constructor of your class, add:
> function Class ($object_name) {
> global $pge;
> $pge = $object_name;
> }
> Then when you use create a new object of that type you must use:
> $objectname = new Class('objectname');

Heh.  This is exactly what I'm doing as it was the only work around
that I could find, too.

> Then in your code you just use ${$pge}-> to refer to it.

Yup.  However, before I do this, I check to make sure $pge is valid 
before I use it.  Otherwise, all kinds of nastiness can occur.

What I'm doing this for is my error reporting class.  I'm using a
wrapper function that calls my class' errorHandler() method since
you cannot specify a class method as the handler function.  Kind
of funky.  But doing this was the only way I could get around it.

> Sucks, doesn't it?

Yup.  But I'm sure there is a reason for it.  Kind of like whatever
the reason is that we cannot actually get a variable's name.

I.E.

$joe = "bob";

we cannot get that the above variable's name is "joe".
Oh, well.

Chris



RE: [PHP] How to find the object name in a class?

2001-04-23 Thread Boget, Chris

> So is there ANY way to get the name of the object in PHP code without
> knowing the name of the object ahead of time?

I went through this exact thing not too long ago with an error class
I wrote.  Unfortunately, there is no way to know.  What you can do,
however, is do a check to see if that object exists before you access
the variable.  Other than that, I think you're outta luck. :/

Chris



RE: [PHP] --enable-trans-sid

2001-04-23 Thread Boget, Chris

> I wasn't able to find this in the docs, so could someone
> tell me exactly how --enable-trans-sid is supposed to work
> behind the scenes?
> while it won't for this url:
> 
>  target="_top">here

I've also tried...

here

> > It makes no sense to me...
> Any help would be greatly appreciated!!

Ok, I found one of my problems but I didn't find the other.
Again, I have 2 frames.  The above link is in the left frame.
In the frame, in the actual page, I'm printing out the the
value of $PHPSESSID and it is showing a value.  So I know
the session has been started.  I click on the above link to
get to the next page and the next page isn't getting the 
$PHPSESSID passed to it.  
I have --enable-trans-sid turned on and it's working in most 
places.  However, it's not working in all places.  Can anybody
guess as to what is going on?  Why wouldn't PHP automagically
transmit the SID to the next page (append it to the href) as
it should with --enable-trans-sid turned off.

One last thing of note - this works when cookies are turned
on.  The $PHPSESSID gets set as a cookie and it's all good.
Now, I'm going through my pages with cookies turned off
to make sure that nothing in the site breaks... I want to 
make sure users w/cookies turned off can use my site, too.
In doing this I made the following configuration settings:

IE: Tools->Internet Options->Security->Custom Level->
Cookies and I said disable for both:
"Allow cookies that are stored on your computer"
"Allow per session cookies"

NS: Edit->Preferences->Advanced->Disable Cookies

Again, any help would be greatly appreciated!

Chris



[PHP] Associative arrays in strings

2001-04-23 Thread Boget, Chris

We have an array:

$myArray = array( "joe"=>"bob", "this"=>"that" );

I know that technically, you shouldn't do the following
to print it out:

echo "Here is a $string, $myArray[joe] with $alot of PHP $variables";

If you have the highest error level on, PHP will display 
an error though if you don't, it makes some assumptions
for you and goes on it's merry way.  Now, supposing you
do have error level set to very high, you cannot do this:

echo "Here is a $string, $myArray['joe'] with $alot of PHP $variables";
(using single quotes)

to stop the error.  You actually have to do this:

echo "Here is a $string, " . $myArray["joe"] . " with $alot of PHP
$variables";

While that works, it makes the code look very fragmented.  
And if you have *alot* of stuff like that all over your page, 
it could get very difficult to read.

First question: Why doesn't the single quote example work?

Second question: Is there any other way (aside from setting
the error level down; we are already doing that and these
questions are purely academic) to do this so the code doesn't
look as fragmented?

Chris



  1   2   3   >