strtolower() for query results

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jerim79

    strtolower() for query results

    I need to take the output from a query and convert it to lower case.
    Here is the relevant code:

    $query="SELECT FNAME, LNAME FROM (table) WHERE FNAME=('$FName' ) AND
    LNAME=('$LName' )";
    $result = mysql_query($qu ery) or die('Query failed: ' . mysql_error());


    I can get number of rows by using mysql_num_rows( $result) so I assume
    there is some similar method for accessing data in the $result
    variable. This didn't seem to work: $result=strtolo wer($result);
    Also changing the query to read LNAME=strtolowe r('$LName') didn't
    work either. I am just looking for a way to access the FNAME and the
    LNAME in the $result variable.

  • BKDotCom

    #2
    Re: strtolower() for query results


    I appologize, but what is with all the MySQL questions?

    RTFM!



    $result = mysql_query($qu ery);
    $rows = array();
    $num_rows = mysql_num_rows( $result);
    for ( $i=0; $i<$num_rows; $i++ )
    $rows[] = mysql_fetch_ass oc($result);
    print_r($rows);

    Comment

    • Jerim79

      #3
      Re: strtolower() for query results


      BKDotCom wrote:
      I appologize, but what is with all the MySQL questions?
      >
      RTFM!
      >

      >
      $result = mysql_query($qu ery);
      $rows = array();
      $num_rows = mysql_num_rows( $result);
      for ( $i=0; $i<$num_rows; $i++ )
      $rows[] = mysql_fetch_ass oc($result);
      print_r($rows);
      Oh, I am sorry. I thought this was a newsgroup about PHP. My bad.

      Comment

      • BKDotCom

        #4
        Re: strtolower() for query results


        Jerim79 wrote:
        >
        Oh, I am sorry. I thought this was a newsgroup about PHP. My bad.
        how many times do we have to explain what mysql_query() returns?
        You've started a few threads asking the same question.
        Very similar mysql related questions have also been asked in just the
        last couple of days.
        I simply suggest you use your resources a bit better.
        There's no shortage of documentation and examples.

        Comment

        • Jerim79

          #5
          Re: strtolower() for query results


          BKDotCom wrote:
          Jerim79 wrote:

          Oh, I am sorry. I thought this was a newsgroup about PHP. My bad.
          >
          how many times do we have to explain what mysql_query() returns?
          You've started a few threads asking the same question.
          Very similar mysql related questions have also been asked in just the
          last couple of days.
          I simply suggest you use your resources a bit better.
          There's no shortage of documentation and examples.
          Huh? I started another thread about IF/Then when using mysql queries.
          Some code snippets were submitted. That situation has been resolved. As
          far as I know, no one has explained what mysql_query() returns in any
          detail that I wasn't already familiar with.

          I think the statement "how many times do we have to explain what
          mysql_query() returns?" is not only false, but irrelevant to my current
          situation. I may post a lot, but I always keep new threads to new
          issues. I use the existing thread to work on the existing problem. I
          certainly understand the concern of flooding the newsgroup with the
          same topic over and over. However, I feel that I have not done that.
          You may think all my posts are all on the same topic, but I can assure
          you they are not. Perhaps I haven't been expressive enough in
          explaining my problem. My posts may be "simple" to advanced
          programmers, but you can always choose to ignore them. You should never
          discourage people from asking questions. I am a beginner and am running
          across a lot of situations where I can't find anything on point for
          what I am trying to do. Sure I can find "similar" posts, but nothing
          that addresses my concerns. If you know of a post that is precisely on
          point, please let me know , as I have yet to find one.

          Comment

          • Jerim79

            #6
            Re: strtolower() for query results


            Jerim79 wrote:
            BKDotCom wrote:
            Jerim79 wrote:
            >
            Oh, I am sorry. I thought this was a newsgroup about PHP. My bad.
            how many times do we have to explain what mysql_query() returns?
            You've started a few threads asking the same question.
            Very similar mysql related questions have also been asked in just the
            last couple of days.
            I simply suggest you use your resources a bit better.
            There's no shortage of documentation and examples.
            >
            Huh? I started another thread about IF/Then when using mysql queries.
            Some code snippets were submitted. That situation has been resolved. As
            far as I know, no one has explained what mysql_query() returns in any
            detail that I wasn't already familiar with.
            >
            I think the statement "how many times do we have to explain what
            mysql_query() returns?" is not only false, but irrelevant to my current
            situation. I may post a lot, but I always keep new threads to new
            issues. I use the existing thread to work on the existing problem. I
            certainly understand the concern of flooding the newsgroup with the
            same topic over and over. However, I feel that I have not done that.
            You may think all my posts are all on the same topic, but I can assure
            you they are not. Perhaps I haven't been expressive enough in
            explaining my problem. My posts may be "simple" to advanced
            programmers, but you can always choose to ignore them. You should never
            discourage people from asking questions. I am a beginner and am running
            across a lot of situations where I can't find anything on point for
            what I am trying to do. Sure I can find "similar" posts, but nothing
            that addresses my concerns. If you know of a post that is precisely on
            point, please let me know , as I have yet to find one.
            Okay, the problem has been solved. What I was trying to do was get my
            variables from the HTM form into lower case. I would then search a
            MySQL database for those values. My associate seemed to think the
            database was case sensitive. So I was looking for a way to make sure
            that the MySQL query converted everything to lower case. However, while
            playing around with it, I got it to work, and didn't have to change the
            MySQL query at all. It looks like the database stores the variables in
            lower case to begin with.

            I was able to run some test data through it, and it always returned the
            correct value for the right data which was positive, no matter how I
            capitilized it. Wrong data would return the correct value, which in
            this case was a negative. So it seems that you don't necessarily have
            to modify your MySQL statement. At least I didn't have to.

            Comment

            • Shelly

              #7
              Re: strtolower() for query results


              "Jerim79" <mylek@hotmail. comwrote in message
              news:1164145458 .506164.274480@ h54g2000cwb.goo glegroups.com.. .
              >
              Jerim79 wrote:
              >BKDotCom wrote:
              Jerim79 wrote:
              >
              Oh, I am sorry. I thought this was a newsgroup about PHP. My bad.
              >
              how many times do we have to explain what mysql_query() returns?
              You've started a few threads asking the same question.
              Very similar mysql related questions have also been asked in just the
              last couple of days.
              I simply suggest you use your resources a bit better.
              There's no shortage of documentation and examples.
              >>
              >Huh? I started another thread about IF/Then when using mysql queries.
              >Some code snippets were submitted. That situation has been resolved. As
              >far as I know, no one has explained what mysql_query() returns in any
              >detail that I wasn't already familiar with.
              >>
              >I think the statement "how many times do we have to explain what
              >mysql_query( ) returns?" is not only false, but irrelevant to my current
              >situation. I may post a lot, but I always keep new threads to new
              >issues. I use the existing thread to work on the existing problem. I
              >certainly understand the concern of flooding the newsgroup with the
              >same topic over and over. However, I feel that I have not done that.
              >You may think all my posts are all on the same topic, but I can assure
              >you they are not. Perhaps I haven't been expressive enough in
              >explaining my problem. My posts may be "simple" to advanced
              >programmers, but you can always choose to ignore them. You should never
              >discourage people from asking questions. I am a beginner and am running
              >across a lot of situations where I can't find anything on point for
              >what I am trying to do. Sure I can find "similar" posts, but nothing
              >that addresses my concerns. If you know of a post that is precisely on
              >point, please let me know , as I have yet to find one.
              >
              Okay, the problem has been solved. What I was trying to do was get my
              variables from the HTM form into lower case. I would then search a
              MySQL database for those values. My associate seemed to think the
              database was case sensitive. So I was looking for a way to make sure
              that the MySQL query converted everything to lower case. However, while
              playing around with it, I got it to work, and didn't have to change the
              MySQL query at all. It looks like the database stores the variables in
              lower case to begin with.
              >
              I was able to run some test data through it, and it always returned the
              correct value for the right data which was positive, no matter how I
              capitilized it. Wrong data would return the correct value, which in
              this case was a negative. So it seems that you don't necessarily have
              to modify your MySQL statement. At least I didn't have to.
              >
              Sometimes the search **IS** case sensitive. I ran into that when the
              database had a mixed case (like "Hound" and the search failed when I put in
              "hound" -- or maybe it was vice-versa).

              Shelly


              Comment

              • Jerry Stuckle

                #8
                Re: strtolower() for query results

                Shelly wrote:
                "Jerim79" <mylek@hotmail. comwrote in message
                news:1164145458 .506164.274480@ h54g2000cwb.goo glegroups.com.. .
                >
                >>Jerim79 wrote:
                >>
                >>>BKDotCom wrote:
                >>>
                >>>>Jerim79 wrote:
                >>>>
                >>>>>Oh, I am sorry. I thought this was a newsgroup about PHP. My bad.
                >>>>
                >>>>how many times do we have to explain what mysql_query() returns?
                >>>>You've started a few threads asking the same question.
                >>>>Very similar mysql related questions have also been asked in just the
                >>>>last couple of days.
                >>>>I simply suggest you use your resources a bit better.
                >>>>There's no shortage of documentation and examples.
                >>>
                >>>Huh? I started another thread about IF/Then when using mysql queries.
                >>>Some code snippets were submitted. That situation has been resolved. As
                >>>far as I know, no one has explained what mysql_query() returns in any
                >>>detail that I wasn't already familiar with.
                >>>
                >>>I think the statement "how many times do we have to explain what
                >>>mysql_query( ) returns?" is not only false, but irrelevant to my current
                >>>situation. I may post a lot, but I always keep new threads to new
                >>>issues. I use the existing thread to work on the existing problem. I
                >>>certainly understand the concern of flooding the newsgroup with the
                >>>same topic over and over. However, I feel that I have not done that.
                >>>You may think all my posts are all on the same topic, but I can assure
                >>>you they are not. Perhaps I haven't been expressive enough in
                >>>explaining my problem. My posts may be "simple" to advanced
                >>>programmer s, but you can always choose to ignore them. You should never
                >>>discourage people from asking questions. I am a beginner and am running
                >>>across a lot of situations where I can't find anything on point for
                >>>what I am trying to do. Sure I can find "similar" posts, but nothing
                >>>that addresses my concerns. If you know of a post that is precisely on
                >>>point, please let me know , as I have yet to find one.
                >>
                >>Okay, the problem has been solved. What I was trying to do was get my
                >>variables from the HTM form into lower case. I would then search a
                >>MySQL database for those values. My associate seemed to think the
                >>database was case sensitive. So I was looking for a way to make sure
                >>that the MySQL query converted everything to lower case. However, while
                >>playing around with it, I got it to work, and didn't have to change the
                >>MySQL query at all. It looks like the database stores the variables in
                >>lower case to begin with.
                >>
                >>I was able to run some test data through it, and it always returned the
                >>correct value for the right data which was positive, no matter how I
                >>capitilized it. Wrong data would return the correct value, which in
                >>this case was a negative. So it seems that you don't necessarily have
                >>to modify your MySQL statement. At least I didn't have to.
                >>
                >
                >
                Sometimes the search **IS** case sensitive. I ran into that when the
                database had a mixed case (like "Hound" and the search failed when I put in
                "hound" -- or maybe it was vice-versa).
                >
                Shelly
                >
                >
                It depends on the database definition. Searches are case sensitive if
                the column is specified as BINARY; otherwise they are case-insensitive.

                --
                =============== ===
                Remove the "x" from my email address
                Jerry Stuckle
                JDS Computer Training Corp.
                jstucklex@attgl obal.net
                =============== ===

                Comment

                • Shelly

                  #9
                  Re: strtolower() for query results


                  "Jerry Stuckle" <jstucklex@attg lobal.netwrote in message
                  news:9qadnZ2vHP utUv7YnZ2dnUVZ_ u6dnZ2d@comcast .com...
                  It depends on the database definition. Searches are case sensitive if the
                  column is specified as BINARY; otherwise they are case-insensitive.
                  This was for a VARCHAR. I thought it unusual at the time, but was too busy
                  to investigate further. I just changed it to match and it worked.

                  Shelly


                  Comment

                  • Shelly

                    #10
                    Re: strtolower() for query results


                    "Jerry Stuckle" <jstucklex@attg lobal.netwrote in message
                    news:9qadnZ2vHP utUv7YnZ2dnUVZ_ u6dnZ2d@comcast .com...
                    It depends on the database definition. Searches are case sensitive if the
                    column is specified as BINARY; otherwise they are case-insensitive.
                    On second thought, maybe my memory is failing me. It might have been an
                    enum.

                    Shelly


                    Comment

                    • Jerry Stuckle

                      #11
                      Re: strtolower() for query results

                      Shelly wrote:
                      "Jerry Stuckle" <jstucklex@attg lobal.netwrote in message
                      news:9qadnZ2vHP utUv7YnZ2dnUVZ_ u6dnZ2d@comcast .com...
                      >
                      >>It depends on the database definition. Searches are case sensitive if the
                      >>column is specified as BINARY; otherwise they are case-insensitive.
                      >
                      >
                      On second thought, maybe my memory is failing me. It might have been an
                      enum.
                      >
                      Shelly
                      >
                      >
                      OK, that makes sense. I believe enums are case sensitive. But
                      VARCHAR's which are not defined as BINARY should not be.

                      --
                      =============== ===
                      Remove the "x" from my email address
                      Jerry Stuckle
                      JDS Computer Training Corp.
                      jstucklex@attgl obal.net
                      =============== ===

                      Comment

                      Working...