substr value changes when submit to mysql

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cyberlei
    New Member
    • Sep 2007
    • 28

    substr value changes when submit to mysql

    Hello Guys,

    Just wondering how I can make the substr value changes when submit into mysql.

    something like:
    someone typed A123456 on a blank field and submit into mysql. the Value will only display 123456 in mysql

    Thanks a lot
  • nomad
    Recognized Expert Contributor
    • Mar 2007
    • 664

    #2
    Originally posted by cyberlei
    Hello Guys,

    Just wondering how I can make the substr value changes when submit into mysql.

    something like:
    someone typed A123456 on a blank field and submit into mysql. the Value will only display 123456 in mysql

    Thanks a lot
    take a look at the substr() function

    nomad

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      Originally posted by cyberlei
      Hello Guys,

      Just wondering how I can make the substr value changes when submit into mysql.

      something like:
      someone typed A123456 on a blank field and submit into mysql. the Value will only display 123456 in mysql

      Thanks a lot
      Most probable cause would be a mistake in offset value of the the substr() function. Starts at 0 (zero) and not 1 (one).

      Ronald

      Comment

      • cyberlei
        New Member
        • Sep 2007
        • 28

        #4
        Originally posted by ronverdonk
        Most probable cause would be a mistake in offset value of the the substr() function. Starts at 0 (zero) and not 1 (one).

        Ronald
        something like?
        Code:
        <?php
        substr=ltrim($sn,"A")
        ?>

        Comment

        • ronverdonk
          Recognized Expert Specialist
          • Jul 2006
          • 4259

          #5
          Originally posted by cyberlei
          something like?
          Code:
          <?php
          substr=ltrim($sn,"A")
          ?>
          That is not the SUBSTR() function, that is the LTRIM() function.
          See the PHP documentation for a full description HERE

          Ronald

          Comment

          • nomad
            Recognized Expert Contributor
            • Mar 2007
            • 664

            #6
            Originally posted by nomad
            take a look at the substr() function

            nomad
            for some reason some of my code was not posted.

            you could do this
            $test = "phpcoder";
            echo substr($test, 3) ; //prints "coder"

            nomad

            Comment

            • cyberlei
              New Member
              • Sep 2007
              • 28

              #7
              Issue Resolved, Here is the code
              Code:
              $Text = ltrim($Text, 'A');

              Comment

              • ronverdonk
                Recognized Expert Specialist
                • Jul 2006
                • 4259

                #8
                Anything that helps you out.

                Ronald

                Comment

                Working...