www.webdeveloper.com
Results 1 to 3 of 3

Thread: Parse error: syntax error, unexpected '.'

  1. #1
    Join Date
    Dec 2013
    Posts
    12

    Parse error: syntax error, unexpected '.'

    Hello Phpgurus

    please i am kinda confuse on where i went wron with the line. this is the html output for the link of a file i have on my server.

    <td>&nbsp;echo "<a href=" . uploads/ . basename($row_users['FILE']) . ">
    {$row_users['FILE']}</a>";</td>

    can you help me decode what the mistake is? i am waiting for a kind prompt response

    thanks
    sperox

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,241
    I think maybe you're trying to do something like this?
    PHP Code:
    echo "<a href='uploads/'" basename($row_users['FILE']) . "'>{$row_users['FILE']}</a>"
    Might be a good candidate for printf(), in order to avoid all that quoting/unquoting and concatenation headaches:
    PHP Code:
    printf(
        
    "<a href='uploads/%s'>%s</a>",
        
    basename($row_users['FILE']),
        
    $row_users['FILE']
    ); 
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Dec 2013
    Posts
    12
    hello Terry

    thanks a bunch! i tried it but only the directory uploads was viewable when i clicked. please review this php that does the . see if you can give the code for the right link

    <?php

    # -------------------------------------------------------------


    @$upload_Name = $_FILES['FILE']['name'];
    @$upload_Size = $_FILES['FILE']['size'];
    @$upload_Temp = $_FILES['FILE']['tmp_name'];
    @$upload_Mime_Type = $_FILES['FILE']['type'];

    function RecursiveMkdir($path)
    {
    if (!file_exists($path))
    {
    RecursiveMkdir(dirname($path));
    mkdir($path, 0777);
    }
    }


    // Validation
    // check only if file
    if( $upload_Size > 0)
    {

    if( $upload_Size == 0)
    {
    header("Location: error.html");
    exit;
    }
    if( $upload_Size >200000)
    {
    //delete file
    unlink($upload_Temp);
    header("Location: error.html");
    exit;
    }
    if( $upload_Mime_Type != "application/msword" AND $upload_Mime_Type != "application/pdf" AND $upload_Mime_Type != "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
    {
    unlink($upload_Temp);
    header("Location: error.html");
    exit;
    }
    $uploadFile = "uploads/".$upload_Name ;
    if (!is_dir(dirname($uploadFile)))
    {
    @RecursiveMkdir(dirname($uploadFile));
    }
    else
    {
    @chmod(dirname($uploadFile), 0777);
    }



    }//end wrapper of no file


    //Sending auto respond Email to user
    // Change email address
    require('edit-me-1.php');
    // Change subject title to be sent
    $pfw_subject = "Your Resume Has Been Sent";
    // DO NOT EDIT
    $pfw_email_to = "$from";
    // Change message to be sent
    $pfw_message = "The Resume you sent with an attachment has been zipped and sent!";
    @mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;


    $thank_you = "thanks.html";
    // Change to your email address
    require('edit-me-2.php');
    // Change subject to be sent to you
    $subject_prefix = "Resume Application - Warning, Watch For Attchements: ";



    // DO NOT EDIT BELOW THIS LINE ---------------------
    if (isset($_POST['SUBJECT'])) { $subject = $_POST['SUBJECT']; } else { $subject = $_POST['subject']; }
    if (isset($_POST['FROM'])) { $from = $_POST['FROM']; } else { $from = $_POST['from']; }
    if (isset($_POST['MESSAGE'])) { $message = $_POST['MESSAGE']; } else { $message = $_POST['message']; }

    foreach ($_POST as $key => $value) {
    if (strtolower($key) != 'subject' and strtolower($key) != 'message' and strtolower($key) != 'from' and strtolower($key) != 'file') {
    $message .= "\n\n$key: $value";
    }
    }


    $from = ereg_replace("(\r|\n)","",$from);
    if( !preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/", $from)) {
    die("Invalid Email Address!");
    }
    $subject = ereg_replace("(\r|\n)","",$subject);
    $mulmail = new multipartmail($mail_to, $from, $subject_prefix . $subject);
    if (is_uploaded_file($_FILES['FILE']['tmp_name'])) {
    $filename = $_FILES['FILE']['name'];
    include("uploader.php");
    $ziper = new zipfile();
    $ziper->addFile(fread(fopen($_FILES['FILE']['tmp_name'], "r"), $_FILES['FILE']['size']), $filename);
    $cid = $mulmail->addattachment($ziper->file(), "application/zip", $filename . '.zip');
    }
    $mulmail->addmessage($message . "\n");
    $mulmail->sendmail();
    header("location: " . $thank_you);


    class multipartmail{
    var $header;
    var $parts;
    var $message;
    var $subject;
    var $to_address;
    var $boundary;

    function multipartmail($dest, $src, $sub){
    $this->to_address = $dest;
    $this->subject = $sub;
    $this->parts = array("");
    $this->boundary = "------------" . md5(uniqid(time()));
    $this->header = "From: $src\r\n" .
    "MIME-Version: 1.0\r\n" .
    "Content-Type: multipart/related;\n" .
    " boundary=\"" . $this->boundary . "\"\r\n" .
    "X-Mailer: PHP/" . phpversion();
    }

    function addmessage($msg = "", $ctype = "text/plain"){
    $this->parts[0] = "Content-Type: $ctype; charset=ISO-8859-1\r\n" .
    "Content-Transfer-Encoding: 7bit\r\n" .
    "\n" . $msg;

    }

    function addattachment($data, $ctype, $fname){
    $i = count($this->parts);
    $content_id = "part$i." . sprintf("%09d", crc32($fname)) . strrchr($this->to_address, "@");
    $this->parts[$i] = "Content-Type: $ctype; name=\"$fname\"\r\n" .
    "Content-Transfer-Encoding: base64\r\n" .
    "Content-ID: <$content_id>\r\n" .
    "Content-Disposition: inline;\n" .
    " filename=\"$fname\"\r\n" .
    "\n" .
    chunk_split( base64_encode($data), 68, "\n");
    return $content_id;
    }

    function buildmessage(){
    $this->message = "This is a multipart message in mime format.\n";
    $cnt = count($this->parts);
    for($i=0; $i<$cnt; $i++){
    $this->message .= "--" . $this->boundary . "\n" .
    $this->parts[$i];
    }
    }


    function getmessage(){
    $this->buildmessage();
    return $this->message;
    }

    function sendmail(){
    $this->buildmessage();
    mail($this->to_address, $this->subject, $this->message, $this->header);
    }
    }


    @move_uploaded_file( $upload_Temp , $uploadFile);
    chmod($uploadFile, 0644);
    $upload_URL = "uploads/".$upload_Name ;
    (move_uploaded_file($_FILES['FILE']['tmp_name'], $uploadfile));
    $id=$_POST['id'];
    $name=$_POST['name'];
    $from=$_POST['from'];
    $gender=$_POST['gender'];
    $address=$_POST['address'];
    $lol=($_FILES['FILE']['name']);
    //Writes the information to the database
    mysql_connect("localhost", "", "") or die(mysql_error());
    mysql_select_db("") or die(mysql_error());
    mysql_query("INSERT INTO `users_cv` VALUES ('$id', '$name', '$from', '$gender', '$address', '$lol')");
    ?>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles