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 6 of 6
  1. #1
    New Coder
    Join Date
    Jul 2010
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Mysql insert with php not working

    Trying to insert an ALBUM but not working. Please help me .


    $hostname ="localhost";
    $password ="";
    $username ="root";
    $CON =mysql_connect ($hostname, $username, $password) ;
    mysql_select_db("reggaedbf", $CON);
    $ALBUMCOD = 5;
    $ALBUMNAM =mysql_real_escape_string( $_POST['ALBUMNAM'] );
    $IMAGEURL =mysql_real_escape_string( $_POST['IMAGEURL'] );
    $SQLALBUM =" INSERT INTO ALBUM
    VALUES ('$ALBUMCOD',
    '$ALBUMNAM',
    '$IMAGEURL') ";
    $RESULTS = mysql_query( $SQLALBUM, $CON );

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,978
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Change the query to this: $RESULTS = mysql_query( $SQLALBUM, $CON ) or die(mysql_error($CON)); and post the error.
    Also, you should look at using mysqli as the mysql library won't be around much longer.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    Regular Coder LearningCoder's Avatar
    Join Date
    Jan 2011
    Location
    The Pleiades
    Posts
    912
    Thanks
    76
    Thanked 28 Times in 28 Posts
    Potential typo? mysql_real_escape_string( $_POST['ALBUMNAM'] );

    Should it be:
    mysql_real_escape_string( $_POST['ALBUMNAME'] );?

    Regards,

    LC.

  • #4
    New Coder
    Join Date
    Jul 2010
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts
    no it is correct ALBUMNAM

  • #5
    Regular Coder LearningCoder's Avatar
    Join Date
    Jan 2011
    Location
    The Pleiades
    Posts
    912
    Thanks
    76
    Thanked 28 Times in 28 Posts
    Ah I see, did you do what Fou said?

    Kind regards,

    LC.

  • #6
    New Coder
    Join Date
    Jul 2010
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts
    it is working I forgot to put hidden variable


    <input type="HIDDEN" name="COMMAND" value="APPEND">
    in my form to call THE INSERT ROUTINE


  •  

    Posting Permissions

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