Note that there are some explanatory texts on larger screens.

plurals
  1. POuploading form and image with php to mysql odd error
    primarykey
    data
    text
    <p>I'm trying to upload a form with an image using PHP to MySQL. I keep however, getting this error - </p> <pre><code>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 </code></pre> <p>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!</p> <p>Form-</p> <pre><code>&lt;?php include "base.php"; ?&gt; &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Submit an Album&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;table&gt; &lt;tr&gt; &lt;td align="center"&gt;Submit an Album&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;table&gt; &lt;form enctype="multipart/form-data" action="submitAlbumForm.php" method="post"&gt; &lt;tr&gt; &lt;td&gt;Artist Name&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="artistName" size="20"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Album Name&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="albumName" size="20"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;tr&gt; &lt;td&gt;Release Date&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="releaseDate" size="20"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;tr&gt; &lt;td&gt;Leak Date&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="leakDate" size="20"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;tr&gt; &lt;td&gt;Where It Leaked&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="whereItLeaked" size="20"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;tr&gt; &lt;td&gt;Album Cover&lt;/td&gt; &lt;td&gt;&lt;input type="file" name="albumCover"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;/td&gt; &lt;td align="right"&gt;&lt;input type="submit" name="submit" value="Add"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Upload script</p> <pre><code>&lt;?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("&lt;br&gt;Thank you for submitting!"); } else{ echo("&lt;br&gt;Sorry, something went wrong! Please try again!"); } ?&gt; </code></pre> <p>My base.php file with connect info</p> <pre><code>&lt;?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()); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload