Jump to content
fatkatie

How to insure good form data winds up in the table.

Recommended Posts

I just started populating a mysql table with data collected from a form posting.  I do the dance ...

$post_partnumber_source = html_entity_decode(trim(fvs($_POST['nsel_pnsrc'])));where fvs is
function fvs($string){$string = filter_var($string,  FILTER_SANITIZE_STRING); return $string; }

And then I use PDO and binding.

Something has happened.  Something bad.

My PHP $sth->fetch(PDO::FETCH_OBJ) loops are failing.  All the records are not
being read (some seem to be read twice)... and it happens around the record when form input was starting to be used.

It's got to illegal data messing this up.  So, my question is, what now?

Will

mb_check_encoding() 

solve this or am I missing something very  basic.

Thank you.

 

mysql  Ver 15.1 Distrib 10.1.37-MariaDB, for Win32 (AMD64), Using configuration as supplied by xampp

Share this post


Link to post
Share on other sites

:psychic:

Can you be more specific about this "not being read" or "read twice"?

What had you changed when this started happening?

Share this post


Link to post
Share on other sites
while ($pending || $row = $sth->fetch(PDO::FETCH_OBJ)) {
   $pending = false;
   $hn = $row->houseid;
   writeData("READ $hn", __FILE__, __LINE__);
}

There's the loop.  houseid starts repeating.  I found the record but I don't see anything wrong yet. Newlines?  I'm going to rewrite the record with the check and see what that does.

Share this post


Link to post
Share on other sites

@#$@#$@!

You spend all day on something that has nothing to do with anything.  It was a stupid join.

mb_check_encoding

But, I would like  to know if mb_check_encoding() is worth anything.  I've relied on binding which has never failed me.

Thank you.

Share this post


Link to post
Share on other sites

mb_check_encoding is fine to use if you want to verify you're receiving valid string data. If your "binding" does that already then you don't need to add it.

Share this post


Link to post
Share on other sites

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.