Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Sep 2010
    Posts
    124
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Insert into table problem

    hi i have question to insert record in to the table

    this size is with 12" like this

    $sqlstr = "INSERT INTO Cost_Tyre(internal,size,blackatb,blackbmx,whiteatb,whitebmx,ww,reflective,tyre_date,Tyre) VALUES('$internal','$size1','$blackatb','$blackbmx','$whiteatb','$whitebmx','$ww','$reflective','$ty re_date','$Tyre')" ;

    echo $sqlstr;



    $result1 = mysql_query($sqlstr);

    when the print the result it shows

    INSERT INTO Cost_Tyre(internal,size,blackatb,blackbmx,whiteatb,whitebmx,ww,reflective,tyre_date,Tyre,tyre_date) VALUES('11','12" ','4.24','','5.20','5.20','4.60','6.04','2011-09-01','2.46','2011-09-01')

    hear my problem is data is not inserting to the table


    plz help me to slove this problem

    plzzzzzzz give me a sample code

  • #2
    Banned
    Join Date
    Apr 2011
    Posts
    656
    Thanks
    14
    Thanked 69 Times in 69 Posts
    Have a look at your quotes and commas. There is a mismatch there.

  • #3
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    There might also be a problem in that he's inserting a null value. You have no error reporting here at all for the MySQL. mysql_query() will not return a result for an INSERT query, or update query or basically anything that doesn't expect a result from the table. It will, however, return a true or false depending on whether the query was successful or not. To error report correctly, you should change your line to a static call with an 'or die' statement:
    PHP Code:
    mysql_query($query) or die(mysql_error()); 
    The 'or die()' might not be your desired option, but it will kill the code at that point if there's a problem which makes it favourable (for me anyway) for debugging.


  •  

    Posting Permissions

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