Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Problem with query

Problem with query

Scheduled Pinned Locked Moved Database
databasehelpmysqlquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gregarion
    wrote on last edited by
    #1

    Hey guys I want to insert values into a MySql database. The following line works fine:

    mysql_query(connection, "INSERT INTO main (NumofShows , Title) VALUES('12', 'Home')");

    What i would like to do is instead of having to hardcore the inserted values into the querty, i would like it to read from a variable. For exmaple the data to be inserted is from a string... like....

    string NewTitle = "Monaco";
    string NumofShows = "2";

    How do i edit my sql statements so variables can be inserted into the Insert statement so the query will read the variables and then store their values in the database. Really need some help in this

    L 1 Reply Last reply
    0
    • G gregarion

      Hey guys I want to insert values into a MySql database. The following line works fine:

      mysql_query(connection, "INSERT INTO main (NumofShows , Title) VALUES('12', 'Home')");

      What i would like to do is instead of having to hardcore the inserted values into the querty, i would like it to read from a variable. For exmaple the data to be inserted is from a string... like....

      string NewTitle = "Monaco";
      string NumofShows = "2";

      How do i edit my sql statements so variables can be inserted into the Insert statement so the query will read the variables and then store their values in the database. Really need some help in this

      L Offline
      L Offline
      loyal ginger
      wrote on last edited by
      #2

      Use a parameters with the command object so you don't hard code values in the SQL statement.

      G 1 Reply Last reply
      0
      • L loyal ginger

        Use a parameters with the command object so you don't hard code values in the SQL statement.

        G Offline
        G Offline
        gregarion
        wrote on last edited by
        #3

        Im not sure what you mean. Could u edit my example to show me what you mean?

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups