RE: [PHP-DB] datetime

2003-01-22 Thread John W. Holmes
 hello and thank you... probably again.
 using datetime, /or something else if applicable, is it possible to
 have entries to a page and entries to a db automatically delete? i
 have looked through many docs at php.net and mysql and can't find
 anything. perhaps i'm using the wrong search key words.? thanks
 again, Addison

Well, no, not automatically. But you can run a query to delete records
that are over X days old.

DELETE FROM table WHERE datetime_field  CURDATE() - INTERVAL 30 DAYS

Will delete anything over 30 days old. Adapt to your needs.

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



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




Re: [PHP-DB] foreach($HTTP_POST_VARS as $key = $value)

2003-01-22 Thread Andrey Hristov
 Long time ago I built a class for these needs. In fact the half of the code
is *stolen* from implemenation of my colleague. I just made it OOP.

 The class in pi-validate.class.php.txt, the definitions of the checked
fields is in pi-validate.defs.php

Sample use :
  $validate_result = CValidate::validate_validate_data(VALIDATE_NEW_USER,
$user_data);
  if ($validate_result[0] != GENERAL_OPERATION_SUCCESSFUL){
   return array(VALIDATE_FAIL, VALIDATE_FAIL_MESSAGE, $validate_result[2]);
  }/* if */

It is kindly complicated example but hope you get it. For every new page
just define the variables you expect to come and rules for them and nothing
more is needed except to place a code like that above to check the validity.
In case of error $validate_result will contain information for the error.


Regards,
Andrey


- Original Message -
From: Addison Ellis [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, January 22, 2003 9:24 AM
Subject: [PHP-DB] foreach($HTTP_POST_VARS as $key = $value)


 hello,
 i do appreciate your time...
 below the code following i don't know where to go. do i need
 to list each value individually or can i do something with
 $HTTP_POST_VARS  or am i even headed in the right direction? i am
 trying to point all my forms to this .php file to check for errors,
 and if they are ok, insert the submitted form values into a table in
 a database. thank you. addison ellis
 foreach($HTTP_POST_VARS as $key = $value)
{
  if ($key != )
  {
if ($value == )
{
  $message_new = font face=verdana size=1
 color=redRequired information missing.\n
  Please try again./font;
}
  }
  if (ereg({name),$key))
  {
   if (!ereg(^[A-Za-z' -]{1,50}$,$key))
   {
 $message_new = font face=verdana size=1 color=redSome
 information not processing.\n
  Please try again./font;
   }
  }
  $$key = strip_tags(trim($value));
}
if (!ereg(^[0-9)(xX -]{7,20}$,$phone))
{
  $message_new = font face=verdana size=1 color=redNot a
 valid phone number.\n
  Please try again./font;
}
if (!ereg(^.+@.+\\..+$,$email))
{
  $message_new = font face=verdana size=1 color=redNot a
 valid email address.\n
   Please try again./font;
 }
else
 if ($message == )
 {
 $query = insert into ad_columns  set
 --
 Addison Ellis
 small independent publishing co.
 114 B 29th Avenue North
 Nashville, TN 37203
 (615) 321-1791
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 subsidiaries of small independent publishing co.
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]

?php
/**
Definition file - defintions of various data.

This module is part from PHPIntra system and is licensed under GPL.

@author Andrey Hristov [EMAIL PROTECTED]
@version$Id: pi-validate.defs.php,v 1.3 2002/07/09 07:30:22 nobody Exp $
@packagePHPIntra
@module pi_validate_defs
*/

/**
@const  VALIDATE_NEW_RULE   .
*/
define('VALIDATE_NEW_RULE', 'new_rule_defs');

/**
@const  VALIDATE_UPDATE_RULE.
*/
define('VALIDATE_UPDATE_RULE', 'update_rule_defs');

/**
@const  VALIDATE_NEW_USER   .
*/
define('VALIDATE_NEW_USER', 'new_user_defs');

/**
@const  VALIDATE_CHANGE_USER_DATA   .
*/
define('VALIDATE_CHANGE_USER_DATA', 'change_user_defs');

/**
@const  VALIDATE_CREATE_TASK_DATA   .
*/
define('VALIDATE_CREATE_TASK_DATA', 'create_task');

/**
@const  VALIDATE_UPDATE_TASK_DATA   .
*/
define('VALIDATE_UPDATE_TASK_DATA', 'update_task');

/**
@const  VALIDATE_CREATE_WSESSION_DATA   .
*/
define('VALIDATE_CREATE_WSESSION_DATA', 'create_wsession');

/*
T - Text
H - Hidden
P - Password
A - text Area
F - File upload
L - List (select)
M - Multiple Selection
C - Checkbox
*/
define('VALIDATE_TYPE_INT',1);
define('VALIDATE_TYPE_FLOAT',2);
define('VALIDATE_TYPE_ARRAY',3);
define('VALIDATE_TYPE_STRING',4);

define('VALIDATE_SELECT_NONE','none');

$VALIDATE_DEFINITIONS = array(
VALIDATE_UPDATE_RULE = array(
'old_schedule_id'   = array(
'type'  = 'T',
'pattern'   = '/^\d+$/',
'optional'  = 0,
'maxlen'= 10,
'allowtags' = 0,
'lang_type' = VALIDATE_TYPE_INT,
),
'old_start_time'= array(
'type'  = 'T',
'pattern'   = 
'/^(?:(?:(?:0|1|)[\d]{1})|(?:2[0-3]{1}))(?:\:[\d]{0,2}){0,2}$/',
'optional'  = 0,
'maxlen'= 8,
'allowtags' = 0,
'lang_type' = VALIDATE_TYPE_STRING,
),
'schedule_id'   = 

Re: [PHP-DB] Cookies problems

2003-01-22 Thread Paul Burney
on 1/21/03 10:37 PM, Sabina Alejandr Schneider at
[EMAIL PROTECTED] appended the following bits to my mbox:

 Hello people!!! This time I have a problem with cookies. I
 tried to send a cookie from one page with the function
 sendcookie(chat,$mail) to a page in another directory,
 but when I tried to prine echo($chat) or
 echo($_COOKIE[chat]) I got notheing. So I put the second
 page where it was the page that sent the cookie and tried
 again. This last time I got the cookie in the echo($chat)
 but not in the echo($_COOKIE[chat]) I need to send a
 cookie to a page in another path and I need that the
 cookie stays in the client browser so I can see if I can
 recognize him/ her next time he/she enters the chat. Was I
 clear? Thank you very much for all of your help and
 time!!! I really appreciate your help in times I'm
 desesperated like this time :-)

Because this question doesn't have anything to do with databases, it should
be posted to PHP-General.  You can sign up here:

http://www.php.net/mailing-lists.php

It is under general user list

FYI, cookies won't be seen until the next time you view the page.  If your
setcookie command and echo $cookie commands are in the same file, you won't
see the echo unless you reload.

You may also wish to look at the documentation for the setcookie (not
sendcookie) function:

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

HTH.

Sincerely,

Paul Burney
http://paulburney.com/

?php
while ($self != asleep) {
$sheep_count++;
}
?



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




Re: [PHP-DB] Array problems

2003-01-22 Thread Paul Burney
on 1/22/03 12:08 AM, Michael Conway at [EMAIL PROTECTED] appended the
following bits to my mbox:

 I find myself stuck in coming up with a way to cycle through this
 array of db results for porting to a graphing script that I did not
 write.  My latest attempt to get around this problem is below.  Outside
 of the $graph-SetDataValues(array( ));, echoing $array[$i] produces the
 desired results for three sets of two bar graphs with the corresponding
 title.  However, inside the $graph function, I get only the last
 expected set of bar graphs and title.  I originally iterated through
 each anticipated result from mysql_fetch_array($result) and plugged each
 of these values into an array calling the columns individually. I got
 the desired graph, but, of course this is bad programming and not useful
 for queries producing a greater number of rows (I simply needed to know
 it worked).  Any help would be appreciated.

What exactly is the Graph class expecting in terms of data?  Is it supposed
to generate several graphs when you give it the data, or one graph per
specified dataset?

If it's the latter, move the $graph-DrawGraph(); call inside your while
loop. 

If not, let us know what format it needs the data in and we'll help you
figure out how to get it from the database into that format.

If you can't figure out what format of data the class needs, you should let
us see the graph class source.

HTH.

Sincerely,

Paul Burney
http://paulburney.com/

?php

if ($your_php_version  4.1.2) {
upgrade_now();  // to avoid major security problems
}

?


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




[PHP-DB] posting field_DATE variables

2003-01-22 Thread Fabrizio Tivano
Hello dear all, 

I have a  php-application witch use mysql DB;

My db have a field (DATE) like timestamp(8)  = 20030110, 
for lay-out problem i call field_DATE 
with a query :
 date_format(field_DATE, '%d-%m-%Y'),

and it display the field_DATA;
10-01-2003 

well.at this point i need to post this field_DATA on another php script witch 
let me to make another SELECT on same DB;
 but now the $field_DATA variable is like 10-01-2003.

How i can post $field_DATA variable such as 20030110 again? (the original DB_field).


thaks in advance

ciao, 
fabrizio

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




[PHP-DB] Re: Using Objects with Databases

2003-01-22 Thread Manuel Lemos
Hello,

On 01/22/2003 03:26 AM, Philip Zee wrote:

I am trying to create a class, say User.  Each user has an entry in the database
table called user.  Each function, including the constructor, will be calling
the database to do something.  Is it better to initialize the database
connection inside each function or is it better to initialize the connection at
the beginning of the class?  What's the best practice on this?


I think Metastorage is what you are looking for. It is a persistence 
layer generator application. It lets you model your classes of objects 
and then it generates all the code for the classes that store and 
retrieves the objects of those classes in database tables.

You do not have to write any code. You just specify the operations that 
you want to perform with the objects of your classes and Metastorage 
generates adequate code to execute such operations with class functions 
that you may configure to your needs.

Metastorage is Open Source and is available here:

http://www.meta-language.net/metastorage.html

http://www.meta-language.net/news-2002-12-09-metastorage.html


--

Regards,
Manuel Lemos


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



Re: [PHP-DB] posting field_DATE variables

2003-01-22 Thread Jason Wong
On Wednesday 22 January 2003 23:53, Fabrizio Tivano wrote:
 I have a  php-application witch use mysql DB;

 My db have a field (DATE) like timestamp(8)  = 20030110,
 for lay-out problem i call field_DATE
 with a query :
  date_format(field_DATE, '%d-%m-%Y'),

 and it display the field_DATA;
 10-01-2003

 well.at this point i need to post this field_DATA on another php script
 witch let me to make another SELECT on same DB;
  but now the $field_DATA variable is like 10-01-2003.

 How i can post $field_DATA variable such as 20030110 again? (the original
 DB_field).

There are many ways to do this. One is:

  $date = explode('-', '10-01-2003');
  $newdate = $date[2] . $date[0] . $date[1];

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *


/*
To err is humor.
*/


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




Re: [PHP-DB] posting field_DATE variables

2003-01-22 Thread Fabrizio Tivano
On Thu, 23 Jan 2003 00:27:26 +0800
Jason Wong [EMAIL PROTECTED] wrote:

 On Wednesday 22 January 2003 23:53, Fabrizio Tivano wrote:
  I have a  php-application witch use mysql DB;
 
  My db have a field (DATE) like timestamp(8)  = 20030110,
  for lay-out problem i call field_DATE
  with a query :
   date_format(field_DATE, '%d-%m-%Y'),
 
  and it display the field_DATA;
  10-01-2003
 
  well.at this point i need to post this field_DATA on another php script
  witch let me to make another SELECT on same DB;
   but now the $field_DATA variable is like 10-01-2003.
 
  How i can post $field_DATA variable such as 20030110 again? (the original
  DB_field).
 
 There are many ways to do this. One is:
 
   $date = explode('-', '10-01-2003');
   $newdate = $date[2] . $date[0] . $date[1];
 
 -- 
 Jason Wong - Gremlins Associates - www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *
 

YEP! 
that's work fine! 

thanx a lot!
fabrizio

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




[PHP-DB] Re: Problem in the returnvalue of a function

2003-01-22 Thread Bayu Susiloadhy
that means the result is not right,
it happen when your query is failed,check your query,
mysql_error() can help 

Ruprecht Helms writes: 


Hi  Bayu Susiloadhy, 

thanks for your answer. 

  function select_price($product_id,$quantity) {

 --cut--

return True;
   }

 --cut--


in the meentime I change the code that not a boolevalue
was returned by the function. 

$q is my querystring and $db is the selected database. 

I insert the following: 

   $db-query($q);
$result=mysql_db_query($db,$q); 

while ($row = mysql_fetch_object($result))
{
$price = $row-product_price;
}
mysql_free_result($result);
echo \n;
echo $q;  // to show the sql-statement in runtime - diagnostics
echo \n;
return $price; 


By executing it I get two warnings  both this is not a valid Mysql-result
resort. The disliked lines are the begin of the while-loop and an the
mysql_free_result($result)-command. 

How have I to change up the script to get the product_price related to the
price_group. 

Regards,
Ruprecht 


--
Ruprecht Helms IT-Service und Softwareentwicklung 

Tel/Fax.:  +49[0]7621 16 99 16
Homepage:  http://www.rheyn.de
email:  [EMAIL PROTECTED]
-- 

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






--
STOP doing things that
the computer can does!
--
$BS 

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



[PHP-DB] revised: foreach($HTTP_POST_VARS...

2003-01-22 Thread Addison Ellis
hello,
i am trying to point all my forms to this .php file to check for 
errors, and if they are ok, insert the submitted form values into a 
table in a database.
if i use this:
?
require(config.php);

$error = ;
if ($name == )
	{
	$error = $errorLIYou must enter a company name./LI;
	}
if ($address == )
{
$error = $errorLIYou must enter an address./LI;
}

etc.   and the form, say yardsale.php, doesn't have the field 
name in it, will it skip over that field or will it return an 
error saying name is blank?or
can you tell me where to go from beyond the attached email below?
	below the code following i don't know where to go. do i need 
to list each value individually or can i do something with 
$HTTP_POST_VARS  or am i even headed in the right direction?
foreach($HTTP_POST_VARS as $key = $value)   
  {
if ($key != )
{
  if ($value == )
  {
$message_new = font face=verdana size=1 
color=redRequired information missing.\n
Please try again./font;
  }
} 
if (ereg($key))   
{
 if (!ereg(^[A-Za-z' -]{1,50}$,$key))
 {
   $message_new = font face=verdana size=1 color=redSome 
information not processing.\n
Please try again./font;
 } 
}
$$key = strip_tags(trim($value));  
  }
  if (!ereg(^[0-9)(xX -]{7,20}$,$contact_phone)) 
  {
$message_new = font face=verdana size=1 color=redNot a 
valid phone number.\n
Please try 
again./font; 
  }
  if (!ereg(^.+@.+\\..+$,$contact_email)) 
  {
$message_new = font face=verdana size=1 color=redNot a 
valid email address.\n
 Please try again./font;
}
  else
if ($message == )
	{
	$query = insert into ad_columns  set


(from here can i write something like $query = 
foreach($HTTP_POST_VARS as $key = $value) insert into ad_columns 
set???
thank you. addison ellis
--
Addison Ellis
small independent publishing co.
114 B 29th Avenue North
Nashville, TN 37203
(615) 321-1791
[EMAIL PROTECTED]
[EMAIL PROTECTED]
subsidiaries of small independent publishing co.
[EMAIL PROTECTED]
[EMAIL PROTECTED]


[PHP-DB] ORA-03106 Error

2003-01-22 Thread Alberto Grájeda C.
I have the problem: ORA-03106: fatal two-task communication ...

I'm running redhat 7.3 with oracle 9i client connecting to oracle 8.0.5 
Server on NT. I put the putEnv to $ORACLE_HOME,$ORACLE_SID,I use OCIDefineByName, but 
the result is the 
error. When I'm using the oci functions I can't receive anything, but if I 
use the old oracle functions of php, the results are good.

Do someone have any idea to resolve my problem??

Thanks in advance.

P.D. I probe to set up the User=oracle and Group dba in apache web server, 
but  either, it's not working.


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




[PHP-DB] using Flat File

2003-01-22 Thread web man

Hi,

I have posted my question to this list before but I did not get a help that I was 
expected.

All I wanted to do is to give access for the users to view a page in which the below 
code is embedded. The user will enter his/her username and password.

But the code is not working.

I don't know what to think. 

I need your help guys. Don't let me die on this code 

?php

 $auth = false;
 if (isset( $PHP_AUTH_USER )   isset($PHP_AUTH_PW)) {


 $filename = 'c:\\php_data\\file.txt';
 $f = @fopen($filename, r);
  if ($f != FALSE)
  {$a = @fread($f, filesize($filename));
 fclose($f);
  }
  else
  {
   echo Could not open file;
  }



 $lines = explode ( \n, $file_contents );



 foreach ( $lines as $line ) {

 list( $username, $password ) = explode( ':', $line );

 if ( ( $username == $PHP_AUTH_USER ) amp;amp;
  ( $password == $PHP_AUTH_PW ) ) {




 $auth = true;
 break;

 }
 }

 }

 if ( ! $auth ) {

 header( 'WWW-Authenticate: Basic realm=Private' );
 header( 'HTTP/1.0 401 Unauthorized' );
 echo 'Authorization Required.';
 exit;

 } else {

 echo 'PYou are authorized!/P';
 }

 ?






-
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now


RE: [PHP-DB] using Flat File

2003-01-22 Thread Hutchins, Richard
What do you mean the code doesn't work? How is the code behaving? What kinds
of errors are being returned by the interpreter? Is your register_globals
set to ON or OFF? Are you certain you have access to the directory in which
the file you wish to open is located?

 -Original Message-
 From: web man [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, January 22, 2003 2:02 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] using Flat File
 
 
 
 Hi,
 
 I have posted my question to this list before but I did not 
 get a help that I was expected.
 
 All I wanted to do is to give access for the users to view a 
 page in which the below code is embedded. The user will enter 
 his/her username and password.
 
 But the code is not working.
 
 I don't know what to think. 
 
 I need your help guys. Don't let me die on this code 
 
 ?php
 
  $auth = false;
  if (isset( $PHP_AUTH_USER )   isset($PHP_AUTH_PW)) {
 
 
  $filename = 'c:\\php_data\\file.txt';
  $f = @fopen($filename, r);
   if ($f != FALSE)
   {$a = @fread($f, filesize($filename));
  fclose($f);
   }
   else
   {
echo Could not open file;
   }
 
 
 
  $lines = explode ( \n, $file_contents );
 
 
 
  foreach ( $lines as $line ) {
 
  list( $username, $password ) = explode( ':', $line );
 
  if ( ( $username == $PHP_AUTH_USER ) amp;amp;
   ( $password == $PHP_AUTH_PW ) ) {
 
 
 
 
  $auth = true;
  break;
 
  }
  }
 
  }
 
  if ( ! $auth ) {
 
  header( 'WWW-Authenticate: Basic realm=Private' );
  header( 'HTTP/1.0 401 Unauthorized' );
  echo 'Authorization Required.';
  exit;
 
  } else {
 
  echo 'PYou are authorized!/P';
  }
 
  ?
 
 
 
 
 
 
 -
 Do you Yahoo!?
 Yahoo! Mail Plus - Powerful. Affordable. Sign up now
 

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




Re: [PHP-DB] using Flat File

2003-01-22 Thread John Krewson
Check to see if $PHP_AUTH_USER exists by echoing it to the browser,
and make sure you have permissions to the txt file you are trying to read.

That's all I can think of given the lack of information such as error 
messages, where it breaks, etc.


web man wrote:

Hi,

I have posted my question to this list before but I did not get a help 
that I was expected.

All I wanted to do is to give access for the users to view a page in 
which the below code is embedded. The user will enter his/her username 
and password.

But the code is not working.

I don't know what to think.

I need your help guys. Don't let me die on this code

$auth = false;
if (isset( $PHP_AUTH_USER )   isset($PHP_AUTH_PW)) {


$filename = 'c:\\php_data\\file.txt';
$f = @fopen($filename, r);
 if ($f != FALSE)
 {$a = @fread($f, filesize($filename));
fclose($f);
 }
 else
 {
  echo Could not open file;
 }



$lines = explode ( \n, $file_contents );



foreach ( $lines as $line ) {

list( $username, $password ) = explode( ':', $line );

if ( ( $username == $PHP_AUTH_USER ) 
 ( $password == $PHP_AUTH_PW ) ) {




$auth = true;
break;

}
}

}

if ( ! $auth ) {

header( 'WWW-Authenticate: Basic realm=Private' );
header( 'HTTP/1.0 401 Unauthorized' );
echo 'Authorization Required.';
exit;

} else {

echo '

You are authorized!

';
}

?






-
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now


--
John Krewson
Programmer - SWORPS


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




[PHP-DB] add.php

2003-01-22 Thread Addison Ellis
hello,
	i was hoping someone could help me further this?
	i have multiple form possibilities someone can fill out. each 
form, on submit would point to say, add.php. it would check for blank 
fields. if there are no blank fields it would insert the current 
values into the database accordingly. the issue i am facing is each 
form has different fields, for instance: form 1 has name, email and 
question. form 2 has name, email, ticket_type, price, how many. form 
3 has name, email, vehicle, color, year. and on and on.
	i appreciate your taking time to read this and any input you 
may have is also appreciated.
if i use this:
?
require(config.php);

$error = ;
if ($name == )
	{
	$error = $errorLIYou must enter a company name./LI;
	}
if ($address == )
{
$error = $errorLIYou must enter an address./LI;
}

etc.   and the form, say yardsale.php, doesn't have the field 
name in it, will it skip over that field or will it return an 
error saying name is blank?

this goes at the end of my ifs...
} else {

$query  = update ads set
name = '$name',
etc.





	my best regards, addison ellis
--
Addison Ellis
small independent publishing co.
114 B 29th Avenue North
Nashville, TN 37203
(615) 321-1791
[EMAIL PROTECTED]
[EMAIL PROTECTED]
subsidiaries of small independent publishing co.
[EMAIL PROTECTED]
[EMAIL PROTECTED]


Re: [PHP-DB] using Flat File

2003-01-22 Thread Addison Ellis
here is what i use. have your login_form.php post to this and call 
this login.php. hope it helps. addison

?
  session_start();
  session_register('auth');
  session_register('logname');
  include(config.php);   //this file (config.php) contains the 
database connection 
info.   
  {
case login:
  $sql = SELECT username FROM accounts 
  WHERE username='$username';
  $result = mysql_query($sql)
  or die(Couldn't execute query1.);
  $num = mysql_num_rows($result);  
  if ($num == 1)  // login name was found   
  {
 $sql = SELECT username FROM accounts  
 WHERE username='$username'
 AND password='$password';
 $result2 = mysql_query($sql)
   or die(Couldn't execute query2.);
 $num2 = mysql_num_rows($result2);
 if ($num2  0)  // password is correct
 {

$auth=yes;  
   $logname=$username;
   $today = date(Y-m-d h:m:s);   
   $sql = INSERT INTO login (username,logintime) //this is a 
login table in the db. not necessarily needed.
   VALUES ('$username','$today');
   mysql_query($sql) or die(Can't execute query login.);
   header(Location: 
where_you_want_user_to_go_if_authorized.php);
 }
 else// password is not correct
 { 
   $message=font face=verdana size=1 color=redThis account 
exists,\n  
 but you have not entered the\n 
 correct password!\n Please try again./font;
   include(login_form.php);  
 }
  }
  elseif ($num == 0)  // login name not found  
  {  
 unset($do);   
 $message = font face=verdana size=1 color=redThe eMail 
Address you entered\n 
 can't be found!\n Please try again or\n
Create a New Account./font;
 include(login_form.php); //this is the file that actually 
contains the log in text fields
  }
?   


Hi,

I have posted my question to this list before but I did not get a 
help that I was expected.

All I wanted to do is to give access for the users to view a page in 
which the below code is embedded. The user will enter his/her 
username and password.

But the code is not working.

I don't know what to think.

I need your help guys. Don't let me die on this code

?php

 $auth = false;
 if (isset( $PHP_AUTH_USER )   isset($PHP_AUTH_PW)) {


 $filename = 'c:\\php_data\\file.txt';
 $f = @fopen($filename, r);
  if ($f != FALSE)
  {$a = @fread($f, filesize($filename));
 fclose($f);
  }
  else
  {
   echo Could not open file;
  }



 $lines = explode ( \n, $file_contents );



 foreach ( $lines as $line ) {

 list( $username, $password ) = explode( ':', $line );

 if ( ( $username == $PHP_AUTH_USER ) amp;amp;
  ( $password == $PHP_AUTH_PW ) ) {




 $auth = true;
 break;

 }
 }

 }

 if ( ! $auth ) {

 header( 'WWW-Authenticate: Basic realm=Private' );
 header( 'HTTP/1.0 401 Unauthorized' );
 echo 'Authorization Required.';
 exit;

 } else {

 echo 'PYou are authorized!/P';

  }


 ?







-
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now


--
Addison Ellis
small independent publishing co.
114 B 29th Avenue North
Nashville, TN 37203
(615) 321-1791
[EMAIL PROTECTED]
[EMAIL PROTECTED]
subsidiaries of small independent publishing co.
[EMAIL PROTECTED]
[EMAIL PROTECTED]


[PHP-DB] inserting dates

2003-01-22 Thread Diana Castillo
When I insert a date into Mysql it has to be in year/month/day format or
else it wont go in right.
how do I convert my date variable which is in month /day /year format into
year/month/day format?


--
Productos de salud:
http://www.nvtechnologies.com/hgh



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




Re: [PHP-DB] inserting dates

2003-01-22 Thread Jeffrey_N_Dyke

check out DATE_FORMAT in the mysql manual.  and acually you'll want
year-month-day not year/month/day...if you're using the mysql defualt date.

DATE_FORMAT(NOW(), '%m/%d/%Y') - would return 01/22/2003

hth
jeff


   

Diana Castillo   

diana.castillo@nvtechnol   To: [EMAIL PROTECTED]   

ogies.com  cc:

Subject: [PHP-DB] inserting 
dates  
01/22/2003 05:19 PM

   

   





When I insert a date into Mysql it has to be in year/month/day format or
else it wont go in right.
how do I convert my date variable which is in month /day /year format into
year/month/day format?


--
Productos de salud:
http://www.nvtechnologies.com/hgh



--
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] Secure variable transport (newbie)

2003-01-22 Thread Karina S
Hi,

I have read, that use global variables on php site is not a good idea. I'm
newbie in PHP and maybe a stupid question:
If I make an array and register it in a session and after I use it all of my
pages as $HTTP_SESSION_VARS['variable'] and register_globals is off. In this
case is $HTTP_SESSION_VARS['variable'] a global variable?

What is the best method (most secure method) to use the same array on all
php site? (I want to read the user data, but don't want to read it always
from database. I want to read once and use it on more pages. )

Thanks for your help!




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




RE: [PHP-DB] inserting dates

2003-01-22 Thread John W. Holmes
 check out DATE_FORMAT in the mysql manual.  and acually you'll want
 year-month-day not year/month/day...if you're using the mysql defualt
 date.

Actually, you can use any delimiter with MySQL, so long as it's in year,
month, day order.
 
 DATE_FORMAT(NOW(), '%m/%d/%Y') - would return 01/22/2003
 When I insert a date into Mysql it has to be in year/month/day format
or
 else it wont go in right.
 how do I convert my date variable which is in month /day /year format
into
 year/month/day format?

Many ways. This question was just asked today, actually. Simple way is:

$part = explode(/,$your_date);
$mysql_date = $part[2] . $part[0] . $part[1];

for MMDD format, which is also valid. Adapt to your needs.

---John Holmes...



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




[PHP-DB] Members area

2003-01-22 Thread Gavin Amm
Hi All,

I'm about to start development on a members area for a site.
The members area will have 2 levels - Paid  Free, with the Paid members
having access to more pages.

I have not created a members area before  am after any advice or links
I can get... I think a lot of reading is in order...

Particularly:
- DB structure  fields (I'll be using MySQL if that's relevant)
- Sessions (I've seen quite a few threads covering sessions over the
last couple of months, so should have some links in my 'inbox'
somewhere... But the more the merrier...)
- Any PHP suggestions/advice/links
- Anything else you can think is relevant...


Thanks, this will be a big help.

Cheers,
Gav

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




[PHP-DB] dump a damn big db with via SSH

2003-01-22 Thread dufronte
Hi all..,
I have a problem here...
I have a pretty damn big db in my account on host.sk
When I failed to dump the file from phpmyadmin.. so I try to dump it via
SSH..

The problem is... when I dump the whole database... it failed..
And it said that the file limit exceeded...

How can I solve that ???

Plz Help.. coz I still newbie in *nix... :(

Thanks in Advanced...


   ---DuFronte--- 
  http://kapsul.org
  Web Administrator
PHP Game Developer



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




Re: [PHP-DB] Members area

2003-01-22 Thread Jim Hunter
Gavin,

Download PHP-Nuke and look to see how they handle Non-Users/users/Admins
and go from there. It's actually quite easy. They have a table structure
that you could utilize and some generic routines for determining if a user
is logged in or if they are an Admin.

www.phpnuke.org

Jim
 
---Original Message---
 
From: Gavin Amm
Date: Wednesday, January 22, 2003 05:05:32 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Members area
 
Hi All,

I'm about to start development on a members area for a site.
The members area will have 2 levels - Paid  Free, with the Paid members
having access to more pages.

I have not created a members area before  am after any advice or links
I can get... I think a lot of reading is in order...

Particularly:
- DB structure  fields (I'll be using MySQL if that's relevant)
- Sessions (I've seen quite a few threads covering sessions over the
last couple of months, so should have some links in my 'inbox'
somewhere... But the more the merrier...)
- Any PHP suggestions/advice/links
- Anything else you can think is relevant...


Thanks, this will be a big help.

Cheers,
Gav

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

.


[PHP-DB] save output to a file instead of displaying in the browser

2003-01-22 Thread Qunfeng Dong
Hi,

I am trying to build a PHP-MySQL application. When
users query our database from our web interface, how
can I send the output to a file for users to save it
to his local disk instead of displaying the output to
the browser. 

Thanks,

Qunfeng 

__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

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




RE: [PHP-DB] dump a damn big db with via SSH

2003-01-22 Thread John W. Holmes
 Hi all..,
 I have a problem here...
 I have a pretty damn big db in my account on host.sk
 When I failed to dump the file from phpmyadmin.. so I try to dump it
via
 SSH..
 
 The problem is... when I dump the whole database... it failed..
 And it said that the file limit exceeded...
 
 How can I solve that ???
 
 Plz Help.. coz I still newbie in *nix... :(

Dump it a few tables at a time.

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



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