Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8327695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:12:11+00:00 2026-06-09T01:12:11+00:00

I’m trying to upload a form with an image using PHP to MySQL. I

  • 0

I’m trying to upload a form with an image using PHP to MySQL. I keep however, getting this error –

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/03/6455003/html/leakfaucet/submitAlbumForm.php on line 17

I’ve been staring at this one for quite a while now and just can’t figure out what the issue is, any help would be greatly appreciated!

Form-

<?php include "base.php"; ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 
Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Submit an Album</title>
</head>
<body>
<table>
  <tr>
    <td align="center">Submit an Album</td>
  </tr>
  <tr>
    <td>
      <table>
        <form enctype="multipart/form-data" action="submitAlbumForm.php" method="post">
        <tr>
          <td>Artist Name</td>
          <td><input type="text" name="artistName" size="20">
          </td>
        </tr>
        <tr>
          <td>Album Name</td>
          <td><input type="text" name="albumName" size="20">
          </td>
        </tr>
        <tr>
        <tr>
          <td>Release Date</td>
          <td><input type="text" name="releaseDate" size="20">
          </td>
        </tr>
        <tr>        
        <tr>
          <td>Leak Date</td>
          <td><input type="text" name="leakDate" size="20">
          </td>
        </tr>
        <tr>
        <tr>
          <td>Where It Leaked</td>
          <td><input type="text" name="whereItLeaked" size="20">
          </td>
        </tr>
        <tr>
        <tr>
          <td>Album Cover</td>
          <td><input type="file" name="albumCover">
          </td>
        </tr>
        <tr>        
          <td></td>
          <td align="right"><input type="submit" name="submit" value="Add"></td>
        </tr>
        </table>
      </td>
    </tr>
</table>
</body>
</html>

Upload script

<?php
include "base.php";

//Setting up images directory
 $target = "images/"; 
 $target = $target . basename( $_FILES['photo']['name']);

 $albumCover=($_FILES['photo']['name']); 

//inserting data order
$order = "INSERT INTO albums
            (artistName, albumName, releaseDate, leakDate, whereItLeaked, albumCover)
            VALUES
            ('$_POST[artistName]',
            '$_POST[albumName]',
            '$_POST[releaseDate]',
            '$_POST[leakDate]',
            '$_POST[whereItLeaked]',
            '($_FILES['albumCover']['name'])')";  /*this is the line where the error keeps occurring. I've tried a number of variations and still can't seem to get it right*/

  if(move_uploaded_file($_FILES['albumCover']['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"; 
 } 
 else { 

 //Gives an error if its not 
 echo "Sorry, there was a problem uploading your file."; 
 } 

//declare in the order variable
$result = mysql_query($order);  //order executes
if($result){
    echo("<br>Thank you for submitting!");
} else{
    echo("<br>Sorry, something went wrong! Please try again!");
}
?>

My base.php file with connect info

<?php
session_start();

$dbhost = "";
$dbname = "";
$dbuser = "";
$dbpass = "";

mysql_connect($dbhost, $dbuser, $dbpass) or die("MySQL Error: " . mysql_error());
mysql_select_db($dbname) or die("MySQL Error: " . mysql_error());
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T01:12:13+00:00Added an answer on June 9, 2026 at 1:12 am

    You cannot use quoted array keys in PHP double-quoted strings. It throws warnings. Plus, you cannot use multi-dimensional arrays as you are within double-quoted strings. PHP’s parser is not “greedy” and will only see a single level of array, e.g.

    $foo = array();
    $foo['bar'] = array();
    $foo['bar']['baz'] = 'fizzbuzz';
    echo "$foo['bar']['baz']";
    

    will issue a warning about the quoted keys, and the ouput would actually be:

    Array['baz']
    

    because the second level of array is not seen by PHP.

    You need to use the {} notation:

    '({$_FILES['albumCover']['name']})')";
      ^---                          ^---
    

    which both allows quoted array keys, and forces PHP to consider the ENTIRE array reference, not just the first level.

    Beyond that, your code is gaping wide open for SQL injection attacks, and you should read up and learn how to avoid those before you put this code on a public facing web-site, otherwise enjoy having your server pwn3d.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I am using Paperclip to handle profile photo uploads in my app. They upload
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.