Solved

numbers php and mysql

Posted on 2011-02-24
4
288 Views
Last Modified: 2013-12-13
Hello Experts,

This is a php form with a mysql database.
One of the fields is a "security number".
The validation of the field entry is done as below:

if(strlen($form_sec_number)<=4) $error_security=0;

Open in new window


Strange issue i have found out is:  If the user enter for example the following numbers: "009"
it prints on the confirmation page the following sign "-" (as a result of the entry).

When i went back to the edit the entry (edit the form) the only number that displays in that field is number "9" so it basically trimmed the "00".

anyone has an idea why or how i can work around it?
0
Comment
Question by:Refael
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 17

Accepted Solution

by:
Shinesh Premrajan earned 500 total points
ID: 34977184
In the database define the securitynumber as string, using integer will truncate the values.

hope this helps
0
 

Author Comment

by:Refael
ID: 34977236
Hi shinuq, thank you.

You are right, it was INT and now i have changed it to: VARCHAR 11 UTF8_BIN.
Yet, still the same problem.

I tried to enter "009" directly via phpmyadmin and it went fine and also it prints on the page:"009".
BUT when i tired to update the entry (via the form) the same problem i face.
So i guess it is something in the form or?
0
 
LVL 11

Expert Comment

by:Ovid Burke
ID: 34977242
What is the desired length (in digits) of your security numbers? What data type does it go to in your database? What $error_security=0 mean or what does it do?
0
 

Author Comment

by:Refael
ID: 34977251

Hi shinuq,

ok your first solution really helped me. i had also to change it from INT to String in the form script when inserting the data.... 'ssiisssssss' i guess you know what i mean,

thank you so much!
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question