RE: [PHP] [newbie] Can PHP be a security risk if it's just connecting to MySQL?

2004-05-18 Thread Dave G
John,

 If that text is not properly validated and escaped, you could 
 be open to SQL Injection attacks
...
 you could be open to Cross Site Scripting attacks

After reading your response, I looked the web to determine what
you meant by properly validated and escaped.
From what I understand, properly validated means that you
restrict the entry as much as possible down to what would be the length
and form of input you expect. For instance, ensuring that email
addresses have an @ mark, no spaces, a valid TLD and are limited in
length and that sort of thing.
I'm less clear on what properly escaped means. I thought
escaping was a matter of putting slashes before special characters, so
that their presence doesn't confuse the SQL queries one might run. Is it
possible that if one has taken at least that much precaution that a user
could still enter malicious script held in a TEXT column?

I'm not totally sure I have the concepts right, but in any case,
would anyone be willing to explain a little further what one would do to
ensure proper validation and escaping of text input from users in
order to increase security?

-- 
Yoroshiku!
Dave G
[EMAIL PROTECTED]

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



[PHP] [newbie] Can PHP be a security risk if it's just connecting to MySQL?

2004-05-17 Thread Dave G
PHP Listers,
I was just reading about Hardened PHP, and the debate between
those who thinks it's a good idea and those who think it will allow for
lazy coding. I'm firmly of the belief that any new security feature is a
good thing. If for no other reason that it will help me stay secure
while I am in the process of learning how to be more secure on my own.
But one question that came up in my mind while reading about PHP
security is exactly where does the risk lie? Specifically, I wonder if
in my own case if there is much of a risk. I almost exclusively use PHP
to draw from data held within a MySQL database on the same server. I do
not allow users to upload files. I suppose the most that I allow users
to do is input some information like email addresses, user names and
passwords. But it seems to be harmless text that gets stored in the
database. I can't see how it could be manipulated to store and/or
execute a script of any kind.
Are there open ports to access PHP that I don't know about?
Wouldn't someone have to be able to telnet in before doing anything with
PHP (and if they had got that far, would they even need PHP to do their
damage)?
I must be missing something. It seems to me that all of what PHP
does, or at least what I use it for, all takes place on the server
without doors for user access. Either my use of PHP is limited to a
fairly small section of it's capabilities and so I don't encounter
risks, or there is some other route to access PHP functions that I'm not
aware of.
Can someone please shed a little light on this matter? Naturally
I want to try and be as secure as possible.

-- 
Yoroshiku!
Dave G
[EMAIL PROTECTED]

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



RE: [PHP] SMTP and changing the character set

2004-05-08 Thread Dave G
Todd,

 Is there a way to specify a character set in a SMTP email?

I've found that SMTP is really, really very particular about how you
apply spacing and carriage returns when passing a content type header
from PHP. In the PHP mail() function, you want to add the content type
header like so:

?php
$contentType =  \r\nContent-Type: text/plain; charset=UTF-8;
mail($toaddress, $subject, $mailcontent, $contentType);
?

In particular, take note of the space before \r\n. Without it, the
content type header would not work. I had to do a lot of experimenting
before I discovered this. You may have to some experimenting as well, as
I'm not sure if all servers behave the same on this issue.

Hope that helps.

-- 
Yoroshiku!
Dave G
[EMAIL PROTECTED]

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



RE: [PHP] why doesn't this work ?

2004-04-18 Thread Dave G
 Why cannot I embed php in html files?

I'm relatively new to PHP, but I am fairly sure that it is
possible to have PHP embedded in .html files, as my web hosting service
accomplishes exactly that. I believe it's just some kind of setting in
Apache or somewhere else that you or your web hosting service can
configure.
On my web hosting service, the file can have a .html extension,
but there must be ?php ? tags at the very beginning of the file, on
the very first line before absolutely any HTML code, including doctype
headings. If you want your PHP to work it's magic somewhere else in the
page, and not at the very beginning, it's no problem, just put some
harmless bit of code at the beginning, and then place whatever it is
that you really want to do within separate ?php ? tags where you want
it.
Personally, because I work with software that generates
templates for all my web pages, I put the following code at the start of
every page:
?php
session_start();
?
I chose session_start as a command because I often need
sessions, and if there is a session, it needs to happen before the HTML
head tag anyway. If one of the pages based on my template doesn't have
a session, or even if it doesn't use any PHP at all, then the HTML
parser seems to just ignore the ?php ? tags and whatever is in it and
output the .html file no problem.

Bottom line - speak to your web hosting service about
configuring .html files to be parsed by the PHP engine. If you're
running your own server, then you'll need to consult someone more
advanced than I. Also, I can't ensure there aren't any errors or
drawbacks to my advice, I'm just relaying how my web hosting service
seems to handle the issue.

Hope that helps.

-- 
Yoroshiku!
Dave G
[EMAIL PROTECTED]

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



RE: [PHP] Fill strings with nbsp;

2004-03-22 Thread Dave G

 I was searching for a php function which fills empty spaces in string 
 varibales with nbsp;, but could not find one.

Wouldn't str_replace do it?
http://jp2.php.net/str_replace

-- 
Yoroshiku!
Dave G
[EMAIL PROTECTED]

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



RE: [PHP] Slight cleaning of code needed in str_replace command.

2004-02-23 Thread Dave G
Jason,
Have no worries, I'm not looking for anyone to write my code for
me. It's precisely because the str_replace command is so simple that I
figure if the results are strange that there is something I don't
understand. And I want to understand it, not just be given code to copy
and paste.
As it turns out, by experimenting with the var_dump() command
that you recommended (which I wasn't aware of), I learned that what was
going wrong was that the line breaks coming out of my MySQL DB aren't
just \n, but \r\n. So swapping around the elements I was replacing, and
experimenting, was not going to do me much good until I knew this.
So now it's working, and largely thanks to the suggestions you
gave. I would never have been able to guess on my own at using
var_dump() in order to get at the solution. Please don't assume that
just because a query is simple that it means that the person asking is
not willing to work or that they haven't already attempted to work at
it. Sometimes it just means that the person asking doesn't know all the
angles possible.

Thanks for your help.

-- 
Yoroshiku!
Dave G
[EMAIL PROTECTED]

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



RE: [PHP] Slight cleaning of code needed in str_replace command.

2004-02-21 Thread Dave G
 Well, you asked for it. The usage of str_replace() is not 
 exactly rocket 
 science, since the output is not what you expected just 
 juggle your search  
 replacement strings until it does what you want.

It's not as if I haven't experimented with different settings, but they
haven't been successful.
In any case, rocket science or not, I was actually looking for advice
that might help me understand the logic behind the command better. I
can't see anything syntactically wrong with the string I have put
forward, so my current assumption is that there is something I don't
understand about how the string input going into the command is parsed
(it comes from a MySQL query), or about how the command interprets line
breaks.

Perhaps someone could offer something a little more concrete than
essentially recommending I just 'try different stuff'.

-- 
Yoroshiku!
Dave G
[EMAIL PROTECTED]

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



[PHP] Slight cleaning of code needed in str_replace command.

2004-02-20 Thread Dave G
PHP listers,
I recently got some help here to fix a str_replace() command.
The string works, and the output from the browser looks right. However,
I would like to further tweak the code so that the HTML source is also a
little cleaner than it is now.
The code in question is this:
$charInfoCss = p class=\content\ . str_replace(\n, /p\np
class=\content\, $charInfo[introE]) . /p;
echo $charInfoCss . \n;

The way this outputs to the HTML source is like this:
p class=contentblah blah blah blah
/p
p class=contentblah blah blah blah
/p
p class=contentblah blah blah blah
/p

Shouldn't the syntax that I have place the new line *after* the
/p tag? I'm trying to get it to look like this:
p class=contentblah blah blah blah/p
p class=contentblah blah blah blah/p
p class=contentblah blah blah blah/p

Any advice would be most welcome.

-- 
Yoroshiku!
Dave G
[EMAIL PROTECTED]

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



[PHP] str_replace to replace /n with p not having desired effect.

2004-02-19 Thread Dave G
PHP Listers,
I am trying to use str_replace to format text taken from a MySQL
TEXT field and make it so that it is compatible with my CSS formatting.
Essentially, I want to ensure that new lines are replaced with p tags
with the appropriate CSS class designation.
The code I have created with assistance from information found
on the web, looks like this:

$charInfoCss = 'p class=content' . str_replace('\n', '/p\np
class=content\n', $charInfo[introE]) . '/p';

The output looks like this:
p class=contentBlah blah blah blah.
Another line of blah blah blah.
A third line of blah blah blah./p

The output I desire is this:
p class=contentBlah blah blah blah./p
p class=contentAnother line of blah blah blah./p
p class=contentA third line of blah blah blah./p

How do I correct my code to accomplish this?

Thank you.

-- 
Yoroshiku!
Dave G
[EMAIL PROTECTED]

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



RE: [PHP] str_replace to replace /n with p not having desiredeffect. [SOLVED]

2004-02-19 Thread Dave G
 From: Adam 
 Single quotes don't work for the escape characters.
 Use double quotes around the str_replace where there is a \n.
and...
 From: Richard
 Double-bag it:
 str_replace(\n, /p\np class=\content\\n, $charInfo[introE])

It's always the simplest of mistakes that one overlooks.
Thanks guys! That's done the trick.

-- 
Yoroshiku!
Dave G
[EMAIL PROTECTED]

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



[PHP] eregi filter stopping valid email address, part two

2004-01-06 Thread Dave G
PHP Gurus

A while ago on this list I posted a few questions about an eregi
filter for email addresses entered into a form. With the help of people
on this list, I settled on the following code which has worked fine in
the months since I started using it. The code is this:

eregi('[EMAIL PROTECTED]', $email)

But recently, a person was unable to get their email to pass
this eregi test. The email is valid, as they are able to send email to
me. It has the following format:

[EMAIL PROTECTED]

Shouldn't this email pass? I've allowed for hyphens after the @
mark. Is it that there are two many periods?

-- 
Yoroshiku!
Dave G
[EMAIL PROTECTED]





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



RE: [PHP] eregi filter stopping valid email address, part two

2004-01-06 Thread Dave G
Mike,

 No.  You've only allowed for hyphens in the first element 
 after the @ sign
 -- this address has them in the 2nd element.

Ah, yes, I guess I had it that way because there are no hyphens in top
level domain designations, but hadn't accounted for the fact that it
would exclude them if there were more elements.
Thanks for pointing that out.

John,
Thank you for pointing out the period matching problem! I will
adjust my syntax as you suggest.

Manuel,
The classes you recommend are probably more robust than what I'm
accomplishing on my own. I will look into using them. Thank you for the
link.

-- 
Yoroshiku!
Dave G
[EMAIL PROTECTED]

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



[PHP] Is a while loop the most efficient way to send out multiple emails?

2003-12-30 Thread Dave G
PHP Gurus,
I currently run a few newsletters that go out to small groups of
50 to 100 people. I use a while loop to send out the emails. I chose a
while loop as opposed to just taking all the emails and putting them in
the CC field because I wanted to personalize each email with a greeting
that included the recipients name and other personalized information. It
looks like:
while ($member = mysql_fetch_array($sqlQueryResult)
{
$content = Hi, {$member[name]}. Your email address is
{$member[email]};
mail ($member[email], $subject, $content)
}
When I execute my script, it takes a little time to go through
about 50 people. I'm not sure exactly, but maybe ten seconds, possibly
as high as twenty.
Soon I will be creating a script to send out an email to 500
people, with the possibility that it will grow to 1000. I'm concerned
that the while loop will take ten times as long, and not only be a drain
on the server, but also run the risk of my browser timing out waiting
for a response to confirm all mails were sent.
So my question is, is there a way more efficient than while
loops to send out multiple emails with personalized information? Is it
the mail() command that takes time, or the mysql_fetch_array(), or both?
Any suggestions would be greatly appreciated.

-- 
Yoroshiku!
Dave G
[EMAIL PROTECTED]

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



RE: [PHP] How do I make these two MySQL queries into one line? [SOLVED]

2003-12-24 Thread Dave G
Chris,
Thank you! I will look on the net for left joins, which is a
bit new to me, and I'll join a MySQL list, since I can see I'm going to
have more MySQL questions in the future.
Your reply is much appreciated, especially since it came so
fast!

-- 
Yoroshiku!
Dave G
[EMAIL PROTECTED]

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



[PHP] How do I make these two MySQL queries into one line?

2003-12-23 Thread Dave G
PHP Gurus,
I'll consider myself lucky to get a response so close to
Christmas, but here goes.

I have two tables. One contains member information, and one
lists which groups the members belong to. I want to select the email
address of active members from the member information table, and I want
to select only the members which belong to a particular group. Right now
I can only think to accomplish this in two lines:
$query1 = SELECT member_id FROM groups WHERE group_id = .
$chosenGroup
Then, take the results and do another query:
$query2 = SELECT email FROM members WHERE active = yes AND
member_id = . $query1Results

But surely there's a way to collapse this into one MySQL line.

-- 
Yoroshiku!
Dave G
[EMAIL PROTECTED]

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



[PHP] Why won't this form post session variables?

2003-12-21 Thread Dave G
PHP Gurus,
I'm really stuck here. I've written the following code, and it
will never execute the if statement. I keep getting the form displayed,
and when I fill the form and hit the submit button, the
HTTP_SESSION_VARS array does not seem to take any of the values set out
in the form.
Is there an error in this code? I've checked and double checked,
but I can't see why the variables wouldn't post. Any advice much
appreciated.

session_start();
if(isset($HTTP_SESSION_VARS['episodeTitle']) 
isset($HTTP_SESSION_VARS['episodePP']))
{
$episodePP=addslashes($HTTP_SESSION_VARS['episodePP']);
$episodeTitle=addslashes($HTTP_SESSION_VARS['episodeTitle']);
db_connect();
$insertPPQuery = INSERT INTO scripts (title, plotpoints) VALUES ( .
$episodeTitle . ,  . $episodePP . );
$insertPPResult = mysql_query($insertPPQuery);
unset ($HTTP_SESSION_VARS['$episodeTitle']);
unset ($HTTP_SESSION_VARS['$episodePP']);
echo 'Your episode, ' . $episodeTitle . ', has been saved. Would you
like to a href=addplotpoint.phpadd another episode/a?';
}
else
{
echo 'Enter in a new episode in plot point form.brbr';
echo 'form action=thispage.php method=post name=newPPbr';
echo 'Title:br';
echo 'input type=text name=episodeTitle size=75br';
echo 'Text:br';
echo 'textarea name=episodePP rows=10 cols=55/textareabr';
echo 'input type=submit name=submitButton value=Upload';
echo '/form';
}

-- 
Yoroshiku!
Dave G
[EMAIL PROTECTED]

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



RE: [PHP] Why won't this form post session variables? [SOLVED]

2003-12-21 Thread Dave G
Martin,

 If they're coming from a form, then they would appear in the $_POST or
 $HTTP_POST_VARS variables, not the $HTTP_SESSION_VARS variable.

Aha! Yes, that was it! Thank you for helping get my script to
work and also giving me that much more insight into session and post
variables. And so quickly, too!
Much appreciated!

-- 
Yoroshiku!
Dave G
[EMAIL PROTECTED]

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



[PHP] PHP and Palm Pilot interaction

2003-12-15 Thread Dave G
PHP Gurus,
I have a web site that helps people sign up for workshops and
classes. The classes happen away from any computer or web access. What I
want to do is be able to collect data about payment and attendance and
be able to send it to the web site for inclusion into the MySQL
database.
Of course, I could go low tech and just have people write things
down and then later type in results when they finally get web access.
However, if possible, I would like to take advantage of the fact
that the teachers of these classes all carry Palm Pilots. If it were
possible, could they record data in some fashion that would allow them
to copy the data over to their PC when they hot synch, and then upload
it to a page where it would automatically be integrated into the site
database.
I have only the faintest notions about how this could work, and
I suspect it may simply not be possible.
But on the other hand, I was wondering if it may be possible to
make use of the simple text editor on the Palm, or perhaps the newer
Excel editors (which I have not yet tried), to create a file of flat
data which could then be uploaded and interpreted by PHP and then
entered into the DB. It seems to me that a simple text file would
probably be easy to upload and read by PHP, but then I'd have to do more
work to get the teachers to conform to layout standards and do more
error checking since the text file allows for a wide range of mistakes
to happen. The Excel file would make it easier for the teachers to see
where to enter data and have less mistakes, but then it might be more
difficult to get the data out of it, through PHP, and into the database.
If anyone has any pointers or advice about how to best approach
this problem, please let me know.

-- 
Yoroshiku!
Dave G
[EMAIL PROTECTED]

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



RE: [PHP] ereg is failing on this simple test

2003-12-12 Thread Dave G
 Why is this test failing?
 If (ereg(^[a-zA-Z0-9\s.\-_']+$, $data)) {

I'm very new to PHP, so I may be barking up the wrong tree, but what is
that s doing after the slash? I don't know if it's the cause of the
problem, but as far as I know it's superfluous.

-- 
Yoroshiku!
Dave G
[EMAIL PROTECTED]

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



[PHP] [OT MySQL] Syntax for selecting within a range of time from database

2003-12-04 Thread Dave G
PHP Gurus,
What I'm trying to accomplish can be done in PHP, but someone on
this list told me once that it's far more efficient to try and do as
much on the MySQL side as possible. But I'm not really enough of an SQL
guy to join an SQL list, so I hope I can be forgiven this posting here.
I'm looking right now at mysql.com's online manual, at the date
and time functions page. I'm pretty sure it is describing the function I
need, but I can't quite understand how they describe the syntax.
What I have is a table which contains a series of events which
have a field that specifies the date on which they occur. I have two
fields to specify the workshop. One is a date field, which specifies
year, month, and date. Then I have a separate time field for the start
time of the event, specifying hours and minutes.
What I want to be able to do is select an event based on whether
or not the start time is within 3 days from now.
What's got me confused are two things:
1. How do I combine the two fields in one SQL query in order to
make a complete start time useful for comparing dates? 
2. I think INTERVAL is the command I want to use. Is what I'm
after something like the following (I put in question marks where I'm
not sure how that variable would be formed)?
SELECT date(?) FROM table WHERE DATE_ADD(now(?), INTERVAL 72
HOURS)

-- 
Yoroshiku!
Dave G
[EMAIL PROTECTED]

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



[PHP] Finding array in MySQL (I'm not asking the right question)

2003-12-02 Thread Dave G
PHP Gurus,
What I'm trying to do must be both common and simple, but I'm
not asking the question right because I can't find the answers in Google
or the online PHP manual using the search words like array, find, PHP,
MySQL, etc...
I have an array, and I want to select the fields in a table that
match the contents of the array.
The array consists of a set of user IDs. I want to find their
emails from the table in a MySQL database which stores all their contact
information. Sounds simple, right?
Well, SELECT email FROM table WHERE id =  . $array . );
isn't cutting it.
I'm a total beginner, but I can understand why this doesn't work
without being able to fix it. The data inside the array needs to be
extracted into the set of ids it contains so that MySQL can read it. So
I could run a while() loop and query the database for each id in the
array, but that's obviously totally inefficient.
There must be a command which handles this kind of thing. It's
not explode(), it's not in_array()... I know what I'm after, but I just
can't come up with the search term or phrasing which will allow a search
engine to help me find it.
Can someone please point me in the right direction?

-- 
Cheers!
Dave G
[EMAIL PROTECTED]

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



RE: [PHP] Finding array in MySQL (I'm not asking the right question)

2003-12-02 Thread Dave G
 Is this method faster than just using IN and implode()?

Thanks to all who replied. I believe I have found what I'm looking for
in using the implode() command.

My assumption is that it was faster and more efficient to try and do as
much processing on the PHP side and make as few queries to the database
as possible. Is that a correct assumption, or am I wrong there?

-- 
Cheers!
Dave G
[EMAIL PROTECTED]

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



RE: [PHP] Finding array in MySQL (I'm not asking the right question)

2003-12-02 Thread Dave G

 Totally wrong ! It's always better to have maximum work done by MySQL

So does that mean that this:

 $countUser = count($arrayUser);
 for($i = 0; $i  $countUser; $i++){
   $sql = SELECT email FROM table WHERE id = ' . $arrayUser[$i] .
 ' ;
 }

... is faster than this:

 SELECT email FROM table WHERE id IN (' . 
 implode(',',$array) . ');

... ?

-- 
Cheers!
Dave G
[EMAIL PROTECTED]


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



RE: [PHP] Add Reply-To to this list(s)

2003-11-26 Thread Dave G
To start out, I'd just like to make an observation. I've noticed
that some people in this thread have said how this argument has come up
many times, and they would even prefer that people look in the archives
to see what the results were of previous discussion. I find the fact
that the topic has come up multiple times in itself indicative of what
natural human expectations are. On the lists I belong to where responses
go only to the list, this topic has never come up before. Some lists I
have been on for years and years, and I swear this is the first time I
have ever encountered this issue, here on this list which uses this
system.

Before I pick out some statements that I'd like to comment
directly on, I wanted to point out a trend I've noticed which is an
assertion that people who do not like the reply-to-the-author approach
as opposed to the reply-to-the-list approach do not understand how to
use it properly. Or they do not know how to properly use the reply to
all button, or other nonsense.
I understand this list, my mail software, and the theory behind
the reply-to munging debate very well. Non comprehension or ability are
not at issue here. Don't assume that non-agreement equals non
understanding.

My opinion is that this is a multi person discussion forum, not a
person to person forum.
I agree very strongly with this statement, and most of the email
that follows it. If someone posts a question, and gets a private email
solving the problem, how does everyone else benefit?
I want other people's answers to be on this list so I can learn,
and I want my answers to go to the list so that other people may build
on it and add more useful commentary.

If you would stop using M$ Outlook and switch to a better mail
client...
MS Outlook suffers from code bloat, but that does not mean it
does not successfully do the task that I acquired it for, which is to
receive, send, and filter my email, every day. And it has successfully
handled the many mailing lists I belong to, including this one. Blaming
the email client is just bias against brands.

Just to add an authoritative answer here.  Mucking up the reply-to
header is simply wrong.  I don't really care what arguments you come up
with...
This seems to describe the tone of the debate. The idea of an
authority on a matter that is incapable of considering alternate
viewpoints seems oxymoronic to me.

-- 
Cheers!
Dave G
[EMAIL PROTECTED]

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



RE: [PHP] Add Reply-To to this list(s)

2003-11-26 Thread Dave G
Edwin,
I read the articles you pointed out. I'm sorry, but I still have
not seen any argument that makes me think that the reply-to-the author
option is better. In another posting I've put forth some of my reasons.

And, what is your opinion regarding Reply All?
Reply all is very useful sometimes. In the case of this mailing
list, however, I see it as redundant. If I hit Reply All, then the
person I'm responding gets it twice. Once directly, and once on the
list, as this mail I'm writing now does. Since you will get this via the
list, why do you also want to get it directly? 
In any case, no one is saying that Reply All should be deleted
as an option. The more options the better - respond to the list, the
list and the author, the author only... all these options should be
readily available. The debate is over what is the default behaviour. I
maintain that the point of a list is to have open discussion, that
people join precisely for the advantage of participating in a group, and
so the postings should default to going to the group, with secondary
options for posting off list.

-- 
Cheers!
Dave G
[EMAIL PROTECTED]

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



Re: [PHP] Add Reply-To to this list(s)

2003-11-26 Thread Dave G
[quote]
Breaking the list to cater for broken mail clients is a ludicrous
suggestion.
[/quote]

I don't know who is talking about broken anything, but I'm
certainly not. I don't think this list is broken, or that my email
software is broken, or that anyone else's is, or that other lists that
handle this issue differently are broken...
Nothing as far as I can see is broken. Everything is working
in the ways that people are intending them to work. It's the intentions
that are under question. To me the debate is not about what is the way
that any of the software is built, because that can be altered. It's
whether or not the chosen design is the most logical design.
So far it seems to me that there are two sides on this. On one
side are those who think that educated users of the internet and mail
and mailing lists have this system set up this way because it gives the
best set of options. And on the other side are those who think that
having a reply-to-list option makes more sense because it is a more
natural expectation of how mailing lists work.
Let's put tribal feelings of allegiance aside. Both points of
view are rational.
I tend towards the side that follows the natural expectation
model because I don't think it comes at the expense of any options. To
me the whole point of a group discussion is the group. So to default to
replying not to the group, but to the individuals in it, seems to run
contrary to the reasons I joined. That is where I am starting from, it's
got nothing to do with anyone's choice of software on either the client
or server side.

-- 
Cheers!
Dave G
[EMAIL PROTECTED]

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



RE: [PHP] Add Reply-To to this list(s) [SOLVED, for me, anyway]

2003-11-26 Thread Dave G

Dave T-G said:
 Perhaps you've simply missed the point.  By not mandating a certain
R-T
 header the list software does not force reply-to-author but instead
 simply allows whatever reply you want.

And Jason Wong said:
 Simply put, there are mail clients available which are mailing-list
aware. To 
 reply to the list you hit the reply-to-list button , to reply to the
sender 
 you hit the reply button, to reply to everybody and their dogs hit
the 
 reply-to-all button.

  I was wrong, wrong, so very wrong. I see the light now, and I am
completely changing my stance on this.
  I now understand that what I want is mailing software which is
mailing list aware so that I can set up the default behaviour of my
reply button to go to the list and not to the user, because that is my
user preference.
  I can see some logic in having a third button that says reply to
list, and that would be a better solution than changing the behaviour
of the list itself. What I failed to see before was how the way this
list set up allowed for configurability. I had the mistaken idea that
the list behaviour leveraged a certain amount of control over the email
client behaviour.
  Also, it was hard for me to grasp it, because in my case 99% of the
time I would want to respond to a message I got via a mailing list by
sending it back to the list, to get the maximum benefit of many people
involved in the problem solving process. But that just allowed me to
slip into a personal bias.
  I was wrong, and I'm big enough to say it. Wrong, wrong, wrong. In
fact, I'm going to revel in it. I have learned, changed, grown. This is
good.

  So, now, what I personally want, in order to take advantage of this
non munging approach to mailing lists, is three buttons:
  1. Reply, and the default behaviour, in the case of mailing lists,
is to send to the list.
  2. Reply to all, to send to everyone and their dog, because canine
input is very important.
  3. Reply to email author only for, again in the case of mailing
lists, the odd exceptional time when I want to reply not to the list,
but just to the guy/gal who posted the message.

  So, if anyone has recommendations for email software which allows me
to set up these buttons in this way, please let me know. You've
convinced me that this mailing list system offers the most control, so
which software allows me to best take advantage of it?

-- 
Cheers!
Dave G
[EMAIL PROTECTED]

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



RE: [PHP] Add Reply-To to this list(s) [SOLVED, for me, anyway]

2003-11-26 Thread Dave G

  I'm on XP. I would change over to Linux in a heartbeat if Adobe
products were available on that OS, but alas, they are not, and the GIMP
is, by their own description, not a Photoshop killer.

  I'm considering the Opera M2 mailer, but it looks kind of immature. 

-- 
Cheers!
Dave G
[EMAIL PROTECTED]

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



RE: [PHP] Add Reply-To to this list(s)

2003-11-25 Thread Dave G
  This is, I suppose, a completely off topic thread. However, I just
read the web page
http://www.unicom.com/pw/reply-to-harmful.html
and I was completely unconvinced. In all the years that I have belonged
to and run mailing lists, I have never experienced any difficulties.
Period. Never. It has been easier and more convenient than this reply
to the sender and not the list system, without a doubt.
  The complaints as outlined on the web page are somewhat silly. When
saying that replying to the mail author is a big hassle on mailing
systems with munging the web page author says that one has to write
down the sender's email address and other steps which simply don't
apply. I'm using Outlook, and I've always been able to just double click
the original senders address and send that way. No writing down, or even
copying and pasting required.
  There's even a privacy argument to be made that some people may prefer
a list where their own address is not shown. What they post is for, and
in context of, the list only, and not an invitation for private mail. In
some situations, I think that would be fair.
  Coddling the Brain-Dead, Penalizing the Conscientious is just
needlessly inflammatory and biased. If the over whelming majority of
people expect a system to behave one way, that's not evidence that they
are brain dead, but that it's very likely the expected behaviour is
more natural for people, and systems should match humans, not vice
versa.
  Freedom of choice is equally satisfied by automatically going to the
list but being able to choose to send to the email author. It's the
exact equivalent of automatically going to the author but being able to
choose to send to the list.
  It Adds Nothing is absolutely false. Being able to automatically
respond to the list adds more naturally expected behaviour.
  I could go on, point by point. But I have a feeling it would fall on
deaf ears. If the overwhelming evidence that so many mailing lists and
so many people on them function very well on email lists where the mail
automatically goes to the list is not evidence enough, than I doubt
anything ever will be.
  Telling people that they need to use proper email software and go
about things in the way they don't expect is not a path to sensible
human interfaces. Computers, machines, systems, should match us, not us
to them. In any case, despite the difficulties, computers are much
easier to change than people.
  I remain steadfast in my opinion that automatically replying to the
list is a much more natural option. 

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



[PHP] MySQL Time Zones, correct codes, and global variable setting (was: Set time zone)

2003-11-17 Thread Dave G
  GoLive Gurus,
 GoLive? This is PHP :P

Doh! Sorry about that. Got my wires crossed.

 http://www.php.net/putenv
 putenv(TZ=EST); etc. (check the user notes).

  Ah, that's done it! Thank you!
  Now, of course, the problem is MySQL. My PHP scripts all think they
are in Japan, and my MySQL db thinks it's Nevada. My impression from
reading the MySQL online manual is that what I need to do is set the
GLOBAL variable TZ to the Japan time zone. Armed with information from
the MySQL online manual, in phpMyAdmin, in the SQL command entry field,
I tried:
SET GLOBAL TZ=JST;
But it keeps rejecting it. I also tried the following:
SET GLOBAL TZ=Japan;
SET GLOBAL timezone=JST;
SET GLOBAL timezone='JST';
... and as many other combinations of codes and punctuation that I could
think of. But I believe I'm barking up the wrong tree. Question one is,
what is wrong with my syntax?
  Another thing that I have noticed is missing from most of the
documentation I have seen on the net and in the manuals is a listing of
what all the accepted codes for different time zones are. Every example
always uses either GMT, EST, PST or UTC. So I guessed the code for Japan
was JST. But when I used putenv(TZ=JST), it was off by a few hours.
So then I tried putenv(TZ=Japan), and it's now correct. I've seen some
reference that Linux machines have a configuration file which would keep
a list of various time zone codes, but I haven't come across any
reference on the web which tells me what that list looks like. So,
question two is, how can I tell which is the right code to set TZ to?
JST? Japan?
  Your help is much appreciated.

-- 
Cheers!
Dave G
[EMAIL PROTECTED]

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



[PHP] Compensating for time zones in PHP

2003-11-17 Thread Dave G
PHP Gurus,
I'm building a calendar which does some things like compare
dates. For example, if an event is in the past, then the link in the
calendar is made inactive. To do this I'm converting everything into
UNIX time stamps, so I can do simple greater than or less than type
equations to figure out which dates come in what order.
Here's how I've got it set up:
$currentMonth and $currentYear are the month and year that the
user has selected to look at. $dayCount is where I'm storing the date. I
build the calendar table by using a loop to put in the right date in
$dayCount and then echo it out in each table cell to draw a months worth
of dates.
So, to compare dates, I take these variables and make it into a
unix timestamp:
$dateFromPHP = mktime(' ',' ',' ',$currentMonth, $dayCount,
$currentYear);
Then, I get all the relevant event dates for that month from
MySQL, like so:
$query = SELECT UNIX_TIMESTAMP(eventdate) FROM table WHERE
MONTH(eventdate) =  . $currentMonth;
I put the results into an array called $dateFromMySQL.
Okay, now here's where it gets wonky. If both PHP and MySQL are
set to default time zone settings, then this following command will
return some results:
if (in_array($dateFromPHP, $dateFromMySQL)
I use the results to determine if in any one table cell I need
to do some handling of events. If there are no matches in the array,
then I just echo out the date. As I say, this works fine when I don't
try to adjust time zones.
But, if at the top of my PHP script I declare the time zone as
being in Japan, like so:
putenv(TZ=Japan);
Then the in_array command never returns anything anymore.
I don't understand why this happens. Since I don't specify the
hours, minutes, or seconds, the time zone difference shouldn't apply.
I thought maybe MySQL needed to be set to have the same time
zone as the PHP script, but, according to my web hosting service, that
is impossible to set for just my site without affecting all the other
sites on the same server.
So I need to compensate for different time zones between my
script and my MySQL server. But I can't figure out how to do that since
I don't know why there is a difference in the first place.
Any help would be much appreciated.

-- 
Cheers!
Dave G
[EMAIL PROTECTED]

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



[PHP] Set time zone

2003-11-16 Thread Dave G
GoLive Gurus,
I've been hunting around the net and PHP online manual for a
while, and I haven't found a clear description of how to make it so my
PHP scripts return values for times and dates that are consistent with
my time zone.
All the web pages I'm working on are intended for use in Japan.
I've created a calendar for people to sign up for activities on specific
dates. The servers where my sites are located are in Nevada (US PST
time). This puts them off by about 16 hours or so, which is significant
enough to offset, for example, which day is shown to be today.
So, naturally, I would like to adjust my scripts so that all
date values returned are in JST.
I thought this was accomplished with setlocale(), so, shooting
in the dark, I experimented with:
setlocale(LC_TIME, JST);
I also tried, in place of JST, jst, jp, JP, Japan,
JAPAN, and japan.
I figured I was not using the command right, so I looked around,
and came across this article:
http://www.opengroup.org/onlinepubs/7908799/xbd/locale.html
... and it confused me greatly.

What I'm trying to do is hopefully set some command at the start
of my script which will make the rest of the script know that it's
supposed to do everything in Japan time. Is this possible?
mysql.org has been equally opaque on the topic of time zones.
Lots of information about how to format times, but not very clear about
how to make the database take on a time zone. If anyone has pointers on
that as well, that would be greatly appreciated.

-- 
Cheers!
Dave G
[EMAIL PROTECTED]

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



RE: [PHP] Why would this eregi() function not work?

2003-11-14 Thread Dave G
 ... escaping isn't necessary.

Thanks so much for all the helpful advice!
Okay, included the + character, and removed the escaping. And I know I'm
supposed to checking into preg_match, but I'm looking at this as an
opportunity to learn about regular expressions, so I still have a
question. I'm confused why hyphens wouldn't still need escaping. Hyphens
are used to express a range of characters. If there's a hyphen there,
won't PHP think I'm looking for a range from nothing to nothing? Or is
it clever enough to figure out what's going on?
(!eregi('[EMAIL PROTECTED]', $email)

-- 
Cheers!
Dave G
[EMAIL PROTECTED]

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



RE: [PHP] Why would this eregi() function not work?

2003-11-14 Thread Dave G
 The last part of your pattern needs to be changed because it 
 allows for a top-level domain to contain numbers and hyphens.
 Currently, such a thing does not exist.

Okay... I can change that...
(!eregi('[EMAIL PROTECTED]', $email))

 Also, the 2nd part of your pattern allows for a 2nd-level domain to
 start and end with a hyphen, which is also disallowed.

Hmmm... but I don't think I want to get too strict. I mean, if I can
write the code to make sure the domain doesn't start or end with the
hyphen, but can have one in between, then cool. But I think that would
require more expression footwork than I'm capable of at this point.

 I truly wish that I could point you to a canonical reference on the
 matter, but such a thing escapes me... 
 http://www.opengroup.org/onlinepubs/7908799/xbd/re.html
 ... which may be helpful. 

That's a pretty hefty read, but it looks useful to have around for a
reference. Thanks!

-- 
Cheers!
Dave G
[EMAIL PROTECTED]

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



[PHP] Why would this eregi() function not work?

2003-11-13 Thread Dave G
PHP Gurus,
I have an eregi() function that I'm using to validate emails
that users enter into a form. I pretty much took it directly from the
book PHP and MySQL Web Development. It looks like this:
(!eregi('[EMAIL PROTECTED]', $email)
For the most part it's working fine. But recently a user tried
to enter in his email address and it got rejected by this script. After
a little experimentation, it looks like it's the hyphen in the first
part of his address that's causing it to be rejected. His email address
looks like:
[EMAIL PROTECTED]
If I remove the hyphen, like so:
[EMAIL PROTECTED]
Then it passes.
Looking at my eregi() function, I've included hyphens as a valid
character, and escaped them out with slashes in order that they work
within the square brackets.
Why would this email be rejected?

-- 
Cheers!
Dave G
[EMAIL PROTECTED]

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



RE: [PHP] Why would this eregi() function not work?

2003-11-13 Thread Dave G
 2) Sure enough, you don't allow + extensions in yours.  
 Neener neener :-)

Is +  a legal character in emails?

 3) You might check out preg_match, which the manual says is 
 often faster than ereg().

Will look into it. Thanks for the tip.

 4) To include '-' in a range list, put it last in the range.

So then it would look like this:
(!eregi('[EMAIL PROTECTED]', $email)
Is that right?

 1. Special characters within brackets do not need to be escaped. [.] 
 will match a period.

So then I could make it:
(!eregi('[EMAIL PROTECTED]', $email)
Correct?

 3. I don't think a hyphen is even legal in an email address...

If it wasn't, the user couldn't have emailed me to tell me that he
wasn't having success in registering on my form. Or could he?

-- 
Cheers!
Dave G
[EMAIL PROTECTED]

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



[PHP] multiple table rows into an array, and creating a calendar

2003-11-12 Thread Dave G
PHP Gurus,
I have a database of events which happen on various dates. I've
set up a query to select all the dates within the current month. I've
got a calendar which shows one month at a time, as a table, on which to
display the relevant dates as links.
My problem is that I can't figure out how to compare the results
of the query to the dates on the calendar so that they display on the
right dates.
I thought I should put those date in an array and then on each
date, search that array for a matching date, and if it's found, then
display a link on that date. But my first obstacle was getting the
results of my query into an array.
I first thought I could just use mysql_fetch_array(), but I am
obviously mistaken. According to php.net, that will make an array out of
the columns in the currently selected row. But I want to make an array
out of *all* the rows I have. Each row has only one entry, the date.
I'm looking through all the mysql_* commands that are listed on
the left side of the page, and I don't see any commands that do that.
Surely this kind of action is common enough to merit having it's own
command...?
As I read further, I wonder if my plan is flawed. I thought
mysql_data_seek would search the array based on my criteria, and then
return true or false. But what it says on php.net is very confusing for
me, so I have to admit I'm not sure what it does at all.

I guess what I really am asking is, what is the most efficient
way for me to compare the dates on the calendar with the dates in my
database and display matches as links.
I mean, I could put my mysql_query command in the while loop
that renders the calendar, and search for matching dates that way. But
that means searching the whole database table roughly 30 times each time
the page is accessed, and that can't be right. I'm sure this is better
handled with arrays, but I can't quite figure out the logic and the
commands.
Can anyone help me out with this?

-- 
Cheers!
Dave G
[EMAIL PROTECTED]

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



RE: [PHP] multiple table rows into an array, and creating a calendar

2003-11-12 Thread Dave G
Burham

 why don't 
 you do an in_array() check for each date that you print.
 Hope this helps.

Yes, this helps a lot!
However, I'm still stuck on how to get my list of dates into the array.
I've been searching around on the Internet, and it seems that one has to
construct a for() loop in order to get the results of multiple rows into
an array. But that seems unnecessarily complicated. Is there no command
to take multiple rows and place them into an array?

-- 
Cheers!
Dave G
[EMAIL PROTECTED]

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



[PHP] Why is this code not working?

2003-11-12 Thread Dave G
PHP Gurus,
I'm trying to put the results of a query into an array.
My code looks like this:
?php
$query = SELECT datecolumn FROM table WHERE MONTH(datecolumn) =  .
$currentMonth;
$result = mysql_query($query);
$numRows = mysql_num_rows($result);
for($i = 0; $i$numRows; $i++)
{
$workshops[$i] = mysql_fetch_row($result);
echo $workshops[$i] . br /;
}
echo The results of the array are -  . $workshops[0] .  and  .
$workshops[1];
?
When I run this, the output to the screen says:
---
Array
Array
The results of the array are - Array and Array
---
If I change just this line (take the square brackets off the
$workshops array declaration):
$workshops = mysql_fetch_row($result);

Then my results are:
---
2003-11-17

The results of the Array are 2003-11-24 and
---
I understand that by not using square brackets to declare the
variable explicitly as an array, then it just stores the last value,
which is why the dates aren't echoing to the screen where they are
supposed to. That part makes sense. What I don't understand is why when
I try to put the results into a particular location in the array, it
gets stored as the word Array. But if I just declare it as a regular
variable, then I get the date that I want.
I've been writing this out a million different ways to try and
figure out what's going on, I've searched Google, and I've read the
descriptions for the mysql_* commands on php.net. But everything I read
indicates it should work. In fact I got the for() loop from a tutorial
web site, so I'm pretty sure it's supposed to work. I can't see what's
wrong. Am I not declaring the array correctly? Is there some simple
error that I'm over looking? What's going on?

-- 
Cheers!
Dave G
[EMAIL PROTECTED]

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



RE: [PHP] Calendar

2003-11-12 Thread Dave G
Steve,
I'm a complete beginner, and I just finished building my own
calendar.
I tried using some pre-built ones, like this one:
http://www.cascade.org.uk/software/php/calendar/index.php
... but I found that trying to figure out how to use their
features was a whole new learning curve, and made customizing more of a
hassle.
So I highly recommend you go through a tutorial and build a
calendar step by step. That way you have mastery over every part of the
calendar and can customize every aspect of it.
The one I used was here:
http://www.devshed.com/Server_Side/PHP/MilesToGo/page1.html

-- 
Cheers!
Dave G
[EMAIL PROTECTED]

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



RE: [PHP] Why is this code not working? [SOLVED]

2003-11-12 Thread Dave G
  PHP Gurus,
 If you say so...

A few people have remarked about this. It's just a habit of
mine. Whatever list I'm on, I address it to the gurus of that list. A
guru being anyone who knows more than me, which is almost everyone. So
on the CSS list, I address it to CSS Gurus. On the GoLive list, it's
to GoLive Gurus. That's all.
 
 Try:
 echo The results of the array are -  . $workshops[0][0] .  and  .
 $workshops[1][0];

I'm not sure if I did something wrong, but when I tried this,
the results came back like this:
The results of the array are - 2 and 2
I have no idea what the twos are referring to.

 while($r = mysql_fetch_row($result))
 { $workshop[] = $r[0]; }

This works perfectly! And, more importantly, I learned what it is that
you are doing here. Taking the one column of the array returned from the
mysql_fetch_row() command and putting it into a slightly simpler array.
And for this purpose a while() loop is less code than a for() loop.
Elegant. That's solved the problem. Thank you.

 Have you tried mysql_fetch_array()?
Just thought I should mention this to Jay. Yes, I had been
alternating my experiments with mysql_fetch_array() and
mysql_fetch_row(), but the results, were exactly the same (or close
enough that I don't remember otherwise). So I suspected that the problem
lay elsewhere and didn't mention it. But thank you for suggesting
alternatives.

-- 
Cheers!
Dave G
[EMAIL PROTECTED]

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



RE: [PHP] Japanese character validation

2003-11-08 Thread Dave G

In hopes of bringing the kanji character validation issue back
on topic, can I point out that it doesn't matter *why* someone would
want to do this, or what the origins of kanji and kana are? The
motivations of the original poster shouldn't be in question. Everyone
has their own situations and goals, and what's not important to one
person is important to others. Either what they are asking for is
possible or not, and if it is, it would be enlightening to know how.
I for one am also very interested in hearing possible solutions.
I can think of multiple situations in which checking to see whether a
user inputted kanji or kana would be very useful indeed. And I hope to
learn more by further discussion of the PHP coding required. It would be
a shame if that potential learning was obscured or lost in off topic
theorizing about the origins of the Japanese language.

Optimistically looking forward to seeing more technical discussion on
how to accomplish this.

-- 
Cheers!
Dave G
[EMAIL PROTECTED]

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



RE: [PHP] Endless 'while' loops?

2003-11-03 Thread Dave G
GoLive Gurus,

The problem has been resolved. I now understand much better how
while loops operate, and fixed the problem of the script not parsing.
I am now successfully making mailing lists using PHP.
While I was banging my head thinking there was something wrong
with how I was accessing the array variable, it turned out to be the
most simple thing. I had mistakenly placed a semi-colon at the end of my
while() command, and that was the root of my troubles. It never ceases
to amaze me how finding that one errant punctuation mark can be so
difficult and misleading!
In any case, I very appreciative of the many valuable tips
offered, and I believe tightening up the code as suggested by people on
this list helped me see my script better and isolate the problem.
Many thanks to David, Jay, Hanuska, Leif, and Teren for their
comments!

-- 
Cheers!
Dave G
[EMAIL PROTECTED]

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



RE: [PHP] Japanese entry into MySQL and into emails

2003-11-03 Thread Dave G

The issue of entering Japanese into email from a PHP script has
been resolved. A key point was that when creating a header for an email,
not only should \r\n be used to separate lines, but immediately
preceding \r\n should be a space.
The end result was to create a variable that goes into the final
space in the mail() command where one puts additional headers which
looks like this:

$headers = $fromaddress .  \r\nContent-Type: text/plain;
charset=iso-2022-jp;

Thanks Marek, Eugene, and Edwin for their advice on this matter,
and of storing kanji in a MySQL database.

-- 
Cheers!
Dave G
[EMAIL PROTECTED]

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



RE: [PHP] Endless 'while' loops?

2003-11-02 Thread Dave G

Thank you Lief, Hanuska and Jay for your comments and advice.

 (it automagically knows which result it's on)

This was the piece of information that I was missing. I did not
know PHP had any automagic in it's handling of arrays.
However, now that I think I know what's going on, my code still
does not seem to be working. When I execute the following, I get a parse
error on the line where my first square brackets (...for  .member[1];)
appears. If I take the square brackets out, the code parses, but does
not do anything.
Here is the problematic code:
db_connect();
$query = select * from tablename where active = 1;
$result = mysql_query($query);
while ($member = mysql_fetch_row($result));
{
$subject = EigoImprov Newsletter for  .member[1];
$mailcontent = Dear  .$member[0] .,\n.$message .\nThis message was
sent to [2] .$member;
mail($member[2], $subject, $mailcontent, $fromaddress);
}
Why is this not parsing?

-- 
Cheers!
Dave G
[EMAIL PROTECTED]

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



RE: [PHP] Japanese entry into MySQL and into emails

2003-11-01 Thread Dave G

Thank you Edwin, Marek, and Eugene for your responses and
advice.
For storing the Japanese names in kanji in the database, I've
changed the column to blob. Storing and retrieving the fields seems to
work okay in all my tests, and this solution seemed to be the easiest
and without any potential impact on the rest of the database. Thank you
for this solution.
For sending the email in Japanese, I am still not quite getting
it. At first I attempted to attach character set information within the
mail() command like so:
$addheaders = 'From: ' .$email .'\r\nContent-Type: text/html;
charset=iso-2022-jp';
mail ($toaddress, $subject, $mailcontent, $addheaders);
This sends the mail correctly, but the content is still coming
out as ASCII gibberish.
I then attempted to use the mb_send_mail() command, like so
(this time a From:  address being the only additional header:
mb_language(Japanese);
mb_send_mail($toaddress, $subject, $mailcontent, $fromaddress);
But this had exactly the same result.
I see on the
http://jp2.php.net/manual/en/function.mb-send-mail.php web page there is
lots of additional comments on the use of mb-send-mail(), but the
technical vocabulary is beyond me.
Can someone help me tweak this code to successfully send a kanji
email?

-- 
Cheers!
Dave G
[EMAIL PROTECTED]

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



[PHP] Japanese entry into MySQL and into emails

2003-10-30 Thread Dave G
PHP Gurus,
Hello, I'm new to this list. I'm very much new to PHP, so my
questions will be very basic.
I have two things I need to do in Japanese:

1. Store people's names in kanji in my MySQL database.
To this end, I've set up an INSERT command without doing
anything different than usual, and then at the HTML interface, just
typed in some Japanese text (on an English Windows XP machine, Opera
7.2, using Microsoft's global IME text entry). When I looked in my
database via phpMyAdmin, the field looked like it was filled with ASCII
gibberish.

2. Send kanji text via PHPs mail() command.
I've set up a form on a web page, that posts to a PHP script
that will send me feedback from the users. Again, I didn't set up
anything different than I would for English usage. When I received the
mail, it came out as ASCII gibberish again.

I've searched some on the web, and in this lists archives, and I
understand that I can possibly use mbstring functions in order to
resolve this. However, the manual for this function on php.net is a
little beyond my ability to understand it. I'm confused by the need to
set internal encoding, and/or also setting the character set. My web
site is on a virtual host, and I don't know if I have access to make
such adjustments.

Can someone please explain in beginners terms how do I set up my
PHP scripts to enter Japanese kanji safely into a database and into an
email?

-- 
Cheers!
Dave G
[EMAIL PROTECTED]

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



[PHP] Endless 'while' loops?

2003-10-30 Thread Dave G
PHP Gurus,
This is my other question which motivated me to join this list.
I've been using the book PHP and MySQL Web Development to
learn how to build dynamically driven sites. For the most part it's
great. But I don't have anyone I know personally that I can ask when I
don't understand a part of the book.
I want to send out an e-mail to a group of people. Each
individual is stored in their own row in my MySQL database, with their
address, name, and all those details. My understanding is that I can use
either a for loop, or a while loop to accomplish this.
In the example they give in this book, they use a while loop
(page 670, for anyone who has it). But it's confusing because it looks
like this:
while ( $subscriber = mysql_fetch_row($result))
{
[write and send the email]
}
$subscriber is probably an array, filled with the email address
and information about the mailing list subscriber. But in the rest of
the script I can't find where they declare and fill this array. But more
than that, I can't understand how this while loop would ever stop
running. Nothing seems to change $subscriber within the while loop's
control structure. It doesn't ever say anything like $subscriber ++1.
Nor does $result have anything act upon it which would change it. So to
me they both look static, and this loop looks endless.

-- 
Cheers!
Dave G
[EMAIL PROTECTED]

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