how to pass string to database query?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MyMarlboro
    New Member
    • Mar 2008
    • 71

    how to pass string to database query?

    i have a form where user click on a button then will direct him to another form which is database displaying page. i would like to filter the query based on user login id. So i could i do that?


    $result = mysql_query("SE LECT * FROM myDatabase WHERE name = 'userLoginID'") ; // < i could i get the userLoginID and pass it to here??
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.

    Yes, you can .

    Comment

    • hsriat
      Recognized Expert Top Contributor
      • Jan 2008
      • 1653

      #3
      You might SELECT * FROM yourTable rather than yourDatabase

      Comment

      • artov
        New Member
        • Jul 2008
        • 40

        #4
        Yes, you could, but you do not like to. Study SQL injection (for example from http://en.wikipedia.org/wiki/SQL_injection) and use parameterized statements instead.

        Comment

        • ragonz
          New Member
          • Jul 2008
          • 24

          #5
          try to
          echo $userLoginID;
          above that line, to see wheteher u fail or not gain the value from the previous page. If not than check ur method to post the data wheter using POST or GET method.

          Regards

          Comment

          Working...