help with changing php's datatype

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ese7
Forum Newbie
Posts: 2
Joined: Tue Aug 18, 2009 2:30 pm

help with changing php's datatype

Post by ese7 »

Hello everyone,

I downloaded this nice script for managing students' grades and did some modification and it's working perfectly except for the fact that the "Students ID' field accepts only figures, however, the students' IDs contain both figures and letters. For example, it accepts student IDs such as "1234" and not "MS1234". Now, I know that this has something to do with the datatype but the code is so intertwined that I can't even pinpoint where the datatype for the students' ID column was declared. Please I desperately heed help here.
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: help with changing php's datatype

Post by Darhazer »

Most likely the datatype is in the database, not in the PHP code, since PHP is dynamically-typed language. Using any database management tool (MySQL query browser, phpMyAdmin, in case it's uses MySQL database), you can change the type using the GUI.
ese7
Forum Newbie
Posts: 2
Joined: Tue Aug 18, 2009 2:30 pm

Re: help with changing php's datatype

Post by ese7 »

That's exactly what I thought, and I've done that. However, the student ID inserts into that database when you add student but when trying to login, it returns an 'invalid Student ID' error, even if the data is in the database. So I think the datatype for that particular field (Student ID) was declared somewhere in the code, perhaps in the login section but I cant seem to find where.
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: help with changing php's datatype

Post by Mark Baker »

ese7 wrote:That's exactly what I thought, and I've done that. However, the student ID inserts into that database when you add student but when trying to login, it returns an 'invalid Student ID' error, even if the data is in the database. So I think the datatype for that particular field (Student ID) was declared somewhere in the code, perhaps in the login section but I cant seem to find where.
The datatype can't be declared and enforced, but the input can be validated to ensure that it matches a certain pattern (e.g. numeric). It's likely that somewhere in the code it's validating your inputs
Post Reply