Results 1 to 4 of 4

Thread: asp with mysql

  1. #1
    Join Date
    Dec 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default asp with mysql

    How to insert a records from a text field into a mysql database table in asp.
    What is the coding for insert records from text field into a mysql database table in asp.

    Is my sql switable for asp.

    I make a coding for insert a record in a database table from text field in asp given as followes
    After compilation server gives some error.


    <%@ Language=VBScript %>

    <%

    Dim objConn
    Set objConn = Server.CreateObject("ADODB.Connection")
    objConn.ConnectionString="DSN=sharp.dsn"
    objConn.open
    category_name=Request.Form("category")
    classified=Request.Form("classified")
    name=Request.Form("company")
    location=Request.Form("location")
    country=Request.Form("country")
    website=Request.Form("website")
    contact_no=Request.Form("contact_no")

    mySQL=" Insert into order_details(category_name,classified,name,locati on,country,website,contact_no) values('"& category_name &"','"& classified &"','"& Name &"','"& location &"','"& country &"','"& website &"','"& contact_no &"')"

    Set RS = objConn.Execute(mySQL)


    %>

  2. #2
    Join Date
    Mar 2005
    Location
    Isle of Man
    Posts
    1,261
    Thanks
    3
    Thanked 24 Times in 24 Posts

    Default

    there appears to be a space in the first instance of the word location (the field name). so try:
    Code:
    mySQL="	INSERT INTO order_details
    			(	category_name,
    				classified,
    				name,
    				location,
    				country,
    				website,
    				contact_no	)
    		VALUES
    			(	'"& category_name &"',
    				'"& classified &"',
    				'"& Name &"',
    				'"& location &"',
    				'"& country &"',
    				'"& website &"',
    				'"& contact_no &"'	);"
    Is the contact_no field definitiely a string in mysql rather than a integer? If it was a number you would want to loose the quotes around it I would think.
    Code:
        '"& website &"',
        "& contact_no &"	);"
    Warn you now though, I'm not an ASP man, so I might be missing something obvious that is specific to that. Also, I hope you are escaping/validating the user input before the variables go into the SQL.

  3. #3
    Join Date
    Sep 2005
    Posts
    190
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    "locati on" may cause you a problem.

  4. #4
    Join Date
    Sep 2005
    Posts
    190
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Sorry, Nick had already suggested that... Didn't spot his much more detialed reply...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. ASP/MYSQL Forum
    By devworld in forum Forum/Community Applications
    Replies: 11
    Last Post: 1st March 2008, 11:18 PM
  2. MySQL Connect String for ASP
    By holivar in forum ASP (VBScript)
    Replies: 16
    Last Post: 25th April 2006, 08:17 AM
  3. asp.net connection to mysql
    By keyur_ptl in forum ASP.NET
    Replies: 1
    Last Post: 27th January 2006, 11:26 AM
  4. ASP.NET 2 connection to MySQL
    By captain in forum ASP.NET
    Replies: 4
    Last Post: 27th December 2005, 07:07 PM
  5. asp mysql commands
    By slippers in forum Technical Support
    Replies: 4
    Last Post: 28th November 2005, 08:39 PM

Bookmarks

Posting Permissions

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