Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with Invisible space in php + sql
#1
Hello guys, i got a problem with a script a friend made, what it does is convert values, but you must confirm your ID and PASSWORD, the problem is that the dbo.member table in the database saves password in char(50) format. It means, by default, all passwords are saved with spaces trailing after it in order to make it 50 bytes long. These pages do not add spaces on the submitted password, so even if the password submitted is correct, they are not accepted because it does not have those spaces, and the match fails.

I've been trying to fix it with all sorts of codes, but PHP doesn't seem to like me. Any suggestions?

Quote: // Get username and password POSTed by input page
if (isset($_POST['gameid'])) { $userName = $_POST['gameid']; }
else { die('Empty fields.'); }

if (isset($_POST['password'])) { $userPass = $_POST['password']; }
else { die('Empty fields.'); }

$s = 50 - strlen($userPass);

// Code here? $s is the number spaces to add.

if (isset($_POST['cashamt'])) { $convAmt = $_POST['cashamt']; }
else { die('Empty fields.'); }
Reply
#2
Why don't you just convert CHAR(50) to VARCHAR(50)?

I'm pretty sure that if you backed up the database, changed your CREATE sql TABLE(){ } to have VARCHAR instead of CHAR, and then Ctrl+f & replaced your way to glory, you could convert all the user-names and passwords to VARCHAR format.
Reply
#3
Yes use VARCHAR(50) instead and problem solved.
Superman I am here to rescue you.
This is Support Forums not Support PMs.  Do not PM me for support unless it's private and site related.
Reply
#4
tried with that, but is still saying me incorrect password =/
Reply
#5
Have you tried trim() yet? This trims leading and trailing spaces from input.

$psw = trim($_REQUEST['password']);
Reply
#6
Solved, close thread plz
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  PHP Framework List: An Ultimate Guide to 102 PHP Frameworks for Web Developers tk-hassan 0 943 07-27-2020, 11:26 PM
Last Post: tk-hassan
  PHP Video Tutorials (PHP For Beginners) Eleqtriq 4 3,671 10-10-2011, 01:00 PM
Last Post: Greyersting
  PHP and SQL ebook collection ! Prominent 5 1,423 08-24-2011, 05:40 PM
Last Post: Prominent
  Common PHP and SQL [File-Sharing Site] Project Evolution 3 1,884 12-12-2010, 02:47 AM
Last Post: Bursihido
  PHP Connects to Microsoft SQL Server... ethical_john 7 1,031 10-30-2009, 06:36 AM
Last Post: ethical_john

Forum Jump:


Users browsing this thread: 3 Guest(s)