Re: [PHP-DB] DB access failure...

2004-07-19 Thread Jason Wong
On Tuesday 20 July 2004 13:16, \[php\]Walter wrote:
> I have a mySQL DB running on an NT server.

> $db_host   = 'db.myserver.net';

> Now, if I change $db_host to the machine IP, it works fine.

If db.myserver.net does not resolve to a sensible IP address add it to your 
HOSTS file. Or setup your DNS properly. Or just use the IP address.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
If you think something is important, no one else will. 
-- Murphy's Laws for Researchers n2
*/

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



[PHP-DB] DB access failure...

2004-07-19 Thread \[php\]Walter
I have a mySQL DB running on an NT server.

I just re-installed it (long story) and everything seems to be fine, except
DB access.

// Connectivity data
$db_engine = 'mysql';
$db_host   = 'db.myserver.net';
$db_user   = 'test';
$db_pass   = 'test';
$db_name  = 'test';

   // Data Source Name: This is the universal connection string
   $dsn = "$db_engine://$db_user:[EMAIL PROTECTED]/$db_name";

   // DB::connect will return a PEAR DB object on success
   // or an PEAR DB Error object on error
   $objDB = DB::connect($dsn);

I get this...

DB Error: connect failed

Now, if I change $db_host to the machine IP, it works fine.

Anyone have any ideas what I did work, or what I can set to make the machine
name work again?

Thanks

Walter

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



Re: [PHP-DB] howto get PK id after INSERT??

2004-07-19 Thread Larry E . Ullman
I have a form to insert customer data into a table. The form goes to 
php
page to input data to db hen uses header to go to a final page
displaying customer's information.
Is there a way to get the ID (custid PK UNIQUE AUTO_INCREMENT) from
mysql after INSERT then pass to final page using urlencode to pull cust
record?
Use the appropriately named mysql_insert_id() function.
Larry
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] howto get PK id after INSERT??

2004-07-19 Thread Jason Wong
On Tuesday 20 July 2004 10:09, Vincent Jordan wrote:

> Is there a way to get the ID (custid PK UNIQUE AUTO_INCREMENT) from
> mysql after INSERT then pass to final page using urlencode to pull cust
> record?

manual > MySQL Functions

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
I used to think that the brain was the most wonderful organ in
my body.  Then I realized who was telling me this.
-- Emo Phillips
*/

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



[PHP-DB] howto get PK id after INSERT??

2004-07-19 Thread Vincent Jordan
I have a form to insert customer data into a table. The form goes to php
page to input data to db hen uses header to go to a final page
displaying customer's information. 
Is there a way to get the ID (custid PK UNIQUE AUTO_INCREMENT) from
mysql after INSERT then pass to final page using urlencode to pull cust
record?

Here is snip from form, post page and final page

FORM CustomerAddNew.php








 .. 






POST PAGE CustomerAddNew1.php
ini_set('display_errors', 1);
error_reporting(E_ALL &~ E_NOTICE);
// Get information from CustomerAdNew.php and make into functions.
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$address = $_POST['address'];
$address2 = $_POST['address2'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$home = $_POST['homephone'];
$work = $_POST['workphone'];
$other = $_POST['otherphone'];
$email = $_POST['email'];
// Connect, Select, and POST to database
$connect = mysql_connect("**", "**", "**") or die ("unable to connect to
database" . mysql_error() . "**");
$select = mysql_select_db("**") or die ("unable to connect to database"
. mysql_error() . "**");
$send = mysql_query("INSERT INTO customerinfo (firstname, lastname,
address, address2, city, state, zip, homephone, workphone, otherphone,
email) VALUES ('$firstname', '$lastname', '$address', '$address2',
'$city', '$state', '$zip', '$home', '$work', '$other', '$email')") or
die ("unable to post data" .' ' . mysql_error() . ' '. "to table
custinfo. Please contact your Administrator");
if ($send) {
print ' Customer Added ';
}
else
{
print 'something went wrong';
}
header("Location: UserMain.php");

>From here I would like to populate the page with data that was just
entered. 
(example)
Cust No 
Name 
Address 
Etc . . . 


RE: [PHP-DB] mysqli/Statement isn't valid anymore in x.php line #

2004-07-19 Thread Gilmore, Corey (DPC)

> John Holmes wrote:
>
> Gilmore, Corey (DPC) wrote:
> 
> > Is anyone familiar with what would cause an error like this:
> > Warning: Statement isn't valid anymore in includes\import.inc.php on
> > line 810
> 
> 1. Which line is 810? That's going to really help someone determine why 
> you may be getting this warning.

if( !$stmt->bind_param("sssd", $addr->PhoneType, $addr->Phone, $addr->Extension, 
$ContactID ) ) {

> 
> 2. This is a warning, not an error. While annoying, it really can be 
> ignored if the program actually works correctly. The warning can be 
> hidden by using an appropriate error_reporing() level.
> 
Unfortunately it doesn't work, somewhere between my successful call to 
mysqli->prepare() and bind_param my statement object is (apparantly) destroyed, and 
nothing is actually inserted.

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



Re: [PHP-DB] mysqli/Statement isn't valid anymore in x.php line #

2004-07-19 Thread John W. Holmes
Gilmore, Corey (DPC) wrote:
Is anyone familiar with what would cause an error like this:
Warning: Statement isn't valid anymore in includes\import.inc.php on
line 810
1. Which line is 810? That's going to really help someone determine why 
you may be getting this warning.

2. This is a warning, not an error. While annoying, it really can be 
ignored if the program actually works correctly. The warning can be 
hidden by using an appropriate error_reporing() level.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] DB table creation question

2004-07-19 Thread Vincent Jordan
I think I may have gone over my head. I am fairly new to mysql and php.
My host only allows access to mysql via phpmysql. I am used to using
mysqlcc to connect to the db's and make changes. By default all tables
created are MYISAM, when I try to input a INNODB table with foreign keys
I either get syntax error or I believe it is errno(150). Anyhow, is
there a piece of software or a webpage out there where I can input how I
want the database to be made and it will spit out a .sql file that can
be uploaded to phpmyadmin or would someone be kind enough to "hold my
hand" as I attempt to create this with proper syntax myself. 

Another note, instead of using indexes and keys can I have tables relate
to each other by php script or am I asking for trouble as it grows. This
database will be small at first however I expect it to grow to over 5k
of customer records after the third month and in stages of about 200
records monthly after that. 

Thanks for all the help everyone has provided thusfar.

-Original Message-
From: Matthew McNicol [mailto:[EMAIL PROTECTED] 
Sent: Monday, July 19, 2004 3:08 AM
To: Vincent Jordan
Cc: [EMAIL PROTECTED]
Subject: [SPAM] Re: [PHP-DB] RE: [SPAM] Re: [PHP-DB] DB table creation
question


at the moment if a value is say inserted into the 'warranty_info' table 
you are just checking that the 'product_id' or 'cust_id' already exists 
in 'product_info' and 'customer_info'. you still have to populate them 
first, otherwise the referential integrity will return an error when you

insert into 'warranty_info'.

similarly if you delete a record from 'warranty_info' you might actually

delete the associated customer record. is this what you want?

at the moment it looks like the 'rma_info' table is not linked to any 
other table?

personally, I would not go so far as to specify 'FOREIGN KEY ... 
REFERENCES' or 'ON UPDATE CASCADE ON DELETE RESTRICT' in the create 
table code. I would use the application code to make sure a customer 
exists before referencing them in the 'product_info' or 'warranty_info' 
tables. similarly I would use the application code to delete table 
record out of each appropriate table.

I would use the primary and secondary index assuming you are working 
with more than 100 records in each table.






Vincent Jordan wrote:
> Does this seem to be correct? With this if value was inserted into a
> table will the tables with the FK's automatically be updated? Here is
> the DB design as I have it now. Let me know if all is correct please.
> 
> CREATE TABLE customer_info (
>cust_id int (6) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
>first_name varchar (50) NOT NULL,
>last_name varchar (50) NOT NULL,
>address varchar (50) NOT NULL,
>address2 varchar (50) NULL,
>city varchar (50) NOT NULL,
>state varchar (50) NOT NULL,
>zip varchar (50) NOT NULL,
>home_phone varchar (15) NOT NULL,
>work_phone varchar (15) NULL,
>other_phone varchar (15) NULL,
>email varchar (50) NOT NULL,
>);
> CREATE TABLE product_info (
>product_id int (6) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY
KEY,
>cust_id int (6) NOT NULL,
>model varchar (50) NOT NULL,
>serial varchar (20) NULL,
>FOREIGN KEY (customer_info_cust_id),
> REFERENCES customer_info(cust_id),
>ON UPDATE CASCADE ON DELETE RESTRICT,
>INDEX (cust_id),
>FOREIGN KEY (cust_id),
>REFERENCES customer_info(cust_id),
>);
> CREATE TABLE warranty_info (
>warranty_id int (6) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY
KEY,
>product_id int (6) NOT NULL,
>cust_id (6) NOT NULL,
>mfg_warranty tinyint (1) NOT NULL default '1',
>gold_warranty tinyint (1) NOT NULL default '0',
>gold_warranty_id int (16) NULL,
>FOREIGN KEY (customer_info_cust_id),
> REFERENCES customer_info(cust_id),
>ON UPDATE CASCADE ON DELETE RESTRICT,
>INDEX (cust_id),
>FOREIGN KEY (cust_id),
>REFERENCES customer_info(cust_id),
>FOREIGN KEY (product_info_product_id),
> REFRENCES product_info(product_id),
>ON UPDATE CASCADE ON DELETE RESTRICT,
>INDEX (product_id),
>FOREIGN KEY (prod_id),
> REFRENCES product_info (product_id),
>);
> CREATE TABLE rma_info (
>rma_id int (6) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
>assigned_to varchar (50) NULL,
>logged_by varchar (50) NULL,
>date datetime NOT NULL,
>time_spent datetime (6) NULL,
>status varchar (50) NOT NULL,
>priority varchar (50) NULL,
>closed_by varchar (50) NULL,
>completed_by varchar (50) NULL,
>date_closed datetime (6) NULL,
>billable tinyint(1)NULL,
>billed tinyint (1) NULL,
>cost varchar (6) NULL,
>last_modified_by varchar (50) NULL,
>last_modified_date datetime NULL,
>

[PHP-DB] mysqli/Statement isn't valid anymore in x.php line #

2004-07-19 Thread Gilmore, Corey (DPC)
Hello,

Is anyone familiar with what would cause an error like this:
Warning: Statement isn't valid anymore in includes\import.inc.php on
line 810

I'm using MySQL 4.1.2a, PHP 5.0.0 with Apache 2.0.50.  All tables are
InnoDB format.

The calling function is:
function insert_phone($ContactID) {
global $kTABLE_PREFIX;

foreach( $this->PhoneList as $addr ) {
$db = DoMySQLConnect(); // connect
$sql = "INSERT INTO {$kTABLE_PREFIX}phone (PhoneType, Phone,
Extension, ContactID) VALUES (?, ?, ?, ?)";
if( !$stmt = $db->prepare($sql) ) { // prepare it
printf("Error with %s:%s",$sql, $db->error );
} else {
if( !$stmt->bind_param("sssd", $addr->PhoneType,
$addr->Phone, $addr->Extension, $ContactID ) ) {
printf("Error (#%d): %s;%s",
$stmt->errno, $sql, $stmt->error );
} else {
$stmt->execute(); // execute
$stmt->free_result();
$stmt->close();
}
}
$db->close();
}
}

bind_param fails and I end up with:
Error (#0): INSERT INTO ap2004phone (PhoneType, Phone, Extension,
ContactID) VALUES (?, ?, ?, ?);

insert_phone is part of a class, Phone.

import.inc.php contains class definitions for a bunch of different
objects, contacts, email addresses, addresses etc that are being
massaged from a single flat table into relational tables.  There are
around 2000 inserts performed in a single import.  At the beginning of
the import I disable all foreign key checks etc 
...
$sql =  "SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT; "
.   "SET
@OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS; "
.   "SET
@OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION; "
.   "SET NAMES utf8; "
.   "SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS,
UNIQUE_CHECKS=0; "
.   "SET
@OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; "
.   "SET @OLD_SQL_MODE=@@SQL_MODE,
SQL_MODE=\"NO_AUTO_VALUE_ON_ZERO\"; ";

$db = DoMySQLConnect();
$db->multi_query($sql);
$db->close();
...

And at the end of the import I re-enable them.

As far as I can tell, there is nothing wrong with the INSERT statement,
or the variables it is inserting.  The errors appear randomly, and for
different objects at different times.  Occasionally there are no errors,
and then other times there are hundreds.  There are no mysql errors in
the mysql error log either.

Anyone have any ideas?  I'm going crazy :(

Thanks,
Corey

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



RE: Re[2]: [PHP-DB] Begining PHP...Have Questions

2004-07-19 Thread Hutchins, Richard
But has that change (commas to periods) addressed the original problem you
posted regarding the code not returning the results you expect?

Rich


> -Original Message-
> From: Aaron Todd [mailto:[EMAIL PROTECTED]
> Sent: Monday, July 19, 2004 3:14 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Re[2]: [PHP-DB] Begining PHP...Have Questions
> 
> 
> That explains it.  I did look at the manual and it did show . 
> instead of ,
> It just didnt even hit me.  One of those kick yourself mistakes.
> 
> Thanks,
> 
> Aaron
> 
> 
> "Pablo M. Rivas" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Hello Aaron,
> >
> > why are you using , instead of . ?
> >
> >   $query = "SELECT * FROM users WHERE 
> email='",$_POST['username'],"'";
> >   is this a typo?...
> >   this sould be:
> >   $query = "SELECT * FROM users WHERE 
> email='".$_POST['username']."'";
> >   or $query = "SELECT * FROM users WHERE
> email='{$_POST['username']}'";
> >
> >   mhhh.. do you whant to know wy echo works and $query= not?
> >   read the manual... (string functions, echo) and (Language
> >   reference, String Operators)
> >
> >
> >   in echo case, you are giving more than 1 argument:
> >   echo "blahblablah",$variable,"blahblahblah";
> >   in $xx="blahblahblah",$variable,"blahblahblah" you 
> are getting a
> >   parse error.
> >
> >
> > AT> That makes great sence, however when I tried using 
> $_POST in my SQL
> > AT> statement it would not work.
> >
> > AT> This works fine:
> > AT> $query = "SELECT * FROM users WHERE email='".$username."'";
> > AT> But this one doesnt at all:
> > AT> $query = "SELECT * FROM users WHERE 
> email='",$_POST['username'],"'";
> >
> > AT> It does however work for  all the echo commands and It 
> is also correct
> when
> > AT> I echo the statement:
> > AT> echo "SELECT * FROM users WHERE email='",$_POST['username'],"'";
> >
> > AT> Am I missing something?
> >
> > AT> Thanks again,
> >
> > AT> Aaron
> >
> >
> >
> >
> > -- 
> > Best regards,
> >  Pablo
> 
> -- 
> 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: Re[2]: [PHP-DB] Begining PHP...Have Questions

2004-07-19 Thread Aaron Todd
That explains it.  I did look at the manual and it did show . instead of ,
It just didnt even hit me.  One of those kick yourself mistakes.

Thanks,

Aaron


"Pablo M. Rivas" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hello Aaron,
>
> why are you using , instead of . ?
>
>   $query = "SELECT * FROM users WHERE email='",$_POST['username'],"'";
>   is this a typo?...
>   this sould be:
>   $query = "SELECT * FROM users WHERE email='".$_POST['username']."'";
>   or $query = "SELECT * FROM users WHERE
email='{$_POST['username']}'";
>
>   mhhh.. do you whant to know wy echo works and $query= not?
>   read the manual... (string functions, echo) and (Language
>   reference, String Operators)
>
>
>   in echo case, you are giving more than 1 argument:
>   echo "blahblablah",$variable,"blahblahblah";
>   in $xx="blahblahblah",$variable,"blahblahblah" you are getting a
>   parse error.
>
>
> AT> That makes great sence, however when I tried using $_POST in my SQL
> AT> statement it would not work.
>
> AT> This works fine:
> AT> $query = "SELECT * FROM users WHERE email='".$username."'";
> AT> But this one doesnt at all:
> AT> $query = "SELECT * FROM users WHERE email='",$_POST['username'],"'";
>
> AT> It does however work for  all the echo commands and It is also correct
when
> AT> I echo the statement:
> AT> echo "SELECT * FROM users WHERE email='",$_POST['username'],"'";
>
> AT> Am I missing something?
>
> AT> Thanks again,
>
> AT> Aaron
>
>
>
>
> -- 
> Best regards,
>  Pablo

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



RE: [PHP-DB] Begining PHP...Have Questions

2004-07-19 Thread Neal Carmine
Correct me if I am wrong

But shouldn't the if statement be 

if (!$_POST['passw'] == mysql_result($result,0,"pass")){

not

if (!$_POST['passw'] = mysql_result($result,0,"pass")){

Two equal signs not one...

Regards,
Neal

-Original Message-
From: Hutchins, Richard [mailto:[EMAIL PROTECTED] 
Sent: Monday, July 19, 2004 12:38 PM
To: [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Begining PHP...Have Questions

Trade in those commas around your $_POST['username'] for some periods.

Rich


> -Original Message-
> From: Aaron Todd [mailto:[EMAIL PROTECTED]
> Sent: Monday, July 19, 2004 2:08 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP-DB] Begining PHP...Have Questions
> 
> 
> That makes great sence, however when I tried using $_POST in my SQL
> statement it would not work.
> 
> This works fine:
> $query = "SELECT * FROM users WHERE email='".$username."'";
> But this one doesnt at all:
> $query = "SELECT * FROM users WHERE email='",$_POST['username'],"'";
> 
> It does however work for  all the echo commands and It is 
> also correct when
> I echo the statement:
> echo "SELECT * FROM users WHERE email='",$_POST['username'],"'";
> 
> Am I missing something?
> 
> Thanks again,
> 
> Aaron
> 
> 
> 
> 
> "Justin Patrin" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > You should generally $_POST for all posted variables, $_GET for all
> > "get" variables (in the query string / url), and the other
> > superglobals for other such things. If you don't care if it's POST,
> > GET, or a cookie, you can use $_REQUEST.
> >
> > register_globals is a setting in your php.ini. It's best practice to
> > set this to "off". What this means for you is that variables sent by
> > the user are not registered as global variables. i.e. $username will
> > no longer work, you have to use $_POST['username']. Search the php
> > lists for lots more discussion on this matter.
> >
> > For more on superglobals:
> > http://www.php.net/manual/en/language.variables.predefined.php
> > For the list archives, click the "Archive" links here:
> > http://www.php.net/mailing-lists.php
> >
> > On Mon, 19 Jul 2004 13:27:15 -0400, Aaron Todd 
> <[EMAIL PROTECTED]>
> wrote:
> > > Jon,
> > >
> > > Thanks for the info.  I did change the LIKE to =.  This 
> was done just
> for my
> > > debugging.  I do have it set to = on a normal basis.
> > >
> > > I am a little unsure what you mean at the end of your reply about
> register
> > > globals.  Are you saying that everywhere I use $username 
> to refer to the
> > > users inputed username I should use $_POST['username'] 
> instead?  Or are
> you
> > > suggesting to use this in one location.
> > >
> > > Thanks again for the reply,
> > >
> > > Aaron
> > >
> > > "Jonathan Haddad" <[EMAIL PROTECTED]> wrote in message
> > > news:[EMAIL PROTECTED]
> > >
> > >
> > > > if you have shell access, please do the following
> > > >
> > > > describe users;
> > > > select * from users;
> > > >
> > > > also, why are you using LIKE instead of =?
> > > > use this instead:
> > > >
> > > > $query = "SELECT * FROM users WHERE email = '".$username."'";
> > > >
> > > > i would also suggest turning off register globals and using
> > > > $_POST['username'] and not $username. (i'm assuming 
> it's on given your
> > > code)
> > > >
> > > > Jon
> > > >
> > > > Aaron Todd wrote:
> > > >
> > > > >I am just starting out with PHP and I have created a 
> simple login
> program
> > > > >that is supposed to check users input with a mysql 
> database.  I am
> doing
> > > 5
> > > > >verifications before the program is completed...Check 
> for the Submit
> > > button,
> > > > >check for a valid email address(which is the 
> username), check for a
> valid
> > > > >password, check to see if the username exists in the 
> database, and
> > > finally
> > > > >check to see if the password matches the database for the
> coresponding
> > > > >username.  Currently you dont get access to a site you 
> only get told
> what
> > > > >your password is in the database.
> > > > >
> > > > >Everything is technically working, but its not perfect 
> and I think I
> need
> > > > >some help.  I have entered 2 records in the database 
> for testing
> > > purposes.
> > > > >When I put in username1 and password1 it works.  The 
> program returns
> the
> > > > >coresponding password.  When I change to username2 and 
> still put in
> > > > >password1 it will return password1.
> > > > >
> > > > >I have done some debuging and I am unsure of what is really
> happening.
> > > My
> > > > >code is below.  Would anyone be able to tell me what I am doing
> wrong.
> > > > >
> > > > >Thanks,
> > > > >
> > > > >Aaron
> > > > >
> > > > >
> > > > >
> > > > > > > > >if ($submit) {
> > > > >  //VALID USERNAME/EMAIL ADDRESS
> > > > >  if
> > > >
> > >
> >(!ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[!#$%&\'*+
> \\/0-9=?A-Z^_`
> > > a
> > > > >-z{|}`]+\.'.'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', 
> $username)) {
> > > > >$error = "You must enter a valid emai

Re: [PHP-DB] Begining PHP...Have Questions

2004-07-19 Thread Scot L. Harris
On Mon, 2004-07-19 at 14:08, Aaron Todd wrote:
> That makes great sence, however when I tried using $_POST in my SQL
> statement it would not work.
> 
> This works fine:
> $query = "SELECT * FROM users WHERE email='".$username."'";
> But this one doesnt at all:
> $query = "SELECT * FROM users WHERE email='",$_POST['username'],"'";
   
^^^^ 
> 
> It does however work for  all the echo commands and It is also correct when
> I echo the statement:
> echo "SELECT * FROM users WHERE email='",$_POST['username'],"'";
> 
> Am I missing something?
> 

I think you need to use . (period) in place of those , (commas).

-- 
Scot L. Harris
[EMAIL PROTECTED]

The chief cause of problems is solutions.
-- Eric Sevareid 

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



Re[2]: [PHP-DB] Begining PHP...Have Questions

2004-07-19 Thread Pablo M. Rivas
Hello Aaron,

why are you using , instead of . ?

  $query = "SELECT * FROM users WHERE email='",$_POST['username'],"'";
  is this a typo?...
  this sould be:
  $query = "SELECT * FROM users WHERE email='".$_POST['username']."'";
  or $query = "SELECT * FROM users WHERE email='{$_POST['username']}'";

  mhhh.. do you whant to know wy echo works and $query= not?
  read the manual... (string functions, echo) and (Language
  reference, String Operators)

  
  in echo case, you are giving more than 1 argument:
  echo "blahblablah",$variable,"blahblahblah";
  in $xx="blahblahblah",$variable,"blahblahblah" you are getting a
  parse error.

  
AT> That makes great sence, however when I tried using $_POST in my SQL
AT> statement it would not work.

AT> This works fine:
AT> $query = "SELECT * FROM users WHERE email='".$username."'";
AT> But this one doesnt at all:
AT> $query = "SELECT * FROM users WHERE email='",$_POST['username'],"'";

AT> It does however work for  all the echo commands and It is also correct when
AT> I echo the statement:
AT> echo "SELECT * FROM users WHERE email='",$_POST['username'],"'";

AT> Am I missing something?

AT> Thanks again,

AT> Aaron




-- 
Best regards,
 Pablo

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



RE: [PHP-DB] Begining PHP...Have Questions

2004-07-19 Thread Hutchins, Richard
Trade in those commas around your $_POST['username'] for some periods.

Rich


> -Original Message-
> From: Aaron Todd [mailto:[EMAIL PROTECTED]
> Sent: Monday, July 19, 2004 2:08 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP-DB] Begining PHP...Have Questions
> 
> 
> That makes great sence, however when I tried using $_POST in my SQL
> statement it would not work.
> 
> This works fine:
> $query = "SELECT * FROM users WHERE email='".$username."'";
> But this one doesnt at all:
> $query = "SELECT * FROM users WHERE email='",$_POST['username'],"'";
> 
> It does however work for  all the echo commands and It is 
> also correct when
> I echo the statement:
> echo "SELECT * FROM users WHERE email='",$_POST['username'],"'";
> 
> Am I missing something?
> 
> Thanks again,
> 
> Aaron
> 
> 
> 
> 
> "Justin Patrin" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > You should generally $_POST for all posted variables, $_GET for all
> > "get" variables (in the query string / url), and the other
> > superglobals for other such things. If you don't care if it's POST,
> > GET, or a cookie, you can use $_REQUEST.
> >
> > register_globals is a setting in your php.ini. It's best practice to
> > set this to "off". What this means for you is that variables sent by
> > the user are not registered as global variables. i.e. $username will
> > no longer work, you have to use $_POST['username']. Search the php
> > lists for lots more discussion on this matter.
> >
> > For more on superglobals:
> > http://www.php.net/manual/en/language.variables.predefined.php
> > For the list archives, click the "Archive" links here:
> > http://www.php.net/mailing-lists.php
> >
> > On Mon, 19 Jul 2004 13:27:15 -0400, Aaron Todd 
> <[EMAIL PROTECTED]>
> wrote:
> > > Jon,
> > >
> > > Thanks for the info.  I did change the LIKE to =.  This 
> was done just
> for my
> > > debugging.  I do have it set to = on a normal basis.
> > >
> > > I am a little unsure what you mean at the end of your reply about
> register
> > > globals.  Are you saying that everywhere I use $username 
> to refer to the
> > > users inputed username I should use $_POST['username'] 
> instead?  Or are
> you
> > > suggesting to use this in one location.
> > >
> > > Thanks again for the reply,
> > >
> > > Aaron
> > >
> > > "Jonathan Haddad" <[EMAIL PROTECTED]> wrote in message
> > > news:[EMAIL PROTECTED]
> > >
> > >
> > > > if you have shell access, please do the following
> > > >
> > > > describe users;
> > > > select * from users;
> > > >
> > > > also, why are you using LIKE instead of =?
> > > > use this instead:
> > > >
> > > > $query = "SELECT * FROM users WHERE email = '".$username."'";
> > > >
> > > > i would also suggest turning off register globals and using
> > > > $_POST['username'] and not $username. (i'm assuming 
> it's on given your
> > > code)
> > > >
> > > > Jon
> > > >
> > > > Aaron Todd wrote:
> > > >
> > > > >I am just starting out with PHP and I have created a 
> simple login
> program
> > > > >that is supposed to check users input with a mysql 
> database.  I am
> doing
> > > 5
> > > > >verifications before the program is completed...Check 
> for the Submit
> > > button,
> > > > >check for a valid email address(which is the 
> username), check for a
> valid
> > > > >password, check to see if the username exists in the 
> database, and
> > > finally
> > > > >check to see if the password matches the database for the
> coresponding
> > > > >username.  Currently you dont get access to a site you 
> only get told
> what
> > > > >your password is in the database.
> > > > >
> > > > >Everything is technically working, but its not perfect 
> and I think I
> need
> > > > >some help.  I have entered 2 records in the database 
> for testing
> > > purposes.
> > > > >When I put in username1 and password1 it works.  The 
> program returns
> the
> > > > >coresponding password.  When I change to username2 and 
> still put in
> > > > >password1 it will return password1.
> > > > >
> > > > >I have done some debuging and I am unsure of what is really
> happening.
> > > My
> > > > >code is below.  Would anyone be able to tell me what I am doing
> wrong.
> > > > >
> > > > >Thanks,
> > > > >
> > > > >Aaron
> > > > >
> > > > >
> > > > >
> > > > > > > > >if ($submit) {
> > > > >  //VALID USERNAME/EMAIL ADDRESS
> > > > >  if
> > > >
> > >
> >(!ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[!#$%&\'*+
> \\/0-9=?A-Z^_`
> > > a
> > > > >-z{|}`]+\.'.'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', 
> $username)) {
> > > > >$error = "You must enter a valid email address for your
> > > username.";
> > > > >echo "$error";
> > > > >  } else {
> > > > >$db = mysql_connect("localhost", "username", "password");
> > > > >mysql_select_db("database",$db);
> > > > >$query = "SELECT * FROM users WHERE email LIKE 
> '".$username."'";
> > > > >echo "$query";
> > > > >$result = mysql_query($query,$db);
> > > > >$num_rows = mysql_num_rows($result);
> > > > > 

Re: [PHP-DB] Begining PHP...Have Questions

2004-07-19 Thread Aaron Todd
Jon,

The table contains 2 fields...email and pass.  My plan is to use the email
address as the username.

$query = "SELECT * FROM users WHERE email='".$username."'";

I used this query because a persons whole email address should be unique.  I
didnt feel it was necessary to add the AND password= because there shouldnt
ever be 2 of the same exact email address' in the table.

Thanks again,

Aaron




"Jonathan Haddad" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> You want to use $_POST['username'] instead of $username everywhere you
> have a POST variable.  I believe this became the standard around PHP4.2.
>
> Can you give us the table def and the results of that select?  Also, can
> you copy that query ( echo "$query";)  into your next reply?
>
> I think you're query looked something like this before:
>
> SELECT * from user where username LIKE ""?
>
> That would select the entire table.  You could do it like this:
>
> SELECT * from user WHERE username = '{$_POST['username']} AND password =
> '{$_POST['password']}
>
> that will only return the row that matches both the username and
> password - so if 1 row is returned it must be the login info.  That'll
> cut down on the PHP code you need to write.
>
> Aaron Todd wrote:
>
> >Jon,
> >
> >Thanks for the info.  I did change the LIKE to =.  This was done just for
my
> >debugging.  I do have it set to = on a normal basis.
> >
> >I am a little unsure what you mean at the end of your reply about
register
> >globals.  Are you saying that everywhere I use $username to refer to the
> >users inputed username I should use $_POST['username'] instead?  Or are
you
> >suggesting to use this in one location.
> >
> >Thanks again for the reply,
> >
> >Aaron
> >
> >
> >"Jonathan Haddad" <[EMAIL PROTECTED]> wrote in message
> >news:[EMAIL PROTECTED]
> >
> >
> >>if you have shell access, please do the following
> >>
> >>describe users;
> >>select * from users;
> >>
> >>also, why are you using LIKE instead of =?
> >>use this instead:
> >>
> >>$query = "SELECT * FROM users WHERE email = '".$username."'";
> >>
> >>i would also suggest turning off register globals and using
> >>$_POST['username'] and not $username. (i'm assuming it's on given your
> >>
> >>
> >code)
> >
> >
> >>Jon
> >>
> >>Aaron Todd wrote:
> >>
> >>
> >>
> >>>I am just starting out with PHP and I have created a simple login
program
> >>>that is supposed to check users input with a mysql database.  I am
doing
> >>>
> >>>
> >5
> >
> >
> >>>verifications before the program is completed...Check for the Submit
> >>>
> >>>
> >button,
> >
> >
> >>>check for a valid email address(which is the username), check for a
valid
> >>>password, check to see if the username exists in the database, and
> >>>
> >>>
> >finally
> >
> >
> >>>check to see if the password matches the database for the coresponding
> >>>username.  Currently you dont get access to a site you only get told
what
> >>>your password is in the database.
> >>>
> >>>Everything is technically working, but its not perfect and I think I
need
> >>>some help.  I have entered 2 records in the database for testing
> >>>
> >>>
> >purposes.
> >
> >
> >>>When I put in username1 and password1 it works.  The program returns
the
> >>>coresponding password.  When I change to username2 and still put in
> >>>password1 it will return password1.
> >>>
> >>>I have done some debuging and I am unsure of what is really happening.
> >>>
> >>>
> >My
> >
> >
> >>>code is below.  Would anyone be able to tell me what I am doing wrong.
> >>>
> >>>Thanks,
> >>>
> >>>Aaron
> >>>
> >>>
> >>>
> >>> >>>if ($submit) {
> >>> //VALID USERNAME/EMAIL ADDRESS
> >>> if
> >>>
> >>>
>
>>(!ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[!#$%&\'*+\\/0-9=?A-Z^_
`
> >>
> >>
> >a
> >
> >
> >>>-z{|}`]+\.'.'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', $username)) {
> >>>   $error = "You must enter a valid email address for your
> >>>
> >>>
> >username.";
> >
> >
> >>>   echo "$error";
> >>> } else {
> >>>   $db = mysql_connect("localhost", "username", "password");
> >>>   mysql_select_db("database",$db);
> >>>   $query = "SELECT * FROM users WHERE email LIKE '".$username."'";
> >>>   echo "$query";
> >>>   $result = mysql_query($query,$db);
> >>>   $num_rows = mysql_num_rows($result);
> >>>   echo "There are $num_rows records matching $username";
> >>>   //VALID PASSWORD
> >>>   echo "Entered User Name:  $username";
> >>>   echo "Entered Password:  $passw";
> >>>   if (strlen($passw) < 6 || !preg_match('/[a-z]/i', $passw) ||
> >>>!preg_match('/[0-9]/', $passw)) {
> >>> $error = "Invalid Password.  Must be greater than six characters
> >>>containing at least one number.";
> >>> echo "$error";
> >>>   } else {
> >>> //USERNAME/EMAIL ADDRESS IN DATABASE
> >>> if (!$num_rows){
> >>>   $error = "Username was not found.  Please Register.";
> >>>   echo "$error";
> >>>   die(mysql_error());
> >>> } else {
> >>>   //ENTERED PASSWORD IN DATABASE
> >>>   if (!$passw = my

[PHP-DB] Re: Begining PHP...Have Questions

2004-07-19 Thread Aaron Todd
Thanks to everyone so far who has responded, but the other posts are going
down a different road than what I currently need.

In my code below I am building a login page.  I am continuing to do
different things to debug this problem myself and I think I have narrowed it
down a bit.  Like I said in my previous post...the program does work without
error, it just doesnt produce the expected results.  When I enter username1
and password 1 I get pasword1.  When I enter username2 and password2 I get
password2.  When I enter username2 and password1 I get password2.  This isnt
a very effective login program.

If you look at the last if statement:
if (!$_POST['passw'] = mysql_result($result,0,"pass")){
  $error = "Invalid Password.";
  echo "$error";
} else {
  printf("Password is %s\n", mysql_result($result,0,"pass"));
}

I am trying to validate what is entered in the form with what is in the
database.  That looks like good code to me, but like I said before, when I
enter username2 and password1 I get password2.  I think $result should only
contain the row that username2 is in so the pass field should have
password2.  I believe it does.  But If I put password1 in the form and the
program checks to see if it is equil to password2 it should echo the error.

You may be able to tell, but I am getting really confused by this.

If anyone can help with this I would really appreciate it.

Aaron




"Aaron Todd" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I am just starting out with PHP and I have created a simple login program
> that is supposed to check users input with a mysql database.  I am doing 5
> verifications before the program is completed...Check for the Submit
button,
> check for a valid email address(which is the username), check for a valid
> password, check to see if the username exists in the database, and finally
> check to see if the password matches the database for the coresponding
> username.  Currently you dont get access to a site you only get told what
> your password is in the database.
>
> Everything is technically working, but its not perfect and I think I need
> some help.  I have entered 2 records in the database for testing purposes.
> When I put in username1 and password1 it works.  The program returns the
> coresponding password.  When I change to username2 and still put in
> password1 it will return password1.
>
> I have done some debuging and I am unsure of what is really happening.  My
> code is below.  Would anyone be able to tell me what I am doing wrong.
>
> Thanks,
>
> Aaron
>
> 
> 
>  if ($submit) {
>   //VALID USERNAME/EMAIL ADDRESS
>   if
>
(!ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[!#$%&\'*+\\/0-9=?A-Z^_`a
> -z{|}`]+\.'.'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', $username)) {
> $error = "You must enter a valid email address for your
username.";
> echo "$error";
>   } else {
> $db = mysql_connect("localhost", "username", "password");
> mysql_select_db("database",$db);
> $query = "SELECT * FROM users WHERE email LIKE '".$username."'";
> echo "$query";
> $result = mysql_query($query,$db);
> $num_rows = mysql_num_rows($result);
> echo "There are $num_rows records matching $username";
> //VALID PASSWORD
> echo "Entered User Name:  $username";
> echo "Entered Password:  $passw";
> if (strlen($passw) < 6 || !preg_match('/[a-z]/i', $passw) ||
> !preg_match('/[0-9]/', $passw)) {
>   $error = "Invalid Password.  Must be greater than six characters
> containing at least one number.";
>   echo "$error";
> } else {
>   //USERNAME/EMAIL ADDRESS IN DATABASE
>   if (!$num_rows){
> $error = "Username was not found.  Please Register.";
> echo "$error";
> die(mysql_error());
>   } else {
> //ENTERED PASSWORD IN DATABASE
> if (!$passw = mysql_result($result,0,"pass")){
>   $error = "Invalid Password.";
>   echo "$error";
> } else {
>   printf("Password is %s\n", mysql_result($result,0,"pass"));
> }
>   }
> }
>   }
> } else {
>
>   ?>
>
> 
>
>   User Name:
>
>   Password:
>
>   
>
>   
>
> 
> } // end if
>
>
> ?>
>
> 
>
> 

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



Re: [PHP-DB] Begining PHP...Have Questions

2004-07-19 Thread Aaron Todd
That makes great sence, however when I tried using $_POST in my SQL
statement it would not work.

This works fine:
$query = "SELECT * FROM users WHERE email='".$username."'";
But this one doesnt at all:
$query = "SELECT * FROM users WHERE email='",$_POST['username'],"'";

It does however work for  all the echo commands and It is also correct when
I echo the statement:
echo "SELECT * FROM users WHERE email='",$_POST['username'],"'";

Am I missing something?

Thanks again,

Aaron




"Justin Patrin" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> You should generally $_POST for all posted variables, $_GET for all
> "get" variables (in the query string / url), and the other
> superglobals for other such things. If you don't care if it's POST,
> GET, or a cookie, you can use $_REQUEST.
>
> register_globals is a setting in your php.ini. It's best practice to
> set this to "off". What this means for you is that variables sent by
> the user are not registered as global variables. i.e. $username will
> no longer work, you have to use $_POST['username']. Search the php
> lists for lots more discussion on this matter.
>
> For more on superglobals:
> http://www.php.net/manual/en/language.variables.predefined.php
> For the list archives, click the "Archive" links here:
> http://www.php.net/mailing-lists.php
>
> On Mon, 19 Jul 2004 13:27:15 -0400, Aaron Todd <[EMAIL PROTECTED]>
wrote:
> > Jon,
> >
> > Thanks for the info.  I did change the LIKE to =.  This was done just
for my
> > debugging.  I do have it set to = on a normal basis.
> >
> > I am a little unsure what you mean at the end of your reply about
register
> > globals.  Are you saying that everywhere I use $username to refer to the
> > users inputed username I should use $_POST['username'] instead?  Or are
you
> > suggesting to use this in one location.
> >
> > Thanks again for the reply,
> >
> > Aaron
> >
> > "Jonathan Haddad" <[EMAIL PROTECTED]> wrote in message
> > news:[EMAIL PROTECTED]
> >
> >
> > > if you have shell access, please do the following
> > >
> > > describe users;
> > > select * from users;
> > >
> > > also, why are you using LIKE instead of =?
> > > use this instead:
> > >
> > > $query = "SELECT * FROM users WHERE email = '".$username."'";
> > >
> > > i would also suggest turning off register globals and using
> > > $_POST['username'] and not $username. (i'm assuming it's on given your
> > code)
> > >
> > > Jon
> > >
> > > Aaron Todd wrote:
> > >
> > > >I am just starting out with PHP and I have created a simple login
program
> > > >that is supposed to check users input with a mysql database.  I am
doing
> > 5
> > > >verifications before the program is completed...Check for the Submit
> > button,
> > > >check for a valid email address(which is the username), check for a
valid
> > > >password, check to see if the username exists in the database, and
> > finally
> > > >check to see if the password matches the database for the
coresponding
> > > >username.  Currently you dont get access to a site you only get told
what
> > > >your password is in the database.
> > > >
> > > >Everything is technically working, but its not perfect and I think I
need
> > > >some help.  I have entered 2 records in the database for testing
> > purposes.
> > > >When I put in username1 and password1 it works.  The program returns
the
> > > >coresponding password.  When I change to username2 and still put in
> > > >password1 it will return password1.
> > > >
> > > >I have done some debuging and I am unsure of what is really
happening.
> > My
> > > >code is below.  Would anyone be able to tell me what I am doing
wrong.
> > > >
> > > >Thanks,
> > > >
> > > >Aaron
> > > >
> > > >
> > > >
> > > > > > >if ($submit) {
> > > >  //VALID USERNAME/EMAIL ADDRESS
> > > >  if
> > >
> >
>(!ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[!#$%&\'*+\\/0-9=?A-Z^_`
> > a
> > > >-z{|}`]+\.'.'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', $username)) {
> > > >$error = "You must enter a valid email address for your
> > username.";
> > > >echo "$error";
> > > >  } else {
> > > >$db = mysql_connect("localhost", "username", "password");
> > > >mysql_select_db("database",$db);
> > > >$query = "SELECT * FROM users WHERE email LIKE '".$username."'";
> > > >echo "$query";
> > > >$result = mysql_query($query,$db);
> > > >$num_rows = mysql_num_rows($result);
> > > >echo "There are $num_rows records matching $username";
> > > >//VALID PASSWORD
> > > >echo "Entered User Name:  $username";
> > > >echo "Entered Password:  $passw";
> > > >if (strlen($passw) < 6 || !preg_match('/[a-z]/i', $passw) ||
> > > >!preg_match('/[0-9]/', $passw)) {
> > > >  $error = "Invalid Password.  Must be greater than six
characters
> > > >containing at least one number.";
> > > >  echo "$error";
> > > >} else {
> > > >  //USERNAME/EMAIL ADDRESS IN DATABASE
> > > >  if (!$num_rows){
> > > >$error = "Username was not found.  Please Register.";

Re: [PHP-DB] Begining PHP...Have Questions

2004-07-19 Thread Jonathan Haddad
You want to use $_POST['username'] instead of $username everywhere you 
have a POST variable.  I believe this became the standard around PHP4.2.

Can you give us the table def and the results of that select?  Also, can 
you copy that query ( echo "$query";)  into your next reply?

I think you're query looked something like this before:
SELECT * from user where username LIKE ""?
That would select the entire table.  You could do it like this:
SELECT * from user WHERE username = '{$_POST['username']} AND password = 
'{$_POST['password']}

that will only return the row that matches both the username and 
password - so if 1 row is returned it must be the login info.  That'll 
cut down on the PHP code you need to write.

Aaron Todd wrote:
Jon,
Thanks for the info.  I did change the LIKE to =.  This was done just for my
debugging.  I do have it set to = on a normal basis.
I am a little unsure what you mean at the end of your reply about register
globals.  Are you saying that everywhere I use $username to refer to the
users inputed username I should use $_POST['username'] instead?  Or are you
suggesting to use this in one location.
Thanks again for the reply,
Aaron
"Jonathan Haddad" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
 

if you have shell access, please do the following
describe users;
select * from users;
also, why are you using LIKE instead of =?
use this instead:
$query = "SELECT * FROM users WHERE email = '".$username."'";
i would also suggest turning off register globals and using
$_POST['username'] and not $username. (i'm assuming it's on given your
   

code)
 

Jon
Aaron Todd wrote:
   

I am just starting out with PHP and I have created a simple login program
that is supposed to check users input with a mysql database.  I am doing
 

5
 

verifications before the program is completed...Check for the Submit
 

button,
 

check for a valid email address(which is the username), check for a valid
password, check to see if the username exists in the database, and
 

finally
 

check to see if the password matches the database for the coresponding
username.  Currently you dont get access to a site you only get told what
your password is in the database.
Everything is technically working, but its not perfect and I think I need
some help.  I have entered 2 records in the database for testing
 

purposes.
 

When I put in username1 and password1 it works.  The program returns the
coresponding password.  When I change to username2 and still put in
password1 it will return password1.
I have done some debuging and I am unsure of what is really happening.
 

My
 

code is below.  Would anyone be able to tell me what I am doing wrong.
Thanks,
Aaron



if ($submit) {
//VALID USERNAME/EMAIL ADDRESS
if
 

(!ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[!#$%&\'*+\\/0-9=?A-Z^_`
   

a
 

-z{|}`]+\.'.'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', $username)) {
  $error = "You must enter a valid email address for your
 

username.";
 

  echo "$error";
} else {
  $db = mysql_connect("localhost", "username", "password");
  mysql_select_db("database",$db);
  $query = "SELECT * FROM users WHERE email LIKE '".$username."'";
  echo "$query";
  $result = mysql_query($query,$db);
  $num_rows = mysql_num_rows($result);
  echo "There are $num_rows records matching $username";
  //VALID PASSWORD
  echo "Entered User Name:  $username";
  echo "Entered Password:  $passw";
  if (strlen($passw) < 6 || !preg_match('/[a-z]/i', $passw) ||
!preg_match('/[0-9]/', $passw)) {
$error = "Invalid Password.  Must be greater than six characters
containing at least one number.";
echo "$error";
  } else {
//USERNAME/EMAIL ADDRESS IN DATABASE
if (!$num_rows){
  $error = "Username was not found.  Please Register.";
  echo "$error";
  die(mysql_error());
} else {
  //ENTERED PASSWORD IN DATABASE
  if (!$passw = mysql_result($result,0,"pass")){
$error = "Invalid Password.";
echo "$error";
  } else {
printf("Password is %s\n", mysql_result($result,0,"pass"));
  }
}
  }
}
} else {
?>

User Name:
Password:



} // end if
?>



 

 

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


Re: [PHP-DB] Fwd: IMPORTANT: Please Verify Your Message

2004-07-19 Thread Justin Patrin
PLEASE look at the previous messages about this.

Yes, it's legit.
No, it's not the PHP lists sending it to you.

On Mon, 19 Jul 2004 10:24:27 -0700, Marcjon <[EMAIL PROTECTED]> wrote:
> I got this email today. Is php doing this? Is this email ligitimate?
> 
> On Mon, 19 Jul 2004 09:55:58 -0400, [EMAIL PROTECTED],
> [EMAIL PROTECTED]
> p.net said:
> 
>   Hello [EMAIL PROTECTED] ,
>   [EMAIL PROTECTED], [EMAIL PROTECTED] is currently
>   protecting themselves from receiving junk mail using
>   [1]Spamcease Just this once, click the link below so I can
>   receive your emails.
>   You won't have to do this again.
>   [2]http://www.tgpwizards.com/spamcease2/verify.php?id=69153
> 
> References
> 
> 1. http://www.spamcease.com/cart/affiliate.php?id=3
> 2. http://www.tgpwizards.com/spamcease2/verify.php?id=69153
> --
>   Marcjon
> 
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> !DSPAM:40fc0683162762080714991!
> 
> 


-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

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



Re: [PHP-DB] Begining PHP...Have Questions

2004-07-19 Thread Justin Patrin
You should generally $_POST for all posted variables, $_GET for all
"get" variables (in the query string / url), and the other
superglobals for other such things. If you don't care if it's POST,
GET, or a cookie, you can use $_REQUEST.

register_globals is a setting in your php.ini. It's best practice to
set this to "off". What this means for you is that variables sent by
the user are not registered as global variables. i.e. $username will
no longer work, you have to use $_POST['username']. Search the php
lists for lots more discussion on this matter.

For more on superglobals:
http://www.php.net/manual/en/language.variables.predefined.php
For the list archives, click the "Archive" links here:
http://www.php.net/mailing-lists.php

On Mon, 19 Jul 2004 13:27:15 -0400, Aaron Todd <[EMAIL PROTECTED]> wrote:
> Jon,
> 
> Thanks for the info.  I did change the LIKE to =.  This was done just for my
> debugging.  I do have it set to = on a normal basis.
> 
> I am a little unsure what you mean at the end of your reply about register
> globals.  Are you saying that everywhere I use $username to refer to the
> users inputed username I should use $_POST['username'] instead?  Or are you
> suggesting to use this in one location.
> 
> Thanks again for the reply,
> 
> Aaron
> 
> "Jonathan Haddad" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> 
> 
> > if you have shell access, please do the following
> >
> > describe users;
> > select * from users;
> >
> > also, why are you using LIKE instead of =?
> > use this instead:
> >
> > $query = "SELECT * FROM users WHERE email = '".$username."'";
> >
> > i would also suggest turning off register globals and using
> > $_POST['username'] and not $username. (i'm assuming it's on given your
> code)
> >
> > Jon
> >
> > Aaron Todd wrote:
> >
> > >I am just starting out with PHP and I have created a simple login program
> > >that is supposed to check users input with a mysql database.  I am doing
> 5
> > >verifications before the program is completed...Check for the Submit
> button,
> > >check for a valid email address(which is the username), check for a valid
> > >password, check to see if the username exists in the database, and
> finally
> > >check to see if the password matches the database for the coresponding
> > >username.  Currently you dont get access to a site you only get told what
> > >your password is in the database.
> > >
> > >Everything is technically working, but its not perfect and I think I need
> > >some help.  I have entered 2 records in the database for testing
> purposes.
> > >When I put in username1 and password1 it works.  The program returns the
> > >coresponding password.  When I change to username2 and still put in
> > >password1 it will return password1.
> > >
> > >I have done some debuging and I am unsure of what is really happening.
> My
> > >code is below.  Would anyone be able to tell me what I am doing wrong.
> > >
> > >Thanks,
> > >
> > >Aaron
> > >
> > >
> > >
> > > > >if ($submit) {
> > >  //VALID USERNAME/EMAIL ADDRESS
> > >  if
> >
> >(!ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[!#$%&\'*+\\/0-9=?A-Z^_`
> a
> > >-z{|}`]+\.'.'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', $username)) {
> > >$error = "You must enter a valid email address for your
> username.";
> > >echo "$error";
> > >  } else {
> > >$db = mysql_connect("localhost", "username", "password");
> > >mysql_select_db("database",$db);
> > >$query = "SELECT * FROM users WHERE email LIKE '".$username."'";
> > >echo "$query";
> > >$result = mysql_query($query,$db);
> > >$num_rows = mysql_num_rows($result);
> > >echo "There are $num_rows records matching $username";
> > >//VALID PASSWORD
> > >echo "Entered User Name:  $username";
> > >echo "Entered Password:  $passw";
> > >if (strlen($passw) < 6 || !preg_match('/[a-z]/i', $passw) ||
> > >!preg_match('/[0-9]/', $passw)) {
> > >  $error = "Invalid Password.  Must be greater than six characters
> > >containing at least one number.";
> > >  echo "$error";
> > >} else {
> > >  //USERNAME/EMAIL ADDRESS IN DATABASE
> > >  if (!$num_rows){
> > >$error = "Username was not found.  Please Register.";
> > >echo "$error";
> > >die(mysql_error());
> > >  } else {
> > >//ENTERED PASSWORD IN DATABASE
> > >if (!$passw = mysql_result($result,0,"pass")){
> > >  $error = "Invalid Password.";
> > >  echo "$error";
> > >} else {
> > >  printf("Password is %s\n", mysql_result($result,0,"pass"));
> > >}
> > >  }
> > >}
> > >  }
> > >} else {
> > >
> > >  ?>
> > >
> > >
> > >
> > >  User Name:
> > >
> > >  Password:
> > >
> > >  
> > >
> > >  
> > >
> > > > >
> > >} // end if
> > >
> > >
> > >?>
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> 
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> !DSPAM:40fc074a164631045595694!
> 
> 


-

[PHP-DB] EXPLAIN error message

2004-07-19 Thread Cristian MARIN
Hello,

Since I migrated to the PHP 4.3.7 I have a major warning problem which
appears from time to time and I cannot find the message explanation or a fix
to this issue with both old tables and new created tables.

The error message is:

[19-Jul-2004 20:00:27] PHP Warning:  mysql_query(): Your query requires a
full tablescan (table table_name, 10 rows affected). Use EXPLAIN to optimize
your query. in d:\www\teste\client120\villen.php on line 23

I thought that there is a problem with the keys so I start optimizing the
tables and the indexes but now it appears also in just created databases
with a single table and a single record manually inserted using the
phpMyAdmin.

I searched this problem on the Google and from the 550 records reported
(actually the real number is smaller) 99,99% of the messages seems to be
pages affected by this problem. The only "relevant" search result is here:
http://www.manucorp.com/archives/php-cvs/200211/msg00300.php and explain
that someone added there new functionalities into the PHP cvs back in 2002:

Added new functionality:
Warnings for table/index scans
Warnings for SQL-Errors
Warnings for non free result sets

but I don't know which is the exact issue of my tables. It appears that
after the recordset is extracted from the database a check against row[1]
(?!) which should contain the ALL string or the INDEX string is made but in
my case the check fails and I have this error.

I know that I can disable this warning through the php.ini
"mysql.trace_mode" but this is not solving the problem.

Please give me some hints to know what is happening.

-
Cristian MARIN - Developer
Support Department - (http://www.interakt.ro/products/buy_0.html#license38)
InterAKT Online (www.interakt.ro)
Tel: +4021 312.53.12
Tel/Fax:  +4021 312.51.91
[EMAIL PROTECTED]

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



Re: [PHP-DB] Begining PHP...Have Questions

2004-07-19 Thread Aaron Todd
Jon,

Thanks for the info.  I did change the LIKE to =.  This was done just for my
debugging.  I do have it set to = on a normal basis.

I am a little unsure what you mean at the end of your reply about register
globals.  Are you saying that everywhere I use $username to refer to the
users inputed username I should use $_POST['username'] instead?  Or are you
suggesting to use this in one location.

Thanks again for the reply,

Aaron


"Jonathan Haddad" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> if you have shell access, please do the following
>
> describe users;
> select * from users;
>
> also, why are you using LIKE instead of =?
> use this instead:
>
> $query = "SELECT * FROM users WHERE email = '".$username."'";
>
> i would also suggest turning off register globals and using
> $_POST['username'] and not $username. (i'm assuming it's on given your
code)
>
> Jon
>
> Aaron Todd wrote:
>
> >I am just starting out with PHP and I have created a simple login program
> >that is supposed to check users input with a mysql database.  I am doing
5
> >verifications before the program is completed...Check for the Submit
button,
> >check for a valid email address(which is the username), check for a valid
> >password, check to see if the username exists in the database, and
finally
> >check to see if the password matches the database for the coresponding
> >username.  Currently you dont get access to a site you only get told what
> >your password is in the database.
> >
> >Everything is technically working, but its not perfect and I think I need
> >some help.  I have entered 2 records in the database for testing
purposes.
> >When I put in username1 and password1 it works.  The program returns the
> >coresponding password.  When I change to username2 and still put in
> >password1 it will return password1.
> >
> >I have done some debuging and I am unsure of what is really happening.
My
> >code is below.  Would anyone be able to tell me what I am doing wrong.
> >
> >Thanks,
> >
> >Aaron
> >
> >
> >
> > >if ($submit) {
> >  //VALID USERNAME/EMAIL ADDRESS
> >  if
>
>(!ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[!#$%&\'*+\\/0-9=?A-Z^_`
a
> >-z{|}`]+\.'.'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', $username)) {
> >$error = "You must enter a valid email address for your
username.";
> >echo "$error";
> >  } else {
> >$db = mysql_connect("localhost", "username", "password");
> >mysql_select_db("database",$db);
> >$query = "SELECT * FROM users WHERE email LIKE '".$username."'";
> >echo "$query";
> >$result = mysql_query($query,$db);
> >$num_rows = mysql_num_rows($result);
> >echo "There are $num_rows records matching $username";
> >//VALID PASSWORD
> >echo "Entered User Name:  $username";
> >echo "Entered Password:  $passw";
> >if (strlen($passw) < 6 || !preg_match('/[a-z]/i', $passw) ||
> >!preg_match('/[0-9]/', $passw)) {
> >  $error = "Invalid Password.  Must be greater than six characters
> >containing at least one number.";
> >  echo "$error";
> >} else {
> >  //USERNAME/EMAIL ADDRESS IN DATABASE
> >  if (!$num_rows){
> >$error = "Username was not found.  Please Register.";
> >echo "$error";
> >die(mysql_error());
> >  } else {
> >//ENTERED PASSWORD IN DATABASE
> >if (!$passw = mysql_result($result,0,"pass")){
> >  $error = "Invalid Password.";
> >  echo "$error";
> >} else {
> >  printf("Password is %s\n", mysql_result($result,0,"pass"));
> >}
> >  }
> >}
> >  }
> >} else {
> >
> >  ?>
> >
> >
> >
> >  User Name:
> >
> >  Password:
> >
> >  
> >
> >  
> >
> > >
> >} // end if
> >
> >
> >?>
> >
> >
> >
> >
> >
> >
> >

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



[PHP-DB] Fwd: IMPORTANT: Please Verify Your Message

2004-07-19 Thread Marcjon
I got this email today. Is php doing this? Is this email ligitimate?

On Mon, 19 Jul 2004 09:55:58 -0400, [EMAIL PROTECTED],
[EMAIL PROTECTED]
p.net said:

  Hello [EMAIL PROTECTED] ,
  [EMAIL PROTECTED], [EMAIL PROTECTED] is currently
  protecting themselves from receiving junk mail using
  [1]Spamcease Just this once, click the link below so I can
  receive your emails.
  You won't have to do this again.
  [2]http://www.tgpwizards.com/spamcease2/verify.php?id=69153

References

1. http://www.spamcease.com/cart/affiliate.php?id=3
2. http://www.tgpwizards.com/spamcease2/verify.php?id=69153
-- 
  Marcjon

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



Re: [PHP-DB] Begining PHP...Have Questions

2004-07-19 Thread Jonathan Haddad
if you have shell access, please do the following
describe users;
select * from users;
also, why are you using LIKE instead of =?
use this instead:
$query = "SELECT * FROM users WHERE email = '".$username."'";
i would also suggest turning off register globals and using 
$_POST['username'] and not $username. (i'm assuming it's on given your code)

Jon
Aaron Todd wrote:
I am just starting out with PHP and I have created a simple login program
that is supposed to check users input with a mysql database.  I am doing 5
verifications before the program is completed...Check for the Submit button,
check for a valid email address(which is the username), check for a valid
password, check to see if the username exists in the database, and finally
check to see if the password matches the database for the coresponding
username.  Currently you dont get access to a site you only get told what
your password is in the database.
Everything is technically working, but its not perfect and I think I need
some help.  I have entered 2 records in the database for testing purposes.
When I put in username1 and password1 it works.  The program returns the
coresponding password.  When I change to username2 and still put in
password1 it will return password1.
I have done some debuging and I am unsure of what is really happening.  My
code is below.  Would anyone be able to tell me what I am doing wrong.
Thanks,
Aaron


";
   echo "$error";
 } else {
   $db = mysql_connect("localhost", "username", "password");
   mysql_select_db("database",$db);
   $query = "SELECT * FROM users WHERE email LIKE '".$username."'";
   echo "$query";
   $result = mysql_query($query,$db);
   $num_rows = mysql_num_rows($result);
   echo "There are $num_rows records matching $username";
   //VALID PASSWORD
   echo "Entered User Name:  $username";
   echo "Entered Password:  $passw";
   if (strlen($passw) < 6 || !preg_match('/[a-z]/i', $passw) ||
!preg_match('/[0-9]/', $passw)) {
 $error = "Invalid Password.  Must be greater than six characters
containing at least one number.";
 echo "$error";
   } else {
 //USERNAME/EMAIL ADDRESS IN DATABASE
 if (!$num_rows){
   $error = "Username was not found.  Please Register.";
   echo "$error";
   die(mysql_error());
 } else {
   //ENTERED PASSWORD IN DATABASE
   if (!$passw = mysql_result($result,0,"pass")){
 $error = "Invalid Password.";
 echo "$error";
   } else {
 printf("Password is %s\n", mysql_result($result,0,"pass"));
   }
 }
   }
 }
} else {
 ?>

 User Name:
 Password:
 
 

} // end if
?>


 

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


[PHP-DB] Begining PHP...Have Questions

2004-07-19 Thread Aaron Todd
I am just starting out with PHP and I have created a simple login program
that is supposed to check users input with a mysql database.  I am doing 5
verifications before the program is completed...Check for the Submit button,
check for a valid email address(which is the username), check for a valid
password, check to see if the username exists in the database, and finally
check to see if the password matches the database for the coresponding
username.  Currently you dont get access to a site you only get told what
your password is in the database.

Everything is technically working, but its not perfect and I think I need
some help.  I have entered 2 records in the database for testing purposes.
When I put in username1 and password1 it works.  The program returns the
coresponding password.  When I change to username2 and still put in
password1 it will return password1.

I have done some debuging and I am unsure of what is really happening.  My
code is below.  Would anyone be able to tell me what I am doing wrong.

Thanks,

Aaron



";
echo "$error";
  } else {
$db = mysql_connect("localhost", "username", "password");
mysql_select_db("database",$db);
$query = "SELECT * FROM users WHERE email LIKE '".$username."'";
echo "$query";
$result = mysql_query($query,$db);
$num_rows = mysql_num_rows($result);
echo "There are $num_rows records matching $username";
//VALID PASSWORD
echo "Entered User Name:  $username";
echo "Entered Password:  $passw";
if (strlen($passw) < 6 || !preg_match('/[a-z]/i', $passw) ||
!preg_match('/[0-9]/', $passw)) {
  $error = "Invalid Password.  Must be greater than six characters
containing at least one number.";
  echo "$error";
} else {
  //USERNAME/EMAIL ADDRESS IN DATABASE
  if (!$num_rows){
$error = "Username was not found.  Please Register.";
echo "$error";
die(mysql_error());
  } else {
//ENTERED PASSWORD IN DATABASE
if (!$passw = mysql_result($result,0,"pass")){
  $error = "Invalid Password.";
  echo "$error";
} else {
  printf("Password is %s\n", mysql_result($result,0,"pass"));
}
  }
}
  }
} else {

  ?>



  User Name:

  Password:

  

  







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



Re: [PHP-DB] Re: REG_BADRPT error

2004-07-19 Thread Aaron Todd
Thanks for the help.  Being new to PHP I was unaware that I could use some
perl compatible regexes here.  That will help me out a lot.

Thanks again,

Aaron


"Justin Patrin" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> In this case, it seems like you're looking for a lot of different and
> exclusive things at once. I would suggest not using a huge regex as
> they can be hard to create, harder to read, and impossible to
> maintain. That said, I do use regexes in some of my code, just not for
> something this simple. ;-) I generally use Perl Compatible Regexes as
> I understand them better. Try:
>
> if(strlen($pass) < 6 || !preg_match('/[a-z]/i', $pass) ||
> !preg_match('/[0-9]/', $pass)) {
>   //bad password
> }
>
> On Mon, 19 Jul 2004 11:10:47 -0400, Aaron Todd <[EMAIL PROTECTED]>
wrote:
> > Hello,
> >
> > Ive been trying a few things and finally I did get rid of the error.  I
> > changed the code to:
> > if (!ereg('^(!?=.*[0-9]+.*)(!?=.*[a-zA-Z]+.*)[0-9a-zA-Z]{6,}$',
$pass)){
> > Notice the ! before the two ?
> >
> > This got rid of the error, but it still isnt working the way I want it
to.
> > That line should validate the variable $pass, which should be greater
than 6
> > characters and contain at least one numbers and one letter.  That line
> > should be true if $pass does not equil 6 characters and contain at least
one
> > numbers and one letter.
> >
> > Can someone correct me on this.  I am new to PHP so I am still trying to
get
> > the hang of it.
> >
> > Any help will be appreciated.
> >
> > Thanks,
> >
> > Aaron
> >
> > "Aaron Todd" <[EMAIL PROTECTED]> wrote in message
> > news:[EMAIL PROTECTED]
> >
> >
> > > Hello,
> > >
> > > I am getting an REG_BADRPT error when I use ereg.
> > >
> > > The line of code that errors is:
> > > if (!ereg('^(?=.*[0-9]+.*)(?=.*[a-zA-Z]+.*)[0-9a-zA-Z]{8,}$',
$pass)){
> > >
> > > I got this regex from regexlib.com and tried to impliment it, but no
> > matter
> > > what I do it always returns the error.  I did a google search and the
only
> > > suggestion I found was to make sure that the variable contains data.
So I
> > > echoed the variable and it did have data in it.  Does anyone know why
I
> > > might be getting this?
> > >
> > > Thanks,
> > >
> > > Aaron
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> > !DSPAM:40fbe26957361384218867!
> >
> >
>
>
> -- 
> DB_DataObject_FormBuilder - The database at your fingertips
> http://pear.php.net/package/DB_DataObject_FormBuilder
>
> paperCrane --Justin Patrin--

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



Re: [PHP-DB] Re: REG_BADRPT error

2004-07-19 Thread Justin Patrin
In this case, it seems like you're looking for a lot of different and
exclusive things at once. I would suggest not using a huge regex as
they can be hard to create, harder to read, and impossible to
maintain. That said, I do use regexes in some of my code, just not for
something this simple. ;-) I generally use Perl Compatible Regexes as
I understand them better. Try:

if(strlen($pass) < 6 || !preg_match('/[a-z]/i', $pass) ||
!preg_match('/[0-9]/', $pass)) {
  //bad password
}

On Mon, 19 Jul 2004 11:10:47 -0400, Aaron Todd <[EMAIL PROTECTED]> wrote:
> Hello,
> 
> Ive been trying a few things and finally I did get rid of the error.  I
> changed the code to:
> if (!ereg('^(!?=.*[0-9]+.*)(!?=.*[a-zA-Z]+.*)[0-9a-zA-Z]{6,}$', $pass)){
> Notice the ! before the two ?
> 
> This got rid of the error, but it still isnt working the way I want it to.
> That line should validate the variable $pass, which should be greater than 6
> characters and contain at least one numbers and one letter.  That line
> should be true if $pass does not equil 6 characters and contain at least one
> numbers and one letter.
> 
> Can someone correct me on this.  I am new to PHP so I am still trying to get
> the hang of it.
> 
> Any help will be appreciated.
> 
> Thanks,
> 
> Aaron
> 
> "Aaron Todd" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> 
> 
> > Hello,
> >
> > I am getting an REG_BADRPT error when I use ereg.
> >
> > The line of code that errors is:
> > if (!ereg('^(?=.*[0-9]+.*)(?=.*[a-zA-Z]+.*)[0-9a-zA-Z]{8,}$', $pass)){
> >
> > I got this regex from regexlib.com and tried to impliment it, but no
> matter
> > what I do it always returns the error.  I did a google search and the only
> > suggestion I found was to make sure that the variable contains data.  So I
> > echoed the variable and it did have data in it.  Does anyone know why I
> > might be getting this?
> >
> > Thanks,
> >
> > Aaron
> 
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> !DSPAM:40fbe26957361384218867!
> 
> 


-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

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



[PHP-DB] Re: REG_BADRPT error

2004-07-19 Thread Aaron Todd
Hello,

Ive been trying a few things and finally I did get rid of the error.  I
changed the code to:
if (!ereg('^(!?=.*[0-9]+.*)(!?=.*[a-zA-Z]+.*)[0-9a-zA-Z]{6,}$', $pass)){
Notice the ! before the two ?

This got rid of the error, but it still isnt working the way I want it to.
That line should validate the variable $pass, which should be greater than 6
characters and contain at least one numbers and one letter.  That line
should be true if $pass does not equil 6 characters and contain at least one
numbers and one letter.

Can someone correct me on this.  I am new to PHP so I am still trying to get
the hang of it.

Any help will be appreciated.

Thanks,

Aaron


"Aaron Todd" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hello,
>
> I am getting an REG_BADRPT error when I use ereg.
>
> The line of code that errors is:
> if (!ereg('^(?=.*[0-9]+.*)(?=.*[a-zA-Z]+.*)[0-9a-zA-Z]{8,}$', $pass)){
>
> I got this regex from regexlib.com and tried to impliment it, but no
matter
> what I do it always returns the error.  I did a google search and the only
> suggestion I found was to make sure that the variable contains data.  So I
> echoed the variable and it did have data in it.  Does anyone know why I
> might be getting this?
>
> Thanks,
>
> Aaron

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



Re: [PHP-DB] Bogus List Messages

2004-07-19 Thread Justin Patrin
On Mon, 19 Jul 2004 07:47:38 -0700, Cole S. Ashcraft
<[EMAIL PROTECTED]> wrote:
> Are the messages with the subject line IMPORTANT: Please Verify Your
> Message bogus? They do not come from the ezmlm mailer at lists.php.net.
> 
> They do not have the [PHP-DB] prefix. Have the owners of the list
> requested this?
> 

No, this is not a feature of the PHP lists. However, these messages
are not bogus. They're from a service that one of the subscribers is
using to stop spam. Just click the link and they'll go away.

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

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



[PHP-DB] Bogus List Messages

2004-07-19 Thread Cole S. Ashcraft
Are the messages with the subject line IMPORTANT: Please Verify Your 
Message bogus? They do not come from the ezmlm mailer at lists.php.net.

They do not have the [PHP-DB] prefix. Have the owners of the list 
requested this?

Cole
--
This message has been scanned for viruses and
dangerous content by MailScanner on mail.ashcraftfamily.net, and is believed
to be clean.
Please report any deviance from this condition immediately to the AFN
Administrator at [EMAIL PROTECTED]
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] REG_BADRPT error

2004-07-19 Thread Aaron Todd
Hello,

I am getting an REG_BADRPT error when I use ereg.

The line of code that errors is:
if (!ereg('^(?=.*[0-9]+.*)(?=.*[a-zA-Z]+.*)[0-9a-zA-Z]{8,}$', $pass)){

I got this regex from regexlib.com and tried to impliment it, but no matter
what I do it always returns the error.  I did a google search and the only
suggestion I found was to make sure that the variable contains data.  So I
echoed the variable and it did have data in it.  Does anyone know why I
might be getting this?

Thanks,

Aaron

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



Re: [PHP-DB] Re: PHP Max execution time

2004-07-19 Thread Lisi
To be honest, I'm not sure. I didn't write the script or the database, they 
were written by the guy who worked there before me. I think the solution 
presented to increase max time will work but if the "hang time" becomes too 
great I will look into this suggestion.

Thanks!
-Lisi
At 09:50 AM 7/15/04 -0400, Peter Westergaard wrote:
"Lisi" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I am running a script (called through a browser) that checks entries in a
> table one at a time. As the table has grown, the script takes longer to
run
> than is allowed - 30 seconds.
Of course, I have to ask... is there absolutely no way to optimize your
table so as to use an index or two, or to add a few extra columns to handle
requisite calculations so that you don't need to process each row every
time?
-P
--
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] php, javascript and db - your help is needed

2004-07-19 Thread Nilo César Teixeira
Hi Cohen,

It´s really trivial. You show put a block that tests if a student is
selected, like

0) { ?>
DO SOME STUFF


/* And add this simple feature to select the student passed as parameter */
/* Assuming that the select is inside a form named 'f' */
function selectOption(selectName, value) {
  var s =  document.f.elements[selectName];
  var found = false;
  for (var i=0; i);


- Original Message - 
From: "G. Cohen" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, July 18, 2004 1:30 PM
Subject: [PHP-DB] php, javascript and db - your help is needed


> Hello,
>
> I have a HTML form with 2 select boxes, lets say students and courses.
When
> the from loads for the first time, I fill the students select box with
data
> from database. The courses selectbox remains empty.
> When the user selects a value from the students selectbox (onchange
event),
> I should go to the db to reterive the courses for the selected student and
> fill the courses selectbaox. I found it very complicated to do the
> interaction between javascript and php: apparently, I have to submit the
> from for the selected student id to be passed as a parameter to php (so
that
> php can access the db with the student id and retrieve his courses), and
at
> the same time I want the form to stay with the list of students, and the
> selected student. This should not be that hard, should it?! this is
> something trivial, I hope?
> I also tried using cookies, with no success.
> If someone knows how to do that, please let me know.
>
> Best Regards,
> G. Cohen
>
> -- 
> 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: Reducing Strings to a certain length

2004-07-19 Thread Amit Arora
You can use the 'substr' function
$reduced_string = substr($str, 0, 60);
More info available at http://www.php.net/substr
Amit Arora
http://www.digitalamit.com
Cole Ashcraft wrote:
How would you reduce a string to a specified length? Say reduce 600 to
60 or abc to ab? Is there a PHP function for this? Will I have to write
my own code?
Cole

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


[PHP-DB] Re: writing to 2 tables

2004-07-19 Thread David Robley
On Mon, 19 Jul 2004 18:33, Phpdiscuss - Php Newsgroups And Mailing Lists
wrote:

> Hi all,
> 
> I am writing a PHP newsletter where users are able to write the news and
> for the information to be written to 2 tables in the database. I can do
> this for one table but it need it for 2.
> 
> Obviously what needs to happen if that the two ids from t1 and t2 be
> linked together but how do i get the code to tell it to write to both
> tables using the same id??
> 
> Does anyone know how this would be done?
> 
> All comments appreciated!
> =)

If your table t1 has an autoincrement field, insert to that table, use
mysql_insert_id to get the id from that insert and use it in your insert to
t2.

-- 
David Robley

"There it is again!" Tom recited.

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



[PHP-DB] writing to 2 tables

2004-07-19 Thread PHPDiscuss - PHP Newsgroups and mailing lists
Hi all,

I am writing a PHP newsletter where users are able to write the news and
for the information to be written to 2 tables in the database. I can do
this for one table but it need it for 2.

Obviously what needs to happen if that the two ids from t1 and t2 be
linked together but how do i get the code to tell it to write to both
tables using the same id??

Does anyone know how this would be done? 

All comments appreciated!
=)

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



Re: [PHP-DB] RE: [SPAM] Re: [PHP-DB] DB table creation question

2004-07-19 Thread Matthew McNicol
at the moment if a value is say inserted into the 'warranty_info' table 
you are just checking that the 'product_id' or 'cust_id' already exists 
in 'product_info' and 'customer_info'. you still have to populate them 
first, otherwise the referential integrity will return an error when you 
insert into 'warranty_info'.

similarly if you delete a record from 'warranty_info' you might actually 
delete the associated customer record. is this what you want?

at the moment it looks like the 'rma_info' table is not linked to any 
other table?

personally, I would not go so far as to specify 'FOREIGN KEY ... 
REFERENCES' or 'ON UPDATE CASCADE ON DELETE RESTRICT' in the create 
table code. I would use the application code to make sure a customer 
exists before referencing them in the 'product_info' or 'warranty_info' 
tables. similarly I would use the application code to delete table 
record out of each appropriate table.

I would use the primary and secondary index assuming you are working 
with more than 100 records in each table.



Vincent Jordan wrote:
Does this seem to be correct? With this if value was inserted into a
table will the tables with the FK's automatically be updated? Here is
the DB design as I have it now. Let me know if all is correct please.
CREATE TABLE customer_info (
   cust_id int (6) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
   first_name varchar (50) NOT NULL,
   last_name varchar (50) NOT NULL,
   address varchar (50) NOT NULL,
   address2 varchar (50) NULL,
   city varchar (50) NOT NULL,
   state varchar (50) NOT NULL,
   zip varchar (50) NOT NULL,
   home_phone varchar (15) NOT NULL,
   work_phone varchar (15) NULL,
   other_phone varchar (15) NULL,
   email varchar (50) NOT NULL,
   );
CREATE TABLE product_info (
   product_id int (6) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
   cust_id int (6) NOT NULL,
   model varchar (50) NOT NULL,
   serial varchar (20) NULL,
   FOREIGN KEY (customer_info_cust_id),
REFERENCES customer_info(cust_id),
   ON UPDATE CASCADE ON DELETE RESTRICT,
   INDEX (cust_id),
   FOREIGN KEY (cust_id),
   REFERENCES customer_info(cust_id),
   );
CREATE TABLE warranty_info (
   warranty_id int (6) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
   product_id int (6) NOT NULL,
   cust_id (6) NOT NULL,
   mfg_warranty tinyint (1) NOT NULL default '1',
   gold_warranty tinyint (1) NOT NULL default '0',
   gold_warranty_id int (16) NULL,
   FOREIGN KEY (customer_info_cust_id),
REFERENCES customer_info(cust_id),
   ON UPDATE CASCADE ON DELETE RESTRICT,
   INDEX (cust_id),
   FOREIGN KEY (cust_id),
   REFERENCES customer_info(cust_id),
   FOREIGN KEY (product_info_product_id),
REFRENCES product_info(product_id),
   ON UPDATE CASCADE ON DELETE RESTRICT,
   INDEX (product_id),
   FOREIGN KEY (prod_id),
REFRENCES product_info (product_id),
   );
CREATE TABLE rma_info (
   rma_id int (6) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
   assigned_to varchar (50) NULL,
   logged_by varchar (50) NULL,
   date datetime NOT NULL,
   time_spent datetime (6) NULL,
   status varchar (50) NOT NULL,
   priority varchar (50) NULL,
   closed_by varchar (50) NULL,
   completed_by varchar (50) NULL,
   date_closed datetime (6) NULL,
   billable tinyint(1)NULL,
   billed tinyint (1) NULL,
   cost varchar (6) NULL,
   last_modified_by varchar (50) NULL,
   last_modified_date datetime NULL,
   );
  

-Original Message-
From: Matthew McNicol [mailto:[EMAIL PROTECTED] 
Sent: Sunday, July 18, 2004 5:46 PM
To: Vincent Jordan
Cc: [EMAIL PROTECTED]
Subject: [SPAM] Re: [PHP-DB] DB table creation question

use the mysql 'auto increment' on a 'int' 'customer_id' field to 
generate a unique customer id.

the RMA number is associated with a 'customer_id' since the 
'customer_id' field is in both the customers table and the RMA table. 
Note that currently you have 'custid' and 'Customerid' respectively 
which you should change so that they are uniform (it helps with database

maintenance is foreign keys are spelt the same as the primary key 
equivalent).

to assign a product to a customer, first create a products table which 
defines each product. each product would have a unique 'product_id'. 
second, create a table which will link the products (zero, one or more) 
a customer has selected to the 'rma_id'. such tables would have the 
following structure:

table: product
product_id
product_desc
...
table: rma_product
rma_id
product_id
table: customer
customer_id
firstname
lastname
...
table: rma
rma_id
assignedto
loggedby
customer_id
...
Do you follow? Do you understand in what order you should populate the 
tables and how you can now create SQL queries to get the information you

need?

Vincent Jordan wrote:
I am creating a database to keep t