|
-
Jul 15th, 2002, 02:15 PM
#1
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.");
}
?>
-
Jul 15th, 2002, 02:30 PM
#2
Fanatic Member
how do I assign things to those variables? When i make a form to i set the submit button to the script?
-
Jul 15th, 2002, 03:26 PM
#3
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?
-
Jul 15th, 2002, 03:28 PM
#4
Fanatic Member
thanks, that's what i needed, i'm just storing the URL for the images so it should be fine
-
Jul 16th, 2002, 09:03 AM
#5
Fanatic Member
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>
Last edited by stickman373; Jul 16th, 2002 at 09:52 AM.
-
Jul 16th, 2002, 09:14 AM
#6
Fanatic Member
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']."')");
Last edited by cpradio; Jul 16th, 2002 at 10:01 AM.
-
Jul 16th, 2002, 09:23 AM
#7
Fanatic Member
now i get this:
Parse error: parse error in insert.php on line 6
-
Jul 16th, 2002, 09:24 AM
#8
Fanatic Member
I missed the quote at the very end right after the last .
-
Jul 16th, 2002, 09:33 AM
#9
Fanatic Member
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
-
Jul 16th, 2002, 09:33 AM
#10
Fanatic Member
sorry double post read above
Last edited by stickman373; Jul 16th, 2002 at 09:37 AM.
-
Jul 16th, 2002, 09:38 AM
#11
Fanatic Member
Try it again, a . (period) was missing.
-
Jul 16th, 2002, 09:50 AM
#12
-
Jul 16th, 2002, 10:01 AM
#13
Fanatic Member
put a parenthesis after the last '
-
Jul 16th, 2002, 10:13 AM
#14
Fanatic Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|