How to use parameters in sql ?(PHP)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • afraze
    New Member
    • Aug 2007
    • 18

    How to use parameters in sql ?(PHP)

    I want to write this sql query:

    Code:
    Select * from table1 limit 0,5
    when i wanted to use php parameter for this query, i got syntax error.

    My code:

    [PHP]...
    $count = 0;
    ...
    mysql_query("Se lect * from table1 limit".$count." ,5");[/PHP]

    So how can i fix the syntax problem for using the parameter in sql?
  • ak1dnar
    Recognized Expert Top Contributor
    • Jan 2007
    • 1584

    #2
    Hi There!
    Welcome to TSDN!

    Try This

    [PHP] mysql_query("Se lect * from table1 limit $count,5");[/PHP]

    Or

    [PHP] mysql_query("Se lect * from table1 limit {$count},5");[/PHP]

    Comment

    • afraze
      New Member
      • Aug 2007
      • 18

      #3
      Thanks so much for your interest!. . .

      Comment

      • ak1dnar
        Recognized Expert Top Contributor
        • Jan 2007
        • 1584

        #4
        Originally posted by afraze
        Thanks so much for your interest!. . .
        So does it works afraze?

        Comment

        • afraze
          New Member
          • Aug 2007
          • 18

          #5
          ajaxrand,

          i am not using my personal comp.. So i 'll answer u after a couple of hours.. nearly 22:00 (my pos: gmt + 2)

          see u later

          Comment

          • afraze
            New Member
            • Aug 2007
            • 18

            #6
            ajaxrand,

            Your code doesn't work . . .

            i have still syntax problem.. :(

            Comment

            • realin
              Contributor
              • Feb 2007
              • 254

              #7
              Originally posted by afraze
              ajaxrand,

              Your code doesn't work . . .

              i have still syntax problem.. :(
              the code is perfect, it should work.. paste the error ;)

              that would help us

              Comment

              • afraze
                New Member
                • Aug 2007
                • 18

                #8
                Ajaxrand,
                i fixed my problem. Yes your code is perfect. i had a character problem. So thnks again..

                Comment

                • ak1dnar
                  Recognized Expert Top Contributor
                  • Jan 2007
                  • 1584

                  #9
                  Originally posted by afraze
                  Ajaxrand,
                  i fixed my problem. Yes your code is perfect. i had a character problem. So thnks again..
                  Ahha, Glad to hear that.
                  post back any time if you have any doubts!

                  -Ajaxrand

                  Comment

                  Working...