Results 1 to 6 of 6

Thread: PHP anyone?

  1. #1
    Veteran
    Join Date
    May 2006
    Location
    Wales
    Posts
    151
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    1

    Default PHP anyone?

    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?

    Code:
    <?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

  2. #2
    Veteran Cheule's Avatar
    Join Date
    Feb 2007
    Location
    UK
    Posts
    218
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    1

    Default

    Looks to me that first semicolon should be an opening square bracket.

  3. #3
    Veteran
    Join Date
    May 2006
    Location
    Wales
    Posts
    151
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    1

    Default

    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>\";
    }

  4. #4
    Veteran Cheule's Avatar
    Join Date
    Feb 2007
    Location
    UK
    Posts
    218
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    1

    Default Re:

    [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.

  5. #5
    Veteran Cheule's Avatar
    Join Date
    Feb 2007
    Location
    UK
    Posts
    218
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    1

    Default

    Well for a start, line 2 should end with a closing bracket and semicolon.

  6. #6
    Veteran
    Join Date
    May 2006
    Location
    Wales
    Posts
    151
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    1

    Default

    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

Posting Permissions

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