vikram12345 Posted November 17, 2012 Share Posted November 17, 2012 Hi, I'm not new to Sql or PHP or atleast I hope not . 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 Quote Link to comment https://forums.phpfreaks.com/topic/270833-php-mysql-weirdo-error/ Share on other sites More sharing options...
jcbones Posted November 17, 2012 Share Posted November 17, 2012 You have either: 1. spelling error in your column names. 2. spelling error in your variable name. Quote Link to comment https://forums.phpfreaks.com/topic/270833-php-mysql-weirdo-error/#findComment-1393211 Share on other sites More sharing options...
vikram12345 Posted November 17, 2012 Author Share Posted November 17, 2012 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 . Any other way this could happen ?. Collation problems ?, any special setting for MySql to handle password fields ?? Quote Link to comment https://forums.phpfreaks.com/topic/270833-php-mysql-weirdo-error/#findComment-1393213 Share on other sites More sharing options...
Pikachu2000 Posted November 17, 2012 Share Posted November 17, 2012 Have you echoed the query string and made sure it contains the values you'd expect it to contain? Quote Link to comment https://forums.phpfreaks.com/topic/270833-php-mysql-weirdo-error/#findComment-1393214 Share on other sites More sharing options...
vikram12345 Posted November 17, 2012 Author Share Posted November 17, 2012 Have you echoed the query string and made sure it contains the values you'd expect it to contain? Can you give me an idea on how to do that, also correct me here, do you mean ? $sql = whatever query echo $sql ; ? Quote Link to comment https://forums.phpfreaks.com/topic/270833-php-mysql-weirdo-error/#findComment-1393215 Share on other sites More sharing options...
Pikachu2000 Posted November 17, 2012 Share Posted November 17, 2012 Exactly. Immediately after defining the $sql variable, and before executing the query. Quote Link to comment https://forums.phpfreaks.com/topic/270833-php-mysql-weirdo-error/#findComment-1393216 Share on other sites More sharing options...
vikram12345 Posted November 17, 2012 Author Share Posted November 17, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/270833-php-mysql-weirdo-error/#findComment-1393219 Share on other sites More sharing options...
MMDE Posted November 17, 2012 Share Posted November 17, 2012 (edited) 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! 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 November 17, 2012 by MMDE Quote Link to comment https://forums.phpfreaks.com/topic/270833-php-mysql-weirdo-error/#findComment-1393221 Share on other sites More sharing options...
Pikachu2000 Posted November 17, 2012 Share Posted November 17, 2012 Something is causing $password to be empty/undefined before it gets to the query. Do you have error reporting set up and on? Quote Link to comment https://forums.phpfreaks.com/topic/270833-php-mysql-weirdo-error/#findComment-1393222 Share on other sites More sharing options...
vikram12345 Posted November 17, 2012 Author Share Posted November 17, 2012 (edited) 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 November 17, 2012 by PFMaBiSmAd removed formatting to fix micro-font size Quote Link to comment https://forums.phpfreaks.com/topic/270833-php-mysql-weirdo-error/#findComment-1393223 Share on other sites More sharing options...
vikram12345 Posted November 17, 2012 Author Share Posted November 17, 2012 I shall upload the detailsverify.php, the code that verifies all fields Quote Link to comment https://forums.phpfreaks.com/topic/270833-php-mysql-weirdo-error/#findComment-1393225 Share on other sites More sharing options...
vikram12345 Posted November 17, 2012 Author Share Posted November 17, 2012 <?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 ; ?> Quote Link to comment https://forums.phpfreaks.com/topic/270833-php-mysql-weirdo-error/#findComment-1393226 Share on other sites More sharing options...
PFMaBiSmAd Posted November 17, 2012 Share Posted November 17, 2012 Any bets that you are trying to check if it is empty, but are actually assigning an empty string to it? Quote Link to comment https://forums.phpfreaks.com/topic/270833-php-mysql-weirdo-error/#findComment-1393227 Share on other sites More sharing options...
vikram12345 Posted November 17, 2012 Author Share Posted November 17, 2012 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 ? Quote Link to comment https://forums.phpfreaks.com/topic/270833-php-mysql-weirdo-error/#findComment-1393230 Share on other sites More sharing options...
vikram12345 Posted November 17, 2012 Author Share Posted November 17, 2012 Solved it, any guesses !!!!!!, come on, this is fun ! Quote Link to comment https://forums.phpfreaks.com/topic/270833-php-mysql-weirdo-error/#findComment-1393234 Share on other sites More sharing options...
vikram12345 Posted November 17, 2012 Author Share Posted November 17, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/270833-php-mysql-weirdo-error/#findComment-1393235 Share on other sites More sharing options...
PFMaBiSmAd Posted November 17, 2012 Share Posted November 17, 2012 When you try to copy/paste together a html document using php include statements, that's the kind of problems you run into. Quote Link to comment https://forums.phpfreaks.com/topic/270833-php-mysql-weirdo-error/#findComment-1393242 Share on other sites More sharing options...
vikram12345 Posted November 18, 2012 Author Share Posted November 18, 2012 When you try to copy/paste together a html document using php include statements, that's the kind of problems you run into. Very much, should quit linking multiple php files together. Quote Link to comment https://forums.phpfreaks.com/topic/270833-php-mysql-weirdo-error/#findComment-1393343 Share on other sites More sharing options...
jcbones Posted November 18, 2012 Share Posted November 18, 2012 This is why I 'DEFINE' my all of my configuration variables (constants). Quote Link to comment https://forums.phpfreaks.com/topic/270833-php-mysql-weirdo-error/#findComment-1393444 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.