|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 (permalink) |
|
Messages: n/a
Hébergeur: |
am trying to associate username with filename in a upload script.
I get this error: Parse error: syntax error, unexpected T_STRING in /home/fhlinux169/c/ clashoff.co.uk/user/htdocs/upload.php on line 42 This is my script any ideas.Am really stuck. <?php $host=""; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name=""; // Database name $tbl_name=""; // Table name $target = ""; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; //This is our size condition $upload_size = $_FILES['uploaded']['size']; if ($upload_size > 1000000000000) { echo "Your file is too large.<br>"; $ok=0; } //This is our limit file type condition $upload_type = $_FILES['uploaded']['type']; if ($upload_type =="text/php") { echo "No PHP files<br>"; $ok=0; } //Here we check that $ok was not set to 0 by an error if ($ok==0) { Echo "Sorry your file was not uploaded"; } //If everything is ok we try to upload it else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploaded']['name']). " has been uploaded"; $myfilename=basename( $_FILES['uploaded']['name']) mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="update $tbl_name set filename = '$myfilename' WHERE username='session_is_registered('myusername')' "; mysql_query($sql); } else { echo "Sorry, there was a problem uploading your file."; } } ?> <html> <body> <a href="/user.php">Return to User Page</a> </form> </body> </html> |
|
|
|
#2 (permalink) |
|
Messages: n/a
Hébergeur: |
On 14.09.2007 14:21 Reggie wrote:
> am trying to associate username with filename in a upload script. > > > I get this error: > Parse error: syntax error, unexpected T_STRING in /home/fhlinux169/c/ > clashoff.co.uk/user/htdocs/upload.php on line 42 > > This is my script any ideas.Am really stuck. The error has nothing to do with your actual problem. It's just a parsing error, you're missing the comma or something like this. Check line 42 of your script. -- gosha bine makrell ~ http://www.tagarga.com/blok/makrell php done right http://code.google.com/p/pihipi |
|
|
|
#3 (permalink) |
|
Messages: n/a
Hébergeur: |
Reggie wrote:
> > am trying to associate username with filename in a upload script. > > I get this error: > Parse error: syntax error, unexpected T_STRING in /home/fhlinux169/c/ > clashoff.co.uk/user/htdocs/upload.php on line 42 Why don't you just look at line 42 then? > $myfilename=basename( $_FILES['uploaded']['name']) > > mysql_connect("$host", "$username", "$password")or die("cannot > connect"); Pretty obvious, you missed a semicolon in the line above 42. Bye! |
|
|
|
#4 (permalink) |
|
Messages: n/a
Hébergeur: |
On Sep 14, 3:23 pm, Anonymous <anonym...@nowhere.invalid> wrote:
> Reggie wrote: > > > am trying to associate username with filename in a upload script. > > > I get this error: > > Parse error: syntax error, unexpected T_STRING in /home/fhlinux169/c/ > > clashoff.co.uk/user/htdocs/upload.php on line 42 > > Why don't you just look at line 42 then? > > > $myfilename=basename( $_FILES['uploaded']['name']) > > > mysql_connect("$host", "$username", "$password")or die("cannot > > connect"); > > Pretty obvious, you missed a semicolon in the line above 42. > > Bye! Where did i miss a semicolon.I cant see it.Am new to PHP |
|
|
|
#6 (permalink) |
|
Messages: n/a
Hébergeur: |
On 14 Sep, 16:20, Reggie <joelregisfo...@hotmail.com> wrote:
> On Sep 14, 3:23 pm, Anonymous <anonym...@nowhere.invalid> wrote: > > > > > > > Reggie wrote: > > > > am trying to associate username with filename in a upload script. > > > > I get this error: > > > Parse error: syntax error, unexpected T_STRING in /home/fhlinux169/c/ > > > clashoff.co.uk/user/htdocs/upload.php on line 42 > > > Why don't you just look at line 42 then? > > > > $myfilename=basename( $_FILES['uploaded']['name']) > > > > mysql_connect("$host", "$username", "$password")or die("cannot > > > connect"); > > > Pretty obvious, you missed a semicolon in the line above 42. > > > Bye! > > Where did i miss a semicolon.I cant see it.Am new to PHP- Hide quoted text - > > - Show quoted text - Of course you can't see it, it's not there! that is what missing means. Look at line 41, it has no semicolon, so php carries on reading to line 42 and finds a string, when by now it should have had a semicolon. |
|
|
|
#7 (permalink) |
|
Messages: n/a
Hébergeur: |
Reggie wrote:
> > On Sep 14, 3:23 pm, Anonymous <anonym...@nowhere.invalid> wrote: > > Reggie wrote: > > > > > am trying to associate username with filename in a upload script. > > > > > I get this error: > > > Parse error: syntax error, unexpected T_STRING in /home/fhlinux169/c/ > > > clashoff.co.uk/user/htdocs/upload.php on line 42 > > > > Why don't you just look at line 42 then? > > > > > $myfilename=basename( $_FILES['uploaded']['name']) > > > > > mysql_connect("$host", "$username", "$password")or die("cannot > > > connect"); > > > > Pretty obvious, you missed a semicolon in the line above 42. > > > > Bye! > > Where did i miss a semicolon.I cant see it.Am new to PHP You missed it here: $myfilename=basename( $_FILES['uploaded']['name']) <- |
|
![]() |
| Outils de la discussion | |
|
|