-
do waht you have but just make things to a varialbe. if you are getting those from a form then it would look like this. I wouldn't put the image in the DB as that will make it big fast, jut put the path in it or the name
PHP Code:
<?php
$connection = mysql_connect ("localhost","stickman373","******");
mysql_select_db("stickman373_uk_db");
$result = mysql_query("INSERT INTO dvd (Title,Review,Image,Other) VALUES ('".$_REQUEST['Title']."','".$_REQUEST['Review']."','".$_REQUEST['image_name']."','"$_REQUEST['other']."' )
");
if(!result)
{
echo "INSERT unsuccessful: ", mysql_error();
exit;
}
else
{
print ("Thanks for submitting details.");
}
?>
-
how do I assign things to those variables? When i make a form to i set the submit button to the script?
-
easy, that is regular html. either you have it on the same page or on a different page it is all the same.
<form action="yourpage.php" method="post">
<input type=text name=Title>
<textarea name=Review rows="6" cols="30"></textarea>
<input type=text name=image>
<input type=text name=Other>
<input type=submit name=send value="Send Review">
</form>
the only problem is that if you want to upload an image you will have to add things to the form tag so you can. then you have to hve an upload script in your regular script.
see the name of each input? that is th evariable name you use on the $_REQUEST[] variable. make since?
-
thanks, that's what i needed, i'm just storing the URL for the images so it should be fine
-
i'm getting an error with the script
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in insert.php on line 6
PHP Code:
<?php
$connection = mysql_connect ("localhost","stickman373","******");
mysql_select_db("stickman373_uk_db");
mysql_query("INSERT INTO dvd (Title,Review,Image,Other) VALUES ('.$_REQUEST['Title'].','.$_REQUEST['Review'].','.$_REQUEST['image'].','$_REQUEST['other'].' );
echo mysql_error();
?>
calling it with this html on a different page
<form action="insert.php" method="post">
<input type=text name=Title>
<textarea name=Review rows="6" cols="30"></textarea>
<input type=text name=image>
<input type=text name=Other>
<input type=submit name=send value="Send Review">
</form>
-
you forgot the double quotes in this statement:
PHP Code:
mysql_query("INSERT INTO dvd (Title,Review,Image,Other) VALUES ('".$_REQUEST['Title']."',
'".$_REQUEST['Review']."','".$_REQUEST['image']."','".$_REQUEST['other']."')");
-
now i get this:
Parse error: parse error in insert.php on line 6
-
I missed the quote at the very end right after the last .
-
you edited the code in you post above right? i tried it again and i still get Parse error: parse error in insert.php on line 6 what am i doing wrong :(
-
sorry double post read above ;)
-
Try it again, a . (period) was missing.
-
almost there, what is wrong on line 1 ;)
You have an error in your SQL syntax near '' at line 1 :(
-
put a parenthesis after the last '
-