Re: [PHP-DB] MySQL Error 1366

2007-05-28 Thread Chetanji

Chetanji says,

This may be a typo of yours.
Look at the header...
 
CREATE TABLE `sometableo`

The 'o' is added by mistake?
Blessings,
Chetanji



elk dolk wrote:
 
Hi All,
 
I want to load data from dump file to MySQL table using LOAD DATA INFILE 
but there is Error 1366 :
 
mysql LOAD DATA
- INFILE 'D:/SITE/SOMETABLE.SQL'
- INTO TABLE SOMETABLE
- FIELDS TERMINATED BY ','
- OPTIONALLY ENCLOSED BY ''
- LINES TERMINATED BY ')';
ERROR 1366 (HY000): Incorrect integer value:  '--MySQL dump 10.10
--
--S' for column 'ID' at row 1
 
 
 
this is the header of my dump file:
 
 
DROP TABLE IF EXISTS `sometable`;
CREATE TABLE `sometableo` (
  `ID` smallint(6) NOT NULL auto_increment,
  `Name` varchar(30) NOT NULL,
  `title` tinytext,
  `description` tinytext,
  `cat` tinytext,
  PRIMARY KEY  (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
 
LOCK TABLES `sometable` WRITE;
/*!4 ALTER TABLE `sometable` DISABLE KEYS */;
INSERT INTO `sometable` VALUES
(79,'110_1099','AAA','AA','AAA'),(80,'110_1100','AAA','DFGDFGF','AAA'),
 
 
 
 
any idea for  solving the problem?
 
 

-
Sick sense of humor? Visit Yahoo! TV's Comedy with an Edge to see what's
on, when. 


-- 
View this message in context: 
http://www.nabble.com/MySQL-Error-1366-tf3830472.html#a10846547
Sent from the Php - Database mailing list archive at Nabble.com.

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



[PHP-DB] $_POST[mypassword]; ***Undefined index: mypassword

2007-05-14 Thread Chetanji

To All a Welcome,

All the errors are gone but this nagging one.  I am running a login script
and getting this error...

To bring the username and password into the processing script I am doing it
this way, and having trouble.
I have spent too many hours working on this one issue.  Please help someone.
Blessings, Chetan

$myusername=$_POST[myusername];
$mypassword=$_POST[mypassword];

::
Notice: Undefined index: myusername in
C:\Inetpub\wwwroot\AimsSite\docproedit\checklogin.php on line 12

Notice: Undefined index: mypassword in
C:\Inetpub\wwwroot\AimsSite\docproedit\checklogin.php on line 13
::
The login script is simple HTML using. 

form name=Flogin.html method=post action=login.php
input name=myusername type=text 
input name=mypassword type=password 
input type=button value=submit 

Note: Flogin.html is name of Login page script; login.php is name of script
below, processing the pass and user.

Here is the Code...

?php
ob_start();session_start();
/
*Function Login.php Begin End  
/
/**
** Process username 1st by md5, then Encrypt,
** then compare with appropiate password in DB. 
**/
//Basic connecting $vars
session_register(myusername); session_register(mypassword);
$db_name='aims site'; $tbl_name='docproedit'; $db_server='localhost';
$db_user='root';
$db_pass='somepass';$myusername=$_POST[myusername];$mypassword=$_POST[mypassword];
$auth = false;
//Encrypting begins for username and password
//entered by the user on login page.
$uname=$myusername;
$pname=$mypassword;
hashinput($uname,$pname);
//The hash function, which includes the encrypt function.
function hashinput($uname,$pname){
global $user; global $pass; global $uname; global $pname; global $p;
$usrname=md5($uname);
$passname=md5($pname);
if (!isset ($_POST['myusername']) ||($_POST['myusername'] !='myusername'))
{}else{} 
//the Encrypt function.
function Encrypt($string) {$Encryption = crypt(md5($string),
md5($string));return $Encryption;} 
$user = encrypt($usrname);
$p = encrypt($passname);
}
//Connecting with DB, selecting array from DB to analyze.
$linkID = mysql_connect($db_server, $db_user, $db_pass);
mysql_select_db($db_name, $linkID);
$result = mysql_query(SELECT password FROM docproedit WHERE username =
'$user', $linkID);
$pass = mysql_fetch_row($result);
mysql_close($linkID);
//Based on the comparision of encryped login username
//against the permanent DB password, $auth is 1 if 'good' login, and 0
if 'bad'.
if ($pass[0] === $p) {
$auth = true;
if ($auth = 1) { 
echo meta http-equiv=\Refresh\
content=\0;url=http://localhost/aimssite/docproedit/welcome.html\;;
return;
}
}
return $auth;

ob_end_flush();
/
*Function Loginphp End***  
/


-- 
View this message in context: 
http://www.nabble.com/PHP-to-md5-the-%24var-before-it-reaches-MySQL%27s-gen-query-log-tf3731340.html#a10599058
Sent from the Php - Database mailing list archive at Nabble.com.

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



Re: [PHP-DB] $_POST[mypassword]; ***Undefined index: mypassword

2007-05-14 Thread Chetanji

I corrected a small spelling error to make the situation more understandable. 
Everything is the same I am stuck!
Thanks in Advance, Chetanji

Chetanji wrote:
 
 
 
 All the errors are gone but this nagging one.  I am running a login script
 and getting this error...
 
 To bring the username and password into the processing script I am doing
 it this way, and having trouble.
 I have spent too many hours working on this one issue.  Please help
 someone.
 Blessings, Chetan
 
 $myusername=$_POST[myusername];
 $mypassword=$_POST[mypassword];
 
 ::
 Notice: Undefined index: myusername in
 C:\Inetpub\wwwroot\AimsSite\docproedit\login.php on line 13
 
 Notice: Undefined index: mypassword in
 C:\Inetpub\wwwroot\AimsSite\docproedit\login.php on line 13
 ::
 The login script is simple HTML using. 
 
 form name=Flogin.html method=post action=login.php
 input name=myusername type=text 
 input name=mypassword type=password 
 input type=button value=submit 
 
 Note: Flogin.html is where you log on; login.php, the script below,
 processes the password and username.
 
 Here is the Code...
 
 ?php
 ob_start();session_start();
 /
 *Login.php Begin End  
 /
 /**
 ** Process username 1st by md5, then Encrypt,
 ** then compare with appropiate password in DB. 
 **/
 
 session_register(myusername); session_register(mypassword);
 $db_name='aims site'; $tbl_name='docproedit'; $db_server='localhost';
 $db_user='root';
 $db_pass='somepass';$myusername=$_POST[myusername];$mypassword=$_POST[mypassword];
 $auth = false;
 
 //Encrypting begins for username and password
 //entered by the user on login page.
 $uname=$myusername;
 $pname=$mypassword;
 hashinput($uname,$pname);
 
 //The hash function, which includes the encrypt function.
 function hashinput($uname,$pname){
 global $user; global $pass; global $uname; global $pname; global $p;
 $usrname=md5($uname);
 $passname=md5($pname);
 
 //the Encrypt function.
 function Encrypt($string) {$Encryption = crypt(md5($string),
 md5($string));return $Encryption;} 
 $user = encrypt($usrname);
 $p = encrypt($passname);
 }
 
 //Connecting with DB, selecting array from DB to analyze.
 $linkID = mysql_connect($db_server, $db_user, $db_pass);
 mysql_select_db($db_name, $linkID);
 $result = mysql_query(SELECT password FROM docproedit WHERE username =
 '$user', $linkID);
 $pass = mysql_fetch_row($result);
 mysql_close($linkID);
 
 //Based on the comparision of encryped login username
 //against the permanent DB password, $auth is 1 if 'good' login, and 0
 if 'bad'.
 if ($pass[0] === $p) {
 $auth = true;
 if ($auth = 1) { 
 echo meta http-equiv=\Refresh\
 content=\0;url=http://localhost/aimssite/docproedit/welcome.html\;;
 return;
 }
 }
 return $auth;
 
 ob_end_flush();
 
 /
 *Function Loginphp End***  
 /
 
 
 

-- 
View this message in context: 
http://www.nabble.com/PHP-to-md5-the-%24var-before-it-reaches-MySQL%27s-gen-query-log-tf3731340.html#a10602633
Sent from the Php - Database mailing list archive at Nabble.com.

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



Re: [PHP-DB] $_POST[mypassword]; ***Undefined index: mypassword

2007-05-14 Thread Chetanji

Thanks for the reply,  this is the only output before and after the
$_POST

  array(0) { } ..that's it

I still have the two Notice's from PHP.
But the program works otherwise, in checking the DB for the hashed
password...
that matches the typed in username ...
that is then hashed itself
in the login.php program.  
It works and doesn't 'auth' for incorrect user/pass combinations.
However, I do not like running programs that kick out 'errors' of any kind.  
It seems to always lead to unpredictable situations that are a problem.
Any other ideas?
Thanks,
Chetanji



Chetanji wrote:
 
 I corrected a small spelling error to make the situation more
 understandable.  Everything is the same I am stuck!
 Thanks in Advance, Chetanji
 
 Chetanji wrote:
 
 
 
 All the errors are gone but this nagging one.  I am running a login
 script and getting this error...
 
 To bring the username and password into the processing script I am doing
 it this way, and having trouble.
 I have spent too many hours working on this one issue.  Please help
 someone.
 Blessings, Chetan
 
 $myusername=$_POST[myusername];
 $mypassword=$_POST[mypassword];
 
 ::
 Notice: Undefined index: myusername in
 C:\Inetpub\wwwroot\AimsSite\docproedit\login.php on line 13
 
 Notice: Undefined index: mypassword in
 C:\Inetpub\wwwroot\AimsSite\docproedit\login.php on line 13
 ::
 The login script is simple HTML using. 
 
 
 
 
 
 
 Note: Flogin.html is where you log on; login.php, the script below,
 processes the password and username.
 
 Here is the Code...
 
 ?php
 ob_start();session_start();
 /
 *Login.php Begin End  
 /
 /**
 ** Process username 1st by md5, then Encrypt,
 ** then compare with appropiate password in DB. 
 **/
 
 session_register(myusername); session_register(mypassword);
 $db_name='aims site'; $tbl_name='docproedit'; $db_server='localhost';
 $db_user='root';
 $db_pass='somepass';$myusername=$_POST[myusername];$mypassword=$_POST[mypassword];
 $auth = false;
 
 //Encrypting begins for username and password
 //entered by the user on login page.
 $uname=$myusername;
 $pname=$mypassword;
 hashinput($uname,$pname);
 
 //The hash function, which includes the encrypt function.
 function hashinput($uname,$pname){
 global $user; global $pass; global $uname; global $pname; global $p;
 $usrname=md5($uname);
 $passname=md5($pname);
 
 //the Encrypt function.
 function Encrypt($string) {$Encryption = crypt(md5($string),
 md5($string));return $Encryption;} 
 $user = encrypt($usrname);
 $p = encrypt($passname);
 }
 
 //Connecting with DB, selecting array from DB to analyze.
 $linkID = mysql_connect($db_server, $db_user, $db_pass);
 mysql_select_db($db_name, $linkID);
 $result = mysql_query(SELECT password FROM docproedit WHERE username =
 '$user', $linkID);
 $pass = mysql_fetch_row($result);
 mysql_close($linkID);
 
 //Based on the comparision of encryped login username
 //against the permanent DB password, $auth is 1 if 'good' login, and
 0 if 'bad'.
 if ($pass[0] === $p) {
 $auth = true;
 if ($auth = 1) { 
 echo ; return;
 }
 }
 return $auth;
 
 ob_end_flush();
 
 /
 *Login.php End***  
 /
 
 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/PHP-to-md5-the-%24var-before-it-reaches-MySQL%27s-gen-query-log-tf3731340.html#a10606352
Sent from the Php - Database mailing list archive at Nabble.com.


Re: [PHP-DB] $_POST[mypassword]; ***Undefined index: mypassword

2007-05-14 Thread Chetanji

Well, well, I just logged on to test the crypt output by typing in wrong
username/password pairs and got this output from the var_dump($_POST);
incorrect
username/password pair;;;
array(3) { [myusername]=  string(8) asdfasdf [mypassword]= 
string(6) hjklhj [Submit]=  string(5) Login }
array(3) { [myusername]=  string(8) asdfasdf [mypassword]= 
string(6) hjklhj [Submit]=  string(5) Login }
;;;

correct
username/password pair
array(3) { [myusername]=  string(6) amrita [mypassword]=  string(4)
tech [Submit]=  string(5) Login} 
array(3) { [myusername]=  string(6) amrita [mypassword]=  string(4)
tech [Submit]=  string(5) Login}

This gives me hard evidence that the $_POST array is working just fine, but
what is it??? that is not seeing that mypassword' and myusername are
defined?
So what does this tell you?
Thanks,
Chetanji





Dimiter Ivanov wrote:
 
 On 5/14/07, Chetanji [EMAIL PROTECTED] wrote:

 I corrected a small spelling error to make the situation more
 understandable.
 Everything is the same I am stuck!
 Thanks in Advance, Chetanji

 Chetanji wrote:
 
 
 
  All the errors are gone but this nagging one.  I am running a login
 script
  and getting this error...
 
  To bring the username and password into the processing script I am
 doing
  it this way, and having trouble.
  I have spent too many hours working on this one issue.  Please help
  someone.
  Blessings, Chetan
 
  $myusername=$_POST[myusername];
  $mypassword=$_POST[mypassword];
 
 
 ::
  Notice: Undefined index: myusername in
  C:\Inetpub\wwwroot\AimsSite\docproedit\login.php on line 13
 
  Notice: Undefined index: mypassword in
  C:\Inetpub\wwwroot\AimsSite\docproedit\login.php on line 13
 
 
 Those messages mean that the variables $_POST[myusername] and
 $_POST[mypassword]; are not set.
 Try dumping the $_POST array var_dump($_POST); , to see what is in
 there, before you assign the values to $mypassword and $myusername.
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 

-- 
View this message in context: 
http://www.nabble.com/PHP-to-md5-the-%24var-before-it-reaches-MySQL%27s-gen-query-log-tf3731340.html#a10606727
Sent from the Php - Database mailing list archive at Nabble.com.

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



Re: [PHP-DB] $_POST[mypassword]; ***Undefined index: mypassword

2007-05-14 Thread Chetanji

Okay, now with the isset and var_dump in place within the login.php script, 
I get the output of what I typed into the Log On page.
All this output is 'premeal' for the login.php script.

So then the PHP Notice's are just something to know the PHP parser is 
seeing a empty, undescriptive container and is throwing a hey, look at this
it may not be normal when the login.php script is run by itself in the
browser.  You are thinking its not a problem and will not lead to any
problems.  If this is the case then thankyou Dimiter.
Blessings,
Chetanji


;;;
array(3) { [myusername]=  string(2) my [mypassword]=  string(4)
amma [Submit]=  string(5) Login }
array(3) { [myusername]=  string(2) my [mypassword]=  string(4)
amma [Submit]=  string(5) Login }
;;;




Dimiter Ivanov wrote:
 
 Well then the $_POST array is empty that's why you have those notices.
 The $_POST array is populated with values ONLY after the form was
 submitted to the login.php script.
 If you use this script before the form was submitted or in any other
 context, then you will get those notices.
 
 If you check if the variables you are looking for are set, before
 assigning them, you will not get the notices.
 
 Try this:
 if(isset($_POST[myusername]) AND isset($_POST[mypassword])){
  $myusername=$_POST[myusername];
  $mypassword=$_POST[mypassword];
 }
 
 On 5/14/07, Chetanji [EMAIL PROTECTED] wrote:

 Thanks for the reply,  this is the only output before and after the
 $_POST

   array(0) { } ..that's it

 I still have the two Notice's from PHP.
 But the program works otherwise, in checking the DB for the hashed
 password...
 that matches the typed in username ...
 that is then hashed itself
 in the login.php program.
 It works and doesn't 'auth' for incorrect user/pass combinations.
 However, I do not like running programs that kick out 'errors' of any
 kind.
 It seems to always lead to unpredictable situations that are a problem.
 Any other ideas?
 Thanks,
 Chetanji
 
 Well then the $_POST array is empty that's why you have those notices.
 The $_POST array is populated with values ONLY after the form was
 submitted to the login.php script.
 If you use this script before the form was submitted or in any other
 context, then you will get those notices.
 
 If you check if the variables you are looking for are set, before
 assigning them, you will not get the notices.
 
 Try this:
 if(isset($_POST[myusername]) AND isset($_POST[mypassword])){
  $myusername=$_POST[myusername];
  $mypassword=$_POST[mypassword];
 }
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 

-- 
View this message in context: 
http://www.nabble.com/PHP-to-md5-the-%24var-before-it-reaches-MySQL%27s-gen-query-log-tf3731340.html#a10607559
Sent from the Php - Database mailing list archive at Nabble.com.

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



Re: [PHP-DB] PHP to md5 the $var before it reaches MySQL's gen query log

2007-05-12 Thread Chetanji

Hey Bedul,
I dropped the table and recreated it with VARCHAR (50) for both. (The reason
I like BLOB is when you edit the table all you see is BLOB until you have
the permission to open it to binary or text.

Here is the log message:

070512 16:36:07  35 Connect [EMAIL PROTECTED] on 
 35 Init DB aims site
 35 Query   INSERT INTO docproedit 
(username,password)VALUES
 
('61d46e51e01c5c77ffb9a60f00a842a1'),('2ccd89b67324dd915dd2d286f613332e')
 35 Query   INSERT INTO docproedit
(username,password)VALUES(md5('mata's'),md5('blessing'))
 35 Query   1
 35 Quit   

Now neither INSERT works.  Do you know what the '1' is by the way?
With BLOB at least one worked with inserting $var's in the values.
This seems like a silly problem.
There must be some way to do this proper.  I'm just a baby at this.
Blessings,
Chetan




Bedul says:


bedul wrote:
 
 username BLOB NOT NULL default '',
 password BLOB NOT NULL default '',
 
 do you try
 username varchar 50,
 password varchar 50??
 
 i'm just ask..
 sry, hope that's can solve your problem
 
 - Original Message -
 From: Chetan Graham [EMAIL PROTECTED]
 To: php-db@lists.php.net
 Sent: Saturday, May 12, 2007 4:28 PM
 Subject: [PHP-DB] PHP to md5 the $var before it reaches MySQL's gen query
 log
 
 
 Greetings to All,
 I am having difficulty in 'md5'ing a $var in a function before it is
 placed into the (INSERT INTO table...

 The whole point is I don't want the MySQL DB logs showing my $var's
 password and username 'before' it is encrypted by MySQL's md5.

 When MySQL receives PHP's encrypted $var the log shows query INSERT with
 the 32 bits but it is not inserted into the DB.

 MySQL will not accept the $var's in the code that is commented out.
 It shows no errors by the way.
 MySQL accepts what is shown, but this is not as I explained what I want.
 Thanks In Advance,
 Chetan

  mysql_query(CREATE TABLE IF NOT EXISTS docproedit (
   id int(11) NOT NULL auto_increment,
   username BLOB NOT NULL default '',
   password BLOB NOT NULL default '',
   TimeEnter timestamp,
   PRIMARY KEY (id)
)
   ENGINE=MyISAM;)or die('Create Died' . mysql_error());


 ?php
 $db_server='localhost';
 $db_user='root';
 $db_pass='somepassword';
 $db_name='aims site';
 $tbl_name='docproedit';
 $con = mysql_connect($db_server,$db_user,$db_pass) or die(mysql_error());
 $q=mysql_select_db($db_name, $con) or die(mysql_error());

 function addNewUser($username,$password){
 global $q;
 global $tbl_name;
 global $con;
 //$user=md5($username);
 //$pass=md5($password);
 //mysql_query(INSERT INTO $tbl_name
 (username,password)VALUES('$user'),('$pass'));
 $user=$username;
 $pass=$password;
 mysql_query(INSERT INTO $tbl_name
 (username,password)VALUES(md5('$user'),md5('$pass')));
 return mysql_query($q,$con);
 }
 ?
 ?php
 $username=somename;
 $password=somepassword;

 addNewUser($username,$password);
 echo h2New User Added!/h2;
 ?

 --
 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
 
 
 

-- 
View this message in context: 
http://www.nabble.com/PHP-to-md5-the-%24var-before-it-reaches-MySQL%27s-gen-query-log-tf3731340.html#a10444916
Sent from the Php - Database mailing list archive at Nabble.com.

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



Re: [PHP-DB] PHP to md5 the $var before it reaches MySQL's gen query log

2007-05-12 Thread Chetanji

Hey Bedul,
My mistake as md5 on MySQL side still works.  I put an extra ' in the
passwords value by mistake.  I corrected it.
Still no error from MySQL I can not tell the difference from either INSERT
in the log as both look the same(except one is  binary 32bits and the other
md5('text').

Still haven't figured this silly problem out.
Thanks for your quick help though.
Chetan
 

Chetanji wrote:
 
 Hey Bedul,
 I dropped the table and recreated it with VARCHAR (50) for both. (The
 reason I like BLOB is when you edit the table all you see is BLOB until
 you have the permission to open it to binary or text.
 
 Here is the log message:
 
 070512 16:36:0735 Connect [EMAIL PROTECTED] on 
35 Init DB aims site
35 Query   INSERT INTO docproedit 
 (username,password)VALUES
  
 ('61d46e51e01c5c77ffb9a60f00a842a1'),('2ccd89b67324dd915dd2d286f613332e')
35 Query   INSERT INTO docproedit
 (username,password)VALUES(md5('mata's'),md5('blessing'))
35 Query   1
35 Quit   
 
 Now neither INSERT works.  Do you know what the '1' is by the way?
 With BLOB at least one worked with inserting $var's in the values.
 This seems like a silly problem.
 There must be some way to do this proper.  I'm just a baby at this.
 Blessings,
 Chetan
 
 
 
 
 Bedul says:
 
 
 bedul wrote:
 
 username BLOB NOT NULL default '',
 password BLOB NOT NULL default '',
 
 do you try
 username varchar 50,
 password varchar 50??
 
 i'm just ask..
 sry, hope that's can solve your problem
 
 - Original Message -
 From: Chetan Graham [EMAIL PROTECTED]
 To: php-db@lists.php.net
 Sent: Saturday, May 12, 2007 4:28 PM
 Subject: [PHP-DB] PHP to md5 the $var before it reaches MySQL's gen query
 log
 
 
 Greetings to All,
 I am having difficulty in 'md5'ing a $var in a function before it is
 placed into the (INSERT INTO table...

 The whole point is I don't want the MySQL DB logs showing my $var's
 password and username 'before' it is encrypted by MySQL's md5.

 When MySQL receives PHP's encrypted $var the log shows query INSERT with
 the 32 bits but it is not inserted into the DB.

 MySQL will not accept the $var's in the code that is commented out.
 It shows no errors by the way.
 MySQL accepts what is shown, but this is not as I explained what I want.
 Thanks In Advance,
 Chetan

  mysql_query(CREATE TABLE IF NOT EXISTS docproedit (
   id int(11) NOT NULL auto_increment,
   username BLOB NOT NULL default '',
   password BLOB NOT NULL default '',
   TimeEnter timestamp,
   PRIMARY KEY (id)
)
   ENGINE=MyISAM;)or die('Create Died' . mysql_error());


 ?php
 $db_server='localhost';
 $db_user='root';
 $db_pass='somepassword';
 $db_name='aims site';
 $tbl_name='docproedit';
 $con = mysql_connect($db_server,$db_user,$db_pass) or
 die(mysql_error());
 $q=mysql_select_db($db_name, $con) or die(mysql_error());

 function addNewUser($username,$password){
 global $q;
 global $tbl_name;
 global $con;
 //$user=md5($username);
 //$pass=md5($password);
 //mysql_query(INSERT INTO $tbl_name
 (username,password)VALUES('$user'),('$pass'));
 $user=$username;
 $pass=$password;
 mysql_query(INSERT INTO $tbl_name
 (username,password)VALUES(md5('$user'),md5('$pass')));
 return mysql_query($q,$con);
 }
 ?
 ?php
 $username=somename;
 $password=somepassword;

 addNewUser($username,$password);
 echo h2New User Added!/h2;
 ?

 --
 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
 
 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/PHP-to-md5-the-%24var-before-it-reaches-MySQL%27s-gen-query-log-tf3731340.html#a10445016
Sent from the Php - Database mailing list archive at Nabble.com.

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



Re: [PHP-DB] PHP to md5 the $var before it reaches MySQL's gen query log

2007-05-12 Thread Chetanji

Once again sorry to all for indulging you.  I have found the answer, plus a
little additional security on the this.
Here is the code that works with additional encrypting of the md5 from PHP. 
My syntax was incorrect before.
Bedul got me thinking by changing the BLOB to VARCHAR.  That led to the
answer.
Blessings, 
Chetan


function addNewUser($username,$password){
global $q;
global $tbl_name;
global $con;
$usrname=md5($username);
$passname=md5($password);

//hash then encrypt a string
function Encrypt($string) {$crypted = crypt(md5($string),
md5($string));return $crypted; } 

$user = encrypt($usrname);
$pass = encrypt($passname);

mysql_query(INSERT INTO $tbl_name
(username,password)VALUES('$user','$pass'));

return mysql_query($q,$con);

;;
;;



Chetanji wrote:
 
 Hey Bedul,
 My mistake as md5 on MySQL side still works.  I put an extra ' in the
 passwords value by mistake.  I corrected it.
 Still no error from MySQL I can not tell the difference from either INSERT
 in the log as both look the same(except one is  binary 32bits and the
 other md5('text').
 
 Still haven't figured this silly problem out.
 Thanks for your quick help though.
 Chetan
  
 
 Chetanji wrote:
 
 Hey Bedul,
 I dropped the table and recreated it with VARCHAR (50) for both. (The
 reason I like BLOB is when you edit the table all you see is BLOB until
 you have the permission to open it to binary or text.
 
 Here is the log message:
 
 070512 16:36:07   35 Connect [EMAIL PROTECTED] on 
   35 Init DB aims site
   35 Query   INSERT INTO docproedit 
 (username,password)VALUES
  
 ('61d46e51e01c5c77ffb9a60f00a842a1'),('2ccd89b67324dd915dd2d286f613332e')
   35 Query   INSERT INTO docproedit
 (username,password)VALUES(md5('mata's'),md5('blessing'))
   35 Query   1
   35 Quit   
 
 Now neither INSERT works.  Do you know what the '1' is by the way?
 With BLOB at least one worked with inserting $var's in the values.
 This seems like a silly problem.
 There must be some way to do this proper.  I'm just a baby at this.
 Blessings,
 Chetan
 
 
 
 
 Bedul says:
 
 
 bedul wrote:
 
 username BLOB NOT NULL default '',
 password BLOB NOT NULL default '',
 
 do you try
 username varchar 50,
 password varchar 50??
 
 i'm just ask..
 sry, hope that's can solve your problem
 
 - Original Message -
 From: Chetan Graham [EMAIL PROTECTED]
 To: php-db@lists.php.net
 Sent: Saturday, May 12, 2007 4:28 PM
 Subject: [PHP-DB] PHP to md5 the $var before it reaches MySQL's gen
 query
 log
 
 
 Greetings to All,
 I am having difficulty in 'md5'ing a $var in a function before it is
 placed into the (INSERT INTO table...

 The whole point is I don't want the MySQL DB logs showing my $var's
 password and username 'before' it is encrypted by MySQL's md5.

 When MySQL receives PHP's encrypted $var the log shows query INSERT
 with
 the 32 bits but it is not inserted into the DB.

 MySQL will not accept the $var's in the code that is commented out.
 It shows no errors by the way.
 MySQL accepts what is shown, but this is not as I explained what I
 want.
 Thanks In Advance,
 Chetan

  mysql_query(CREATE TABLE IF NOT EXISTS docproedit (
   id int(11) NOT NULL auto_increment,
   username BLOB NOT NULL default '',
   password BLOB NOT NULL default '',
   TimeEnter timestamp,
   PRIMARY KEY (id)
)
   ENGINE=MyISAM;)or die('Create Died' . mysql_error());


 ?php
 $db_server='localhost';
 $db_user='root';
 $db_pass='somepassword';
 $db_name='aims site';
 $tbl_name='docproedit';
 $con = mysql_connect($db_server,$db_user,$db_pass) or
 die(mysql_error());
 $q=mysql_select_db($db_name, $con) or die(mysql_error());

 function addNewUser($username,$password){
 global $q;
 global $tbl_name;
 global $con;
 //$user=md5($username);
 //$pass=md5($password);
 //mysql_query(INSERT INTO $tbl_name
 (username,password)VALUES('$user'),('$pass'));
 $user=$username;
 $pass=$password;
 mysql_query(INSERT INTO $tbl_name
 (username,password)VALUES(md5('$user'),md5('$pass')));
 return mysql_query($q,$con);
 }
 ?
 ?php
 $username=somename;
 $password=somepassword;

 addNewUser($username,$password);
 echo h2New User Added!/h2;
 ?

 --
 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
 
 
 
 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/PHP-to-md5-the-%24var-before-it-reaches-MySQL%27s-gen-query-log-tf3731340.html#a10445307
Sent from the Php - Database mailing list archive