Jump to content

Recommended Posts

Hi,

I'm not new to Sql or PHP or atleast I hope not :happy-04: . I coded a simple register form in HTML and this file opens a 'newuser.php' which in turn opens another one, and another finally after checking all INPUT fields, reaches a 'enterintodb.php' .

 

Now, here's the joke. Every field enters into the table of MySql except for the password field. All entries including 1st name, last name, etc etc. get added to the table and like I said , password doesn't add.

 

Just to be sure, at the end I echo all the fields and then echo "New user created !" .

 

No MySql error or any syntax error displayed. The password field echoes w/o any problems, it displays the entered password. But no entry in the DB .

 

password column : varchar(255) , utf16_general_ci ,

 

Iv also attached the enterintodb.php file .

the others don't matter, coz when I echo $password, it displays perfectly.

 

in the form this is the password field " <input type="password" name="password" size="20" style="border-left-width=0px"> "

 

and don't worry about sql auth, i run a separate PHP file for that before enterintodb.php

 

So, guys, help me out :) please

 

Here's the attachment = enterintodb.php

Link to comment
https://forums.phpfreaks.com/topic/270833-php-mysql-weirdo-error/
Share on other sites

You have either:

1. spelling error in your column names.

2. spelling error in your variable name.

 

Well, I don't seem to have a variable spelling error, seems to me the echo wouldn't have worked at all.

No column spelling error either, double checked both. I'm running on Xampp, with phpmyadmin .

restarted MySql twice, no progress there either . :sweat: Any other way this could happen ?. Collation problems ?, any special setting for MySql to handle password fields ??

Exactly. Immediately after defining the $sql variable, and before executing the query.

 

Alright, looks like we're getting somewhere.

echoed the query, the insert password value turns blank for some reason .

Any idea ?, all other inserts have solid values, only the pw value disappears during query

Alright, looks like we're getting somewhere.

echoed the query, the insert password value turns blank for some reason .

Any idea ?, all other inserts have solid values, only the pw value disappears during query

We don't see your code, how should we know?

Please post it! :P

 

My tip is to trace it all the way back to where you think you get it from and echo it all the way from there to wherever you lose it.

Edited by MMDE

as you can see

 

INSERT INTO userregistry (email,password11,firstname,lastname,contact,sex,dob,active,date) VALUES ('vikram12345@gmail.com','','cv','sd','9535283163','1','01012000','1','November 17, 2012, 10:53 pm')

 

^ the echoed sql query

Edited by PFMaBiSmAd
removed formatting to fix micro-font size

<?php

date_default_timezone_set('Asia/Kolkata') ;

$estatus = 0 ;

$erepeatstatus = 0 ;

$passwordstatus = 0 ;

$repeatpasswordstatus = 0 ;

$date = date("F j, Y, g:i a");

$active = 1 ;

$blankemail = 0 ;

$blankpassword = 0 ;

$allokay = 0 ;

if (strlen($email)==0)

{

$blankemail = 2 ;

}

else

{

$blankemail = 1 ;

}

 

if (strlen($password)==0)

{

$blankpassword = 2 ;

}

else

{

$blankpassword = 1 ;

}

 

if(!filter_var($email, FILTER_VALIDATE_EMAIL))

{

$estatus = 2 ;

}

else

{

$estatus = 1 ;

}

 

if($emailtwo == $emailtwo)

{

$erepeatstatus = 1 ;

}

else

{

$erepeatstatus = 2 ;

}

 

 

if (strlen($password)<= 10)

{

$passwordstatus = 1 ;

}

else

{

$passwordstatus = 2 ;

}

 

if($password == $passwordtwo)

{

$passwordrepeatstatus = 1 ;

}

else

{

$passwordrepeatstatus = 2 ;

}

 

echo $email."<br>" ;

echo $emailtwo."<br>" ;

echo $password."<br>" ;

echo $passwordtwo."<br>" ;

//echo intval($email);

 

 

$allokay = $blankemail.$blankpassword.$estatus.$erepeatstatus.$passwordstatus.$passwordrepeatstatus ;

echo $allokay ;

if($allokay == 111111)

{

require ('sqlauth2.php') ;

require ('enterintodb.php') ;

echo "new user registered " ;

}

else

{

$goto = "http://localhost:78/bullet2/newuserregister.php?blankemail=".$blankemail."&blankpassword=".$blankpassword."&emailformat=".$estatus."&emailrepeat=".$erepeatstatus."&longpassword=".$passwordstatus."&passwordrepeat=".$passwordrepeatstatus ;

header("Location: $goto ");

}

exit ;

 

?>

Any bets that you are trying to check if it is empty, but are actually assigning an empty string to it?

 

It doesn't get assign empty. echoed $password right before mysql query. displays the value fine

anything wrong with the mysql code ?

Alright, here it is :

 

before addintodb.php

I run sqlauth.php

 

Since I'm runnin sql w/o a password, the $password from the form and $password from the auth file conflict.

Thereby the $password sets to null .

change sql $password to $passworda or whatever and conflict resolved :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.