View Full Version : Insert function Problem

11-15-2011, 07:13 AM
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">
----------------------- code for insert function ----------------------
$query = "INSERT INTO product (image, desc, title) VALUES ('$filePath', '$desc', '$titley') ";

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

11-15-2011, 08:09 AM
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']."','')";

11-16-2011, 10:47 PM
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