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
    New Coder
    Join Date
    Nov 2011
    Posts
    64
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Insert function Problem

    So I'm just trying to write basic insert function, I mess stuff up all the time, I have no idea what's wrong with the way I'm putting it in, any help would be sweeeeeet.


    --------------------- final failed php insert function ---------------------

    INSERT INTO product ( image, desc, title) VALUES ('prodimage/817283_P10_H_CH20000_1.jpg', 'does good things', 'gear')

    -------------------------- form ------------------------------
    <form action="" enctype="multipart/form-data" method="POST">
    <input type="text" name="titley" /><br />
    <textarea name="desc"></textarea><br />
    <INPUT type="file" name="Photo" size="2000000" accept="image/gif, image/jpeg, image/x-ms-bmp, image/x-png" size="4px" /><br/>
    <INPUT type="submit" class="button" name="Submit" value=" Submit">
    &nbsp;&nbsp;<INPUT type="reset" class="button" value="Cancel">
    </form>
    ----------------------- code for insert function ----------------------
    $query = "INSERT INTO product (image, desc, title) VALUES ('$filePath', '$desc', '$titley') ";

    mysql_query($query) or die($query);

  • #2
    New to the CF scene
    Join Date
    Nov 2011
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts
    say we have three boxes in our file :

    <input type="text" name="user_name">
    <input type="password" name="password">
    <input type="text" name="name">
    <input type="text" name="age">

    and want these values to be inserted into database

    then we will do :


    $insert = "INSERT INTO product(user_name,password,name,age)
    VALUES ('".$_POST['user_name']."', '".$_POST['password']."','','".$_POST['name']."','".$_POST['age']."','')";

  • #3
    New Coder
    Join Date
    Nov 2011
    Posts
    64
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Solved

    Thanks, I thought I had done it right, but instead of sql error, I went and printed the $query to see what was wrong, thanks for the time


  •  

    Posting Permissions

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