Results 1 to 4 of 4

Thread: Use variables in a MySQL query

  1. #1
    Join Date
    Apr 2009
    Posts
    79

    Use variables in a MySQL query

    hello my friends ...
    I have a problem during the creation of my site .. the idea is to use a PHP variable in a query Mysql. possible or not?! and how?
    thank you ...

  2. #2
    Join Date
    May 2008
    Posts
    2,302

    Re: Use variables in a MySQL query

    Hi,
    you can save your variables between single quotes if I remember correctly, style

    $ ta_variable = 'ab';

    "SELECT * FROM ta_base WHERE = '$ ta_variable"

  3. #3
    Join Date
    Apr 2009
    Posts
    79

    Re: Use variables in a MySQL query

    thank you, but you can do: $ ta_variable = $ _POST [ 'variable'];??

  4. #4
    Join Date
    May 2008
    Posts
    2,015

    Re: Use variables in a MySQL query

    Hi,
    If your variable has a form, you can directly integrate your $ _POST variable in the request for the concatenation in your application:

    mysql_query ( "UPDATE` `tabase. taTable` SET `tonChamp = '". $ variableChamp. "' WHERE tonChamp = '". $ _POST [' variable ']. "'") or die (mysql_error ());

Similar Threads

  1. MySQL query in a query
    By Rail racer in forum Software Development
    Replies: 3
    Last Post: 21-07-2009, 07:06 PM
  2. Turn on MySQL query cache to speed up query performance
    By DMA2Superman in forum Software Development
    Replies: 3
    Last Post: 07-07-2009, 10:26 AM
  3. MySQL Query Cache
    By Ryder in forum Software Development
    Replies: 3
    Last Post: 16-04-2009, 03:05 PM
  4. MySQL IF ELSE in Query
    By Ryder in forum Software Development
    Replies: 3
    Last Post: 27-03-2009, 05:24 PM
  5. Passing variables in SQL Query
    By Braze in forum Software Development
    Replies: 2
    Last Post: 01-01-2009, 07:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •