[PHP] htmlentities, links, javascript

2004-04-12 Thread Beau Hartshorne
hi all,

i have a script that calls a popup like this:

a href=/popup.php?name=Choicesamp;product_id=15 
   target=_blank 
   onclick=openWindow(this.href,600,200,'yes'); return
false;Choices/a

the amp; is there to make sure the page validates. the problem is that
some browsers seem to be incorrectly translating this to:

[REQUEST_URI] = /popup.php?name=Choicesamp;product_id=15

instead of:

[REQUEST_URI] = /popup.php?name=Choicesproduct_id=15

a couple of browsers that have choked on this:

[HTTP_USER_AGENT] = Mozilla/4.0 (compatible; MSIE 4.0; Windows 95)
[HTTP_USER_AGENT] = Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-us)
AppleWebKit/103u (KHTML, like Gecko) Safari/100

i have safari 1.2.1 installed on one of my development machines, and
have had no trouble with the bad REQUEST_URIs. does anyone have some
insight into the problem?

i've posted a demonstration here:

http://hartshorne.ca/sandbox.php

you'll have to view the source of the popup to see if the  was
translated properly.

thanks,

beau

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



RE: [PHP] IE6 with latest hotfixes breaks forms ...

2004-03-01 Thread Beau Hartshorne
Marc:

This could be related to the problem I described in detail a few days
ago. Here was my solution:

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

Please let us know if this helps!

Beau

 We're having a weird problem with some of our PHP forms, 
 where, when a client uses IE6 with the latest hotfixes, they 
 are reporting that have to re-submit a couple of times for it 
 to take ... as if somehow the data isn't being passed down 
 properly to the FORM/ACTION ...
 
 We're using sessions to pass the data around, and it seems to 
 work with every other browser we've used, including IE6 
 previous to the latest hotfixes ... but, could it be 
 something that *we* aren't doing right, or is there a known 
 bug with sessions + IE6?  Some sort of work around?

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



RE: [PHP] PHP or MSIE Problem? -- SOLVED

2004-02-22 Thread Beau Hartshorne
I described a situation where MSIE for Windows would not post all of a
form's fields under fairly unique circumstances. This problem occurs in
MSIE 5, 5.5, and 6 (with the most recent hotfixes applied). No other
browsers seem to be affected. When:

1. A form is submitted with the enctype attribute set to
multipart/form-data.

2. No http header is sent to explicitly select a character encoding that
matches form input, or if the http header and xml prolog and/or meta
http-equiv=content-type tag do not select the correct character
encoding[1].

3. The user has input a character into one of the form fields, such as
[TM], a curly quote, or some other character that could have been
copy-pasted from a word processor, that is not defined in the character
set identified by some combination of an http header, xml prolog, and
meta tag.

4. There is at least one unchecked checkbox on contained in the form
(thanks Pablo!).

MSIE will not return all of the name/value pairs sent in the posted form
to the server. If you check the checkbox, the form will post normally.
The earliest reference to this problem that I could find was in a German
Usenet post[2,3], where the special character was the Euro sign.
Although the behaviour is a little buggy, we can't blame MSIE for
getting it wrong.

I've posted a new version of my page that sends the correct header:

?php header('Content-type: text/html; charset=utf-8'); ?

And that uses the correct meta tag:

meta http-equiv=content-type content=text/html; charset=utf-8 /

I've omitted the xml prolog because of other problems that it can cause
with MSIE 6.

The page is still posted here:

http://hartshorne.ca/sandbox.php

Thanks!!

Beau

1. http://ppewww.ph.gla.ac.uk/~flavell/charset/checklist
2. http://ppewww.ph.gla.ac.uk/~flavell/charset/form-i18n.html
3.
http://groups.google.com/groups?selm=afmkl9%24fghgm%243%40ID-16486.news
.dfncis.de

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



[PHP] PHP or MSIE Problem?

2004-02-20 Thread Beau Hartshorne
All,

When I submit a form from MSIE, under certain circumstances some of the
fields don't make it into the $_POST array. I am building a CMS that
accepts images and text entered into an HTML form. If I submit a form
from MSIE, and if the text contains special characters (like T [TM] for
example), some of the $_POST fields are not populated in PHP. This
problem does not occur on Mozilla or Safari.

The php version is 4.3.4, and is running on Linux. The MSIE version is
6.0.2800.1106.xpsp2.030422-1633. Here's a demonstration of the problem:

http://hartshorne.ca/sandbox.php

Can anyone tell me if this is a common problem? Is this a purely MSIE
bug, or could PHP be a factor?

Thanks!!

Beau

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



RE: [PHP] Cleaning up HTML table structure

2003-03-10 Thread Beau Hartshorne
Jens,

I would suggest that you try writing a script that keeps track of how
many tags have been opened (look for ), versus how many tags have
been closed ([^]*/) on a line-by-line basis. Using that number, you
should be able to indent the code properly.

Let us know what you've got so far.

Beau

 table ... 
tr ... 
  td ... 
table ...
  tr ... 
td ... 
  ...
/td
td ... 
  ...
/td
  /tr
/table
  /td
/tr
 /table



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



[PHP] instantiating objects

2003-02-06 Thread Beau Hartshorne
I'm just starting to use PEAR, and have seen several ways of
instantiating the PEAR objects:

$form = new HTML_QuickForm();
$form = new HTML_QuickForm();
$dbh = DB:connect(dsn);
$dbh = new DB();
$mail_object = Mail::factory('sendmail', $params);

Can anyone explain (or point to dome docs that explain) what the
differences are, and when I should be using which method to work with
PEAR objects?

Thank you,

Beau



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




[PHP] php and file uploads/downloads

2002-12-03 Thread Beau Hartshorne
Hi,

I'm working on a system that allows users to upload and then download
pdf files. Each file is related to a mySQL database entry. To keep
things simple and consistent, I'd like to store the pdf files like this
on the server:

[PRIMARY_KEY].pdf

But when a user downloads the file, I'd like them to receive something
like:

[TITLE].pdf

Is there a way to get php to rename the file when a user tries to
download it?

TIA,

Beau



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




[PHP] writing functions to preform mysql queries

2002-11-22 Thread Beau Hartshorne
Hi,

I'm trying to separate my database query code from my application logic.
I want to do this by creating a small application-level library with
functions that INSERT, DELETE and UPDATE specific information in a mysql
database. So I created a file called  news_mysql.lib.php and put it in a
/library directory. It has functions that look something like this:

function get_news_item($id)
{
// boundary and error checking, strip out potentially nasty SQL
stuff
// build the SQL statement
$result = $mysql_query($sql);
return mysql_fetch_array($result);
}

// and so on...

My news.php file looks something like:

require_once('path/to/library/news_mysql.lib.php');
$id = $_GET['id'];
$news_item = get_news_item($id);
if (count($news_item) = 0) {
echo 'h1Error/h1'; // deal with the error
} else {
echo 'h1' . $news_item['headline'] . '/h1';
echo 'h4' . $news_item['date'] . '/h4';
echo 'p' . $news_item['body'] . '/p';
}

// and so on...

This works great for UPDATE, INSERT and DELETE statements, but not so
well for SELECT statements that return more than one row.

The first problem is that mysql_fetch_array() works so well for stepping
through the mysql result set, but I don't know how to duplicate it's
functionality in a library function.

The second problem is that even though I might SELECT information from
the same table in a database several times in my application, each time
the query might be a little different. Sometimes I want the information
sorted in a certain way, for example. So I don't want to use a bunch of
bit flags to identify exactly which information I need.

The best I can come up with is to make an exception for the one function
that will return more than one record, and get it to accept an SQL
string as input (instead of a couple parameters), to return a mysql
resource identifier, and then to use mysql_fetch_array on that resource
identifier and step through the results in a while loop as I would
normally.

What's the better way of doing this?

Thank you,

Beau



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




[PHP] php programming style

2002-11-21 Thread Beau Hartshorne
Hi,

I'm curious if it's bad coding style for a function to return a value on
success, or simply false on fail. Here's what I mean:

?php

function foo($number)
{
if (is_numeric($number)) {
return $number . ' is a number.';
} else {
return false;
}
}

if ($string = foo(1)) {
echo $string;
} else {
echo 'error';
}

?

Is this ok?

Thank you,

Beau



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




RE: [PHP] php programming style

2002-11-21 Thread Beau Hartshorne
 I think that some of the above question might help you out. However,
 from a programming standpoint i like to make sure that my functions
 return the same type at least.  Some feel different about this and
 return various type (ie, int, strings, arrays)...

I agree that it should return a consistent type. I was planning on
returning a populated array on success, or a boolean false on fail.
Instead, I will return an empty (but initialized) array on fail, and use
the count() function to test for failure like this:

?php

function foo()
{
/* if the result set is empty */
return array();
}

$my_array = foo();

if (count($my_array) = 0) {
// nothing in array
echo 'nothing';
} else {
// do something with data
echo 'something';
}

?

Beau



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




RE: [PHP] Output Buffering - Am I using it correctly?

2002-09-25 Thread Beau Hartshorne

 I guess that this means I am out of luck here. Anyone know a cleaner 
 method for delivering spreadsheets?

Can you get the server to write it to a file, and then let the client
download the file normally?

Beau



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




RE: [PHP] Output Buffering - Am I using it correctly?

2002-09-25 Thread Beau Hartshorne

 Can you get the server to write it to a file, and then let the client
 download the file normally?
 [/snip]
 
 Believe me, if I could have taken that way out I would have done it. I
am
 researching some classes, but they all seem to take just as long to
create
 the spreadsheet.

What about something like this:

1. Script loads. Script writes everything to some file.
2. Script is finished writing everything to file.
4. Script does a browser redirect and the user starts downloading the
file normally.

It just seems like the server doesn't want to have to deal with
streaming a large database result set to a web browser.

Beau



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




RE: [PHP] Is php even right for this design?

2002-09-20 Thread Beau Hartshorne

 The admin users will need to run long processes that take about 
 5-15 minutes each.  They cannot timeout and they must be done
throughout the day
 while general users are working in the application as well.  Is 
 there a big problem with this?  What steps should I take to ensure 
 these long processes complete and do not timeout.

What about turning these long processes into perl scripts or C programs
that can be exec()ed? They'll probably run faster, and they won't time
out.

I've never done this myself. It's just a suggestion -- does it make
sense to do it this way?

Beau



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




RE: [PHP] PHP Execution Timer

2002-09-19 Thread Beau Hartshorne

This function:

function getmicrotime()
{
list($usec, $sec) = explode( ,microtime()); 
return ((float)$usec + (float)$sec); 
}

is provided on this page:

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

and is needed for the code below to work properly.

Beau 

 ?
 $timerOn = 1; // set to 0 if you want to turn it off $timestart = 
 getmicrotime(); ?
 
 
 Bottom:
 
 ?
 if($timerOn)
 {
 $timeend = getmicrotime();
 $timer = $timeend - $timestart;
 echo timer: $timer;
 }
 ?
 
 Similar things could be done with MySQL quereies, but I haven't looked

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




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




[PHP] Session problems: Warning: write failed: Disk quota exceeded

2002-08-21 Thread Beau Hartshorne

Hi,

Recently, my php app has started to throw these warnings:

Warning: write failed: Disk quota exceeded (122) in Unknown on line 0

Warning: Failed to write session data (files). Please verify that the
current setting of session.save_path is correct (/tmp) in Unknown on
line 0

I narrowed it down to this code:

?php
session_start();
session_register('anything');
?

(A test file containing only that will throw those two warnings.)

The php version is 4.2.2. This script is running in a shared hosting
environment. My guess is that the ISP has misconfigured php, and has not
set the appropriate permissions to the /tmp directory.

Does this make sense? Or is there something that I've missed?

Thank you,

Beau



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