#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    19
    Rep Power
    0
    i want to add a record in a table but
    through a varible
    mysql_query( &mysql, "INSERT INTO tablename(acctnbr, amount) VALUES (12345, 651.30)" );

    i want to pass the value of acctnbr and amount through veriables how can i do it ?
    thanks....
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    In PHP:

    $result=mysql_query("insert into tablename (acctnbr,amount) values ($acctnbr,$amount)");

  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    19
    Rep Power
    0
    i want to know about c coding not for php
    to pass a veriable in mysql_query function.
    thanks...
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    1
    Rep Power
    0
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by abbas:
    i want to know about c coding not for php
    to pass a veriable in mysql_query function.
    thanks...
    [/quote]

    this should work

    String query,acctnbr,amount;

    accntnbr = [(whatever the variable is)];
    amount = [(whatever the variable is)];

    query = "insert into tablename (acctnbr,amount) values (%s,%s)",acctnbr,amount);
    mysql_query(&mysql,query);
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    19
    Rep Power
    0
    error:
    String not allow to compile
    if i use
    char accout[30]
    and use your formate then not happen any thing after run the program.
    thanks
    please review your query is it right?

Similar Threads

  1. Replies: 1
    Last Post: August 30th, 2003, 10:39 PM
  2. How to pass a php variable to exec()
    By achandak in forum PHP Development
    Replies: 15
    Last Post: June 24th, 2003, 04:12 PM
  3. not to use form to pass variable
    By andy81 in forum PHP Development
    Replies: 2
    Last Post: September 5th, 2002, 01:01 AM
  4. Creating pop-up window and pass variable to it
    By Sharapov in forum PHP Development
    Replies: 1
    Last Post: June 4th, 2002, 07:06 PM
  5. Replies: 6
    Last Post: January 7th, 2002, 04:40 AM

IMN logo majestic logo threadwatch logo seochat tools logo