[PHP-DB] new guy with stupid question

2006-01-20 Thread Lonny

Hello,
I am new to the list.
I thought I would call my question stupid just to raise some eyebrows to
those who might like to flame me for not reading some basic php/mysql books.
Fact is - I have -
I have been working with some scripts where I can change them and expand on
them to suit my needs.
I really don't think my question is stupid.
It is just that time is of the essence and I am optimistic that I might make
some friends to help me with some quick answers to get my scripts running.

OK, sorry for the long winded info.
For today I will ask for a script that will gather emails from the email
field of a table in a database and send a news letter to those emails.
How do I compose the email formatted with html for a professional look and
send it to everyone in the database.

If I haven't got myself kicked of this list yet, here is another basic
question.

I want users to be able to select a date for their schedule.
I do not want them to have to follow the format of -mm-dd
I just want them to select a month from a pulldown, then a day, and then a
year. (I have all this set up all ready)
What is confusing me is the part where I need to think out of the box a bit
and combine there three selection into a date field.
Like $month + $day + $year
INSERT $month$day$year into $date; and come up with something that looks
like 2006-08-13
I hope you know what I am trying to do here.

Have I made any friends yet?
Lonny

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



Re: [PHP-DB] new guy with stupid question

2006-01-20 Thread Aaron Koning
$date = $month.-.$day.-.$year;
$query = INSERT INTO sometable (date) VALUES ('$date');;

Hope this works for you,
Aaron

On 1/20/06, Lonny [EMAIL PROTECTED] wrote:


 Hello,
 I am new to the list.
 I thought I would call my question stupid just to raise some eyebrows to
 those who might like to flame me for not reading some basic php/mysql
 books.
 Fact is - I have -
 I have been working with some scripts where I can change them and expand
 on
 them to suit my needs.
 I really don't think my question is stupid.
 It is just that time is of the essence and I am optimistic that I might
 make
 some friends to help me with some quick answers to get my scripts running.

 OK, sorry for the long winded info.
 For today I will ask for a script that will gather emails from the email
 field of a table in a database and send a news letter to those emails.
 How do I compose the email formatted with html for a professional look and
 send it to everyone in the database.

 If I haven't got myself kicked of this list yet, here is another basic
 question.

 I want users to be able to select a date for their schedule.
 I do not want them to have to follow the format of -mm-dd
 I just want them to select a month from a pulldown, then a day, and then a
 year. (I have all this set up all ready)
 What is confusing me is the part where I need to think out of the box a
 bit
 and combine there three selection into a date field.
 Like $month + $day + $year
 INSERT $month$day$year into $date; and come up with something that looks
 like 2006-08-13
 I hope you know what I am trying to do here.

 Have I made any friends yet?
 Lonny

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




Re: [PHP-DB] new guy with stupid question

2006-01-20 Thread Balazs Hegedus
Hi,

Here's what I found googling around (with these keywords: html email php):

http://www.sitepoint.com/article/advanced-email-php

didn't read it through, but looks good imho (and there's more).
And my apologies but I really don't understand your second question. :)

Balazs

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



Re: [PHP-DB] new guy with stupid question

2006-01-20 Thread Jeffrey

Lonny wrote:


OK, sorry for the long winded info.
For today I will ask for a script that will gather emails from the email
field of a table in a database and send a news letter to those emails.
How do I compose the email formatted with html for a professional look and
send it to everyone in the database.

If I haven't got myself kicked of this list yet, here is another basic
question.

I want users to be able to select a date for their schedule.
I do not want them to have to follow the format of -mm-dd
I just want them to select a month from a pulldown, then a day, and then a
year. (I have all this set up all ready)
What is confusing me is the part where I need to think out of the box a bit
and combine there three selection into a date field.
Like $month + $day + $year
INSERT $month$day$year into $date; and come up with something that looks
like 2006-08-13
I hope you know what I am trying to do here.

Have I made any friends yet?
Lonny

 


Lonny:

Don't slag yourself off so much. That's what this list is for ;o)

First question...

$subject=Email subject line;
$body=htmlNewsletter content/html;
$return_address=From: [EMAIL PROTECTED];

$query=SELECT $email_address FROM some_table;
$result=mysql_query($query) or die(Something went wrong, sweetheart:  
. mysql_error());

while($row=mysql_fetch_array($result)){
   extract($row);
   mail($email,$subject,$body,$return_address);
}
Untested, but should work. And I know some of the people on the list 
will say that the mysql_fetch_array() is not the best approach - but you 
can fiddle with mysql_fetch_row() if you'd prefer. It would probably be 
a bit more efficient.


As to HTML content for your newsletter, I would test first. Create a 
newsletter, send it to yourself and, if possible a couple of other 
people. Try various layouts until it looks right. But bear in mind that 
different e-mail clients are not consistent with the display of html 
content. So try as many different clients as you can, especially 
Outlook, Lotus Notes (if there are a lot of busness users), Thunderbird, 
Gmail, hotmail, etc.


For what it's worth, I do a popular and highly regarded newsletter 
entirely in ASCII text. Of the over 2000 subscribers, only one person 
every complained about the appearance - and his complaints were such 
that it was clear he wasn't remotely interested in the actual content of 
the newsletter.


For the last question, get the date info from your drop down menus, then 
in php...


$date_for_db=$year.-.$month.-.$day;

...and insert $date_for_db into your table.

Good luck,

Jeffrey

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



Re: [PHP-DB] new guy with stupid question

2006-01-20 Thread Balazs Hegedus
Hi,

Aaron helped me to understand the question so here's an add-in to his comment.

?php

if ($_SERVER['REQUEST_METHOD'] === 'GET') {//'GET' !== 'get'
//display form (using POST method)
}
elseif ($_SERVER['REQUEST_METHOD'] === 'POST' 
isset($_POST['_non-optional_fields_']) 
is_numeric($_POST['_year_field_']) 
is_numeric($_POST['_month_field_']) 
is_numeric($_POST['_day_field_']) 
checkdate($_POST['_month_field_'], $_POST['_day_field_'],
$_POST['_year_field_'])) {
//process the form
$date = $_POST['_year_field_'] . '-' . $_POST['_month_field_'] . '-' .
$_POST['_day_field_'];
$sqlInsertNewDate = INSERT INTO table_name (date_field) VALUES (' .
$date . ');
}
else {
//some error message or redirection here
}

?

from  the MySQL manual:

MySQL version through 4.1 accept certain illegal values for dates,
such as '1999-11-31'. This is useful when you want to store a possibly
incorrect value specified by a user (for example, in a web form) in
the database for future processing. MySQL verifies only that the month
is in the range from 0 to 12 and that the day is in the range from 0
to 31.

that's why checkdate() is important.

Hope it helped.

Balazs

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



[PHP-DB] Select found_rows problem...

2006-01-20 Thread Yemi Obembe
Using the select calc_found rows code (i.e select sql_calc_found_rows *
from table where ... limit 0, 10) to get the found fesult irrespective of
the limit clause...then using $count = mysql_query(select found_rows());
with the hope of getting the returened result but got this instead: Resource
id #7.
what could be wrong?

--
http://ngBot.com
Nigeria's #1 website directory.


[PHP-DB] SELECT

2006-01-20 Thread Ron Piggott (PHP)
Yesterday I asked how to get the date  time 90 minutes ago and I
received several responses.  Thanks.

I don't think this select statement is working correctly.  (Correctly
being what I am intending it to do)

I took a look at the table this morning.  One record remains that was
created 2006-01-19 at 23:55:37.  These are the values of date_created
and time_created.  The current values are approximately 2006-01-20 and
05:50:00

This is the select statement I am writing about:

SELECT * FROM `table` WHERE `date_created` = '$date_90_minutes_ago' AND
`time_created` = '$time_90_minutes_ago'

Intellectually I know the problem: 05:50:00 is much earlier than
23:55:37 ... thus my AND is not allowing both conditions to exist
together.

Is there a way that I may modify this SELECT statement so the present
conditions continue to exist and add a second part to the SELECT
statement that if the time is 01:30:00 or higher that records from the
previous day are selected?  This continues to allow the 90 minute time
frame for users logged into my web site ... I am not sure how you would
add an OR function to the above without messing up what presently
works :)

(I am writing a SESSION function for my web site using mySQL and a cron.
The select statement I quoted above is part of the cron.)

Ron

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



Re: [PHP-DB] SELECT

2006-01-20 Thread Adrian Bruce

Possibility?

WHERE (`date_created` = '$date_90_minutes_ago' AND
`time_created` = '$time_90_minutes_ago') or 
(`date_created`  '$date_90_minutes_ago' AND

`time_created`  '01:30:00')


Ade


Ron Piggott (PHP) wrote:


Yesterday I asked how to get the date  time 90 minutes ago and I
received several responses.  Thanks.

I don't think this select statement is working correctly.  (Correctly
being what I am intending it to do)

I took a look at the table this morning.  One record remains that was
created 2006-01-19 at 23:55:37.  These are the values of date_created
and time_created.  The current values are approximately 2006-01-20 and
05:50:00

This is the select statement I am writing about:

SELECT * FROM `table` WHERE `date_created` = '$date_90_minutes_ago' AND
`time_created` = '$time_90_minutes_ago'

Intellectually I know the problem: 05:50:00 is much earlier than
23:55:37 ... thus my AND is not allowing both conditions to exist
together.

Is there a way that I may modify this SELECT statement so the present
conditions continue to exist and add a second part to the SELECT
statement that if the time is 01:30:00 or higher that records from the
previous day are selected?  This continues to allow the 90 minute time
frame for users logged into my web site ... I am not sure how you would
add an OR function to the above without messing up what presently
works :)

(I am writing a SESSION function for my web site using mySQL and a cron.
The select statement I quoted above is part of the cron.)

Ron

 



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



RE: [PHP-DB] new guy with stupid question

2006-01-20 Thread Lonny


-Original Message-
From: Lonny [mailto:[EMAIL PROTECTED] 
Sent: Friday, January 20, 2006 3:46 AM
To: php-db@lists.php.net
Subject: [PHP-DB] new guy with stupid question


Hello,
I am new to the list.
I thought I would call my question stupid just to raise some eyebrows to
those who might like to flame me for not reading some basic php/mysql books.
Fact is - I have -
I have been working with some scripts where I can change them and expand on
them to suit my needs.
I really don't think my question is stupid.
It is just that time is of the essence and I am optimistic that I might make
some friends to help me with some quick answers to get my scripts running.

OK, sorry for the long winded info.
For today I will ask for a script that will gather emails from the email
field of a table in a database and send a news letter to those emails.
How do I compose the email formatted with html for a professional look and
send it to everyone in the database.

If I haven't got myself kicked of this list yet, here is another basic
question.

I want users to be able to select a date for their schedule.
I do not want them to have to follow the format of -mm-dd
I just want them to select a month from a pulldown, then a day, and then a
year. (I have all this set up all ready)
What is confusing me is the part where I need to think out of the box a bit
and combine there three selection into a date field.
Like $month + $day + $year
INSERT $month$day$year into $date; and come up with something that looks
like 2006-08-13
I hope you know what I am trying to do here.

Have I made any friends yet?
Lonny

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

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



[PHP-DB] Re: SELECT

2006-01-20 Thread David Robley
Ron Piggott (PHP wrote:

 Yesterday I asked how to get the date  time 90 minutes ago and I
 received several responses.  Thanks.
 
 I don't think this select statement is working correctly.  (Correctly
 being what I am intending it to do)
 
 I took a look at the table this morning.  One record remains that was
 created 2006-01-19 at 23:55:37.  These are the values of date_created
 and time_created.  The current values are approximately 2006-01-20 and
 05:50:00
 
 This is the select statement I am writing about:
 
 SELECT * FROM `table` WHERE `date_created` = '$date_90_minutes_ago' AND
 `time_created` = '$time_90_minutes_ago'
 
 Intellectually I know the problem: 05:50:00 is much earlier than
 23:55:37 ... thus my AND is not allowing both conditions to exist
 together.
 
 Is there a way that I may modify this SELECT statement so the present
 conditions continue to exist and add a second part to the SELECT
 statement that if the time is 01:30:00 or higher that records from the
 previous day are selected?  This continues to allow the 90 minute time
 frame for users logged into my web site ... I am not sure how you would
 add an OR function to the above without messing up what presently
 works :)
 
 (I am writing a SESSION function for my web site using mySQL and a cron.
 The select statement I quoted above is part of the cron.)
 
 Ron

It would seem you have different columns for date and time? Seems to me that
a little judicious use of CONCAT and DATE_SUB might solve your problem. In
other words, create a valid date/timestamp value with CONCAT then use
DATE_SUB to determine -90 min.

I've given a Mysql based solution as this is php.db :-)



Cheers
-- 
David Robley

I'm an ordained minister, said Tom reverently.

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



Re: [PHP-DB] Getting PHP 5 w/mysqli to communicate with MySQL 5

2006-01-20 Thread Arie Nugraha
To solve compability problem with mysql library, try to save your mysql user
password with OLD_PASSWORD('some pass') function, not the ordinary
PASSWORD('some pass') function.

With this you can connect to MySQL 4.1  5 even with php 4


RE: [PHP-DB] SELECT

2006-01-20 Thread Bastien Koert
Convert both to unix timestamps...be much easier to wrok with both date and 
time then


bastien



From: Ron Piggott (PHP) [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: PHP DB php-db@lists.php.net
Subject: [PHP-DB] SELECT
Date: Fri, 20 Jan 2006 06:00:33 -0500

Yesterday I asked how to get the date  time 90 minutes ago and I
received several responses.  Thanks.

I don't think this select statement is working correctly.  (Correctly
being what I am intending it to do)

I took a look at the table this morning.  One record remains that was
created 2006-01-19 at 23:55:37.  These are the values of date_created
and time_created.  The current values are approximately 2006-01-20 and
05:50:00

This is the select statement I am writing about:

SELECT * FROM `table` WHERE `date_created` = '$date_90_minutes_ago' AND
`time_created` = '$time_90_minutes_ago'

Intellectually I know the problem: 05:50:00 is much earlier than
23:55:37 ... thus my AND is not allowing both conditions to exist
together.

Is there a way that I may modify this SELECT statement so the present
conditions continue to exist and add a second part to the SELECT
statement that if the time is 01:30:00 or higher that records from the
previous day are selected?  This continues to allow the 90 minute time
frame for users logged into my web site ... I am not sure how you would
add an OR function to the above without messing up what presently
works :)

(I am writing a SESSION function for my web site using mySQL and a cron.
The select statement I quoted above is part of the cron.)

Ron

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



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



Re: [PHP-DB] Storing money values in MySQL

2006-01-20 Thread tg-php
Thanks Balazs and David.. I think that's exactly what I was looking for.  I 
searched for hours (and I consider myself a fairly decent researcher) and was 
just getting frustrated..hah..   I think my problem was I was searching for 
money and float problems and such and not monetary.  I think that's the 
keyword that would have done it for me.

I appreciate the help guys!  Best of luck to both of you (and anyone else I 
inadvertantly missed who may have responded).

-TG

= = = Original message = = =

Me again,

Sorry for the rtfm stuff, I googled around and found this:

http://bugs.mysql.com/bug.php?id=10719

and another thing, maybe worth a try; MySQL stores decimal numbers as
strings...did you try to input decimals as string? I mean not:

UPDATE SomeTable SET AmtOwed = 10.74

but:

UPDATE SomeTable SET AmtOwed = '10.74'

Bye,

Balazs


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP-DB] Getting PHP 5 w/mysqli to communicate with MySQL 5

2006-01-20 Thread Allen Schultz
Sorry, I was in a rush to work guys.

All these were downloaded pre-compliled for Win32.
Apache 2.0.55
PHP 5.1.1 w/php_mysqli.dll (improved mysql)
MySQL 5.0.18

This script:

htmlhead/headbody
?php
$link = mysqli_connect('localhost','root','xx');
if (mysqli_connect_errno()) {
  echo error;
  exit();
} else { echo no error; }
?
/body/html

turns into this:

htmlhead/headbody
no error
/body/html

And this script:

htmlhead/headbody
?php
$link = mysqli_connect('localhost','root','xx');
if (mysqli_connect_errno()) {
  echo error;
  exit();
}
if (!mysqli_select_db($link,pers)) {
  echo pers not found; }
else {
  if ($result = mysqli_multi_query($link, select helloworld();)) {
$row = mysqli_fetch_array($result, MYSQLI_NUM);
echo $row[0];
  } else { echo problem :(; }
}
?
/body/html

turns to this:

htmlhead/headbody
/body/html

In summary again, It seems to want to connect to the database, but
doesnt see anything after connecting using mysqli functions. That
helloworld() function in the database exists.
I'm following this page for a tutorial to find out why I cant use the database:

http://mysql.gilfster.com/page.php?parent_id=4page_id=4.0.2

On 1/19/06, Julien Bonastre [EMAIL PROTECTED] wrote:
 If you only compiled php with the mysqli libraries then you need to use
 them

 What exactly are you have troubles with? A code snippet or version
 examples would be good. Also is your database mysql5 engine I take it?

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



[PHP-DB] Length of variable

2006-01-20 Thread Ron Piggott (PHP)
Is there a way I may find out how many characters 

$variable

is long after it has been submitted through a web form?

Ron

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



RE: [PHP-DB] Length of variable

2006-01-20 Thread Bastien Koert

of course

strlen($var)

bastien



From: Ron Piggott (PHP) [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: PHP DB php-db@lists.php.net
Subject: [PHP-DB] Length of variable
Date: Fri, 20 Jan 2006 20:48:21 -0500

Is there a way I may find out how many characters

$variable

is long after it has been submitted through a web form?

Ron

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



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



Re: [PHP-DB] new guy with stupid question

2006-01-20 Thread Julien Bonastre
In reference to Jeffrey's comment about the performance of 
mysql_fetch_row vs mysql_fetch_array, which I always have used the 
_array implementation:



From the horses mouth:
Performance: An important thing to note is that using 
mysql_fetch_array() is not significantly slower than using 
mysql_fetch_row(), while it provides a significant added value


[source: www.php.net/manual/en/function.mysql-fetch-array.php ]


tata!

- Original Message - 
From: Jeffrey [EMAIL PROTECTED]

To: php-db@lists.php.net
Sent: Friday, January 20, 2006 7:19 PM
Subject: Re: [PHP-DB] new guy with stupid question



Lonny wrote:


OK, sorry for the long winded info.
For today I will ask for a script that will gather emails from the 
email

field of a table in a database and send a news letter to those emails.
How do I compose the email formatted with html for a professional look 
and

send it to everyone in the database.

If I haven't got myself kicked of this list yet, here is another basic
question.

I want users to be able to select a date for their schedule.
I do not want them to have to follow the format of -mm-dd
I just want them to select a month from a pulldown, then a day, and 
then a

year. (I have all this set up all ready)
What is confusing me is the part where I need to think out of the box 
a bit

and combine there three selection into a date field.
Like $month + $day + $year
INSERT $month$day$year into $date; and come up with something that 
looks

like 2006-08-13
I hope you know what I am trying to do here.

Have I made any friends yet?
Lonny



Lonny:

Don't slag yourself off so much. That's what this list is for ;o)

First question...

$subject=Email subject line;
$body=htmlNewsletter content/html;
$return_address=From: [EMAIL PROTECTED];

$query=SELECT $email_address FROM some_table;
$result=mysql_query($query) or die(Something went wrong, sweetheart: 
 . mysql_error());

while($row=mysql_fetch_array($result)){
   extract($row);
   mail($email,$subject,$body,$return_address);
}
Untested, but should work. And I know some of the people on the list 
will say that the mysql_fetch_array() is not the best approach - but 
you can fiddle with mysql_fetch_row() if you'd prefer. It would 
probably be a bit more efficient.


As to HTML content for your newsletter, I would test first. Create a 
newsletter, send it to yourself and, if possible a couple of other 
people. Try various layouts until it looks right. But bear in mind 
that different e-mail clients are not consistent with the display of 
html content. So try as many different clients as you can, especially 
Outlook, Lotus Notes (if there are a lot of busness users), 
Thunderbird, Gmail, hotmail, etc.


For what it's worth, I do a popular and highly regarded newsletter 
entirely in ASCII text. Of the over 2000 subscribers, only one person 
every complained about the appearance - and his complaints were such 
that it was clear he wasn't remotely interested in the actual content 
of the newsletter.


For the last question, get the date info from your drop down menus, 
then in php...


$date_for_db=$year.-.$month.-.$day;

...and insert $date_for_db into your table.

Good luck,

Jeffrey

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



--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.1.375 / Virus Database: 267.14.21/235 - Release Date: 
19/01/2006







--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.1.375 / Virus Database: 267.14.21/236 - Release Date: 20/01/2006

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