Hi,
I come from a VB background and often to prepare a string for insertion into a database I would make sure that the length of the string did not exceed the size of varchar that the database could handle. So for example, assuming the database could only handle names up to 50 characters in length, I would write
and then go ahead and insert the string without fear of any data being truncated.
How do I go about this in PHP? I see the strlen() function but I don't see a way to get the first x characters of a string. Am I missing something?
Thanks in advance as I am very new to PHP.
I come from a VB background and often to prepare a string for insertion into a database I would make sure that the length of the string did not exceed the size of varchar that the database could handle. So for example, assuming the database could only handle names up to 50 characters in length, I would write
Code:
Name = Left(Name,50)
How do I go about this in PHP? I see the strlen() function but I don't see a way to get the first x characters of a string. Am I missing something?
Thanks in advance as I am very new to PHP.
Comment