PDA

View Full Version : PHP anyone?



Lovefist233
18-03-07, 18:25
OK, I don't know any php really so i'm really stuck here, I got this code from about.com and it is supposed to handle a file upload and a mysql insert (making a video blog) but I get \"parse error: unexpected T_VARIABLE in line 8\"

can anyone shed some light on this for me please?


<?php
//This is the directory where images will be saved

$target = \"video/\";
$target = $target . basename( $_FILES['video']['name']
//This gets all the other information from the form

$name = $_POST['title'];
$caption = $_POST['caption'];
$date = $_POST['date'];
$video = ($_FILES['video']['name']);
// Connects to your Database

mysql_connect(\"localhost\", \"admin\", \"password\") or die(mysql_error());
mysql_select_db(\"vlg_videoblog\") or die(mysql_error());
//Writes the information to the database

mysql_query(\"INSERT INTO `vlg_article_art` (title_art, caption_art, date_art, video_art)
VALUES ('$name', '$caption', '$date', '$video')\");

//Writes the photo to the server
if(move_uploaded_file($_FILES['video']['tmp_name'], $target)){
//Tells you if its all ok
echo \"The file \". basename( $_FILES['uploadedfile']['name']). \" has been uploaded, and your information has been added to the directory
<a href=\"index.php\">Back To Index</A>\"; }
else {
//Gives and error if its not
echo \"Sorry, there was a problem uploading your file. please <a href=\"post2.php\">Try Again</a>\";
}
?>
line 8, for you lazy ones is the line that starts with $name

Cheule
18-03-07, 23:42
Looks to me that first semicolon should be an opening square bracket.

Lovefist233
18-03-07, 23:45
thats a weird anomaly, it doesnt ook like that in dreamweaver the code tags have messed it all up, try it without the tags


//This is the directory where images will be saved

$target = \"video/\";
$target = $target . basename( $_FILES['video']['name']
//This gets all the other information from the form

$name = $_POST['title'];
$caption = $_POST['caption'];
$date = $_POST['date'];
$video = ($_FILES['video']['name']);
// Connects to your Database

mysql_connect(\"localhost\", \"admin\", \"password\") or die(mysql_error());
mysql_select_db(\"vlg_videoblog\") or die(mysql_error());
//Writes the information to the database

mysql_query(\"INSERT INTO `vlg_article_art` (title_art, caption_art, date_art, video_art)
VALUES ('$name', '$caption', '$date', '$video')\");

//Writes the photo to the server
if(move_uploaded_file($_FILES['video']['tmp_name'], $target)){
//Tells you if its all ok
echo \"The file \". basename( $_FILES['uploadedfile']['name']). \" has been uploaded, and your information has been added to the directory
<a href=\"index.php\">Back To Index</A>\"; }
else {
//Gives and error if its not
echo \"Sorry, there was a problem uploading your file. please <a href=\"post2.php\">Try Again</a>\";
}

Cheule
18-03-07, 23:47
[quote:57103c74fa=\"Cheule\"]Looks to me that first semicolon should be an opening square bracket.[/quote:57103c74fa]

EDIT, yup, it's wrong because you got it from another site. You need to replace all instances of aria91; with [

As for aria40; I'm not quite certain what that's supposed to represent. Needless to say, semicolons only appear at the end of a line and not anywhere in the middle, unless commented out.

Cheule
18-03-07, 23:49
Well for a start, line 2 should end with a closing bracket and semicolon.

Lovefist233
18-03-07, 23:51
thats probably it, cant test right now. damn i stared at that code for ages, this is why copying is bad for you. thanks guys