PHP Help?

Im trying to create a little webpage in html and php

but im getting and error

QuoteParse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\upload.php on line 3

For this script http://pastebin.com/ZJGT0Czi

Im trying to define the "map" variable in dropdown menu in a different page using the following code
http://pastebin.com/pY90Z5rb

can any help me getting the files uploaded to the folder defined in the dropdown menu?
Comments
22
line 2: $target = "map";
should i use something like $_GET ?
Parent
;;;;;;;;;;;;;;
Parent
for 2nd problem: you are using method="post" in form, which means the value of the select box will be in the $_POST array.

$_POST["map"] will have the content of that.
Parent
thx for your help
pls kill me for missing that ; :p

for some reason, the file isnt being uploaded to the folders i created

Quote<select name="map" size="1">
<option>C/</option>
<option>Computertechniek/</option>
<option>Databases en SQL/</option>
</select>

Quote
<?php
$target = $_post["map"];
$target = $target . basename($_FILES['uploaded']['name']);
$ok=1;
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ". basename($_FILES['uploaded']['name']). " has been uploaded";
}
else {
echo "Sorry, there was a problem uploading your file.";
}
?>
Parent
what filus said, it's $_POST not $_post.

Make sure the directory exists relative to the file executed
Parent
to give you a good advice, you should first check if there is some uploaded file before you try to access $_FILES variable.

And another problem, your select is outside your form so if you want to send a value of that select to server with it, move select before form closing tag.

EDIT: Another issue you can experience, you should set a value attribute on select options otherwise you wont have anything in $_POST['map'] variable
Parent
now im getting

Quote Undefined index: map


Im not learning php at school yet, but i cant wait
can you help me :<?

thx for your help so far btw

edit:

<select name="$map" size="1">
<option>C/</option>
<option>Computertechniek/</option>
<option>Databases en SQL/</option>
</select>
<form enctype="multipart/form-data" action="upload.php" method="POST">
Please choose a file: <input name="uploaded" type="file" /><br />
<input type="submit" value="Upload" />
</form>
Parent
<form enctype="multipart/form-data" action="upload.php" method="POST">
Please choose a file: <input name="uploaded" type="file" /><br />
<input type="submit" value="Upload" />
<select name="map" size="1">
<option>C/</option>
<option>Computertechniek/</option>
<option>Databases en SQL/</option>
</select>

</form>

thats what I ment by putting select into form, everything outside <form></form> will not be sent to server after submit.
Another thing is, you cant assing name of "$map" for inputs, leave it as it was ( name="map"). Your problem with $_POST['map'] not being assigned lies in smth else. As I said, you need to specify values for your options withing select. To give you an example:

<select name="map" size="1">
<option value="1">C/</option>
<option value="2">Computertechniek/</option>
<option value="3">Databases en SQL/</option>
</select>

will send to server variable "map" with value specified by selected option (so $_POST['map'] will hold a value in option). So, if you wont have attribute value present in options, it wont sent a value, thus variable is defacto not sent at all (if you specify value as value="" it will send empty string and variable will be set!! so, no value attribute = no variable, empty attribute = variable holding emptry string). Full example of your form would look like this:

<form enctype="multipart/form-data" action="upload.php" method="POST">
Please choose a file: <input name="uploaded" type="file" /><br />
<input type="submit" value="Upload" />
<select name="map" size="1">
<option value="C/">C/</option>
<option value="Computertechniek/">Computertechniek/</option>
<option value="Databases en SQL/">Databases en SQL/</option>
</select>
</form>

EDIT: or maybe I can be wrong about selects, I actually didnt test whether option with no value attribute is sending innerHtml as value or not (it seems kinda logical to me that no value does basically nothing, but seeing that attribute value is optional, I am not sure right now), but its always nice to follow good programming practices, it will save a lot of troubles in future.
Parent
the option didnt need a value as long as u use <option>C/</option> (foldername = c)
I already used
<option value="C/">C</option>
<option value="Computertechniek/">Computertechniek</option>
<option value="Databases en SQL/">Databases en SQL</option>
to make it look better
thx for your help, I guess I need to learn a lot more from tutorials etc before I start a new project
Parent
from my own experience, dont do things step by step from tutorials because most of the time its just about doing copy/paste. I prefer actually going into some project and discover things on the fly, at least thats the way I got into php (my first project was on high school, some simple chat after that few years nothing and then I "decided" to make e-shop for company I was working for :P ). And it will force to actually check some background and understand why some things are doing what they are doing and how they are doing it.
Parent
so what u say is, jump into a project, solve the problems by googling
Parent
thats the quickest way you are going to learn something
Parent
I got it working now
I mispasted the select(pasted it above the form)
Parent
you are missing semicolon on line 2 :D
semicolor? :XD is that some kind of half a color? :D

semicolon ;P
Parent
chosen answer seems explicit
we got a website for this: stackoverflow.com

not crossfire.
since this site (cf) is busy with retards such as this guys who wanna act cool by posting php for noobs, I'd say stackoverflow doesn't need shit threads like that anymore.

oh sorry BM
Parent
You forgotted ; from string end.
You could use class...
http://genert.impact.pri.ee/upload.phps
"SYNTAX ERROR" used to get that on my calculator in 12. and 13th class, and everytime some1 had this error he screamed through class "SYNTAX ERROR"
I found, I found it!

Quotebut im getting and error
Back to top