[PHP-DB] Problems with ereg-Command

2007-09-06 Thread Ruprecht Helms
Hi,

I have some problems with validating the values of the fields street,
phone and fax. In the field street I want that only the european
standard for writing ( number name or name. number) should be
possible. By other fieldentries the user should be informed of the error
and the proccessing should stop.

In the fields phone and fax it should be able to write  (12345) 12345
or to write 12345 / 12345

The checking of the contactperson in german Ansprechpartner is also
incorrect.

if (!ereg([a-zA-Z .0-9],$strasse))
{
echo Unguuml;ltige Werte in Strasse;
exit;
}

if (!ereg([a-zA-Z] \.,$ansprechpartner))
{
echo Unguuml;ltige Werte im Ansprechpartner;
exit;
}

if (ereg([0-9 ()/],$telefon) == false)
{
echo Unguuml;ltige Werte bei Telefon;
exit;
}

if (ereg([0-9 ()/],$fax) == false)
{
echo Unguuml;ltige Werte bei Fax;
exit;
}

What is the code for the correct validating.

Regards,
Ruprecht Helms
---
Ruprecht Helms IT-Service  Softwaredevelopement

Web: http://www.rheyn.de
Mail: [EMAIL PROTECTED]

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



[PHP-DB] date problems

2007-09-06 Thread rDubya
I'm having a problem with dates in php and mysql.  I run a site that
promotes dated events and concerts and has the information for each
stored in a mysql database with the timestamp field.

Here is the function that checks the date of the event to ensure it is
between now and three weeks from now (only events in this time period
are displayed on a page, with all events being displayed on another
page)

function check_date ($mysql_timestamp, $days) {

$timestamp = mktime(0, 0, 0, substr($mysql_timestamp, 4, 2),
substr($mysql_timestamp, 6, 2), substr($mysql_timestamp, 0, 4));
$event_day = date(z, $timestamp);
$event_year = date(Y, $timestamp);
$actual_day = date(z);
$actual_year =  date(Y);

while ($event_year  $actual_year) {
$event_day = $event_day + 365;
$event_year--;
}

if (($event_day - $actual_day) = $days  $event_day =
$actual_day) { return TRUE; }

else { return FALSE; }
}


Then, to display the events that fill this criteria, there is this
code for the date:

function short_date ($mysql_timestamp) {
$stimestamp = mktime(0, 0, 0, substr($mysql_timestamp, 4, 2),
substr($mysql_timestamp, 6, 2), substr($mysql_timestamp, 0, 4));
$sformatted_date = date(D M j, $stimestamp);
return $sformatted_date;
}


My problem is that I have events dated for Sep 2007 and on, and yet
they all come up as being on Dec 7 to 9, 2006..  any ideas?

rDubya

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



RE: [PHP-DB] date problems

2007-09-06 Thread Instruct ICC

From: rDubya [EMAIL PROTECTED]
My problem is that I have events dated for Sep 2007 and on, and yet
they all come up as being on Dec 7 to 9, 2006..  any ideas?

rDubya


How about having MySQL only return the events you are interested in?

SELECT yourEventFields FROM theTable
WHERE
TO_DAYS( theEventDate ) = TO_DAYS( NOW() )
AND
TO_DAYS( theEventDate ) = TO_DAYS( NOW() ) + 21

I like theEventDate to be in the format -MM-DD

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_to-days

_
A place for moms to take a break! 
http://www.reallivemoms.com?ocid=TXT_TAGHMloc=us


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



Re: [PHP-DB] date problems

2007-09-06 Thread Mike Gohlke
It's much better to use add_date instead of to_days since mysql isn't 
smart enough to do it for you.

Such as:
SELECT yourEventFields FROM theTable
WHERE theEventDate BETWEEN now() AND date_add(now(), INTERVAL 21 DAYS;

This way mysql will calc the now() and date_add and will essentially 
convert them to static values.  If there's an index on theEventDate it 
will be used.


Mike...

Instruct ICC wrote:

From: rDubya [EMAIL PROTECTED]
My problem is that I have events dated for Sep 2007 and on, and yet
they all come up as being on Dec 7 to 9, 2006..  any ideas?

rDubya


How about having MySQL only return the events you are interested in?

SELECT yourEventFields FROM theTable
WHERE
TO_DAYS( theEventDate ) = TO_DAYS( NOW() )
AND
TO_DAYS( theEventDate ) = TO_DAYS( NOW() ) + 21

I like theEventDate to be in the format -MM-DD

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_to-days 



_
A place for moms to take a break! 
http://www.reallivemoms.com?ocid=TXT_TAGHMloc=us




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



Re: [PHP-DB] date problems

2007-09-06 Thread Mike Gohlke
Argh, make sure you add the closing paren for the date_add since I 
forgot it.


Mike...

Mike Gohlke wrote:
It's much better to use add_date instead of to_days since mysql isn't 
smart enough to do it for you.

Such as:
SELECT yourEventFields FROM theTable
WHERE theEventDate BETWEEN now() AND date_add(now(), INTERVAL 21 DAYS;

This way mysql will calc the now() and date_add and will essentially 
convert them to static values.  If there's an index on theEventDate it 
will be used.


Mike...

Instruct ICC wrote:

From: rDubya [EMAIL PROTECTED]
My problem is that I have events dated for Sep 2007 and on, and yet
they all come up as being on Dec 7 to 9, 2006..  any ideas?

rDubya


How about having MySQL only return the events you are interested in?

SELECT yourEventFields FROM theTable
WHERE
TO_DAYS( theEventDate ) = TO_DAYS( NOW() )
AND
TO_DAYS( theEventDate ) = TO_DAYS( NOW() ) + 21

I like theEventDate to be in the format -MM-DD

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_to-days 



_
A place for moms to take a break! 
http://www.reallivemoms.com?ocid=TXT_TAGHMloc=us






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



Re: [PHP-DB] date problems

2007-09-06 Thread rDubya
Thanks for the help so far guys!!

Not helping though.  I have the date contained in the database as timestamp
(-MM-DD HH:MM:SS).  The problem is that not only is it not displaying
events, but if I alter my code so that it displays ALL events, it shows the
events for the last year, and those upcoming, as all being in the first
couple weeks of December, 2006.

Here is the script in action: http://www.clubandpub.ca/lobby/?city=1

The events SHOULD display on the right column, under where it says events.
If you click to the GUIDE page, the calendar should be highlighted on the
dates where there are events, and the events in the coming weeks (as well as
concerts) should display below that (under their respective headings).

This DID work, but I recently switched hosting companies as the one I was
with has become increasingly unreliable after the company changed hands.  My
new server uses PHP 5 server, with MySQL 4.1 (I'm not 100% sure what the old
was.. I think it was PHP 4, and while I think it was the same MySQL version,
it could have been an earlier one).

Cheers!

rDubya

also, here is the code that actually displays the events:

?php

$db = mysql_connect(xx, user, pw) or error(mysql_error);
mysql_select_db(database, $db) or error(mysql_error);

$eventquery = mysql_query(SELECT * FROM `EVENTS` WHERE `event_city` =
'$city' ORDER BY `date` ASC, $db);

while($event_data = mysql_fetch_assoc($eventquery)) {

if (check_date($event_data[date], 21) == TRUE) {
?


it then displays the event information of the events within that time period
(pulled from the database, with the date being displayed using the
short_date function posted earlier)





On 9/6/07, Mike Gohlke [EMAIL PROTECTED] wrote:

 Argh, make sure you add the closing paren for the date_add since I
 forgot it.

 Mike...

 Mike Gohlke wrote:
  It's much better to use add_date instead of to_days since mysql isn't
  smart enough to do it for you.
  Such as:
  SELECT yourEventFields FROM theTable
  WHERE theEventDate BETWEEN now() AND date_add(now(), INTERVAL 21 DAYS;
 
  This way mysql will calc the now() and date_add and will essentially
  convert them to static values.  If there's an index on theEventDate it
  will be used.
 
  Mike...
 
  Instruct ICC wrote:
  From: rDubya [EMAIL PROTECTED]
  My problem is that I have events dated for Sep 2007 and on, and yet
  they all come up as being on Dec 7 to 9, 2006..  any ideas?
 
  rDubya
 
  How about having MySQL only return the events you are interested in?
 
  SELECT yourEventFields FROM theTable
  WHERE
  TO_DAYS( theEventDate ) = TO_DAYS( NOW() )
  AND
  TO_DAYS( theEventDate ) = TO_DAYS( NOW() ) + 21
 
  I like theEventDate to be in the format -MM-DD
 
 
 http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_to-days
 
 
  _
  A place for moms to take a break!
  http://www.reallivemoms.com?ocid=TXT_TAGHMloc=us
 
 

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