By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,052 Members | 1,249 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,052 IT Pros & Developers. It's quick & easy.

associate user account with filename

P: n/a
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>

Sep 14 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
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
Sep 14 '07 #2

P: n/a
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!
Sep 14 '07 #3

P: n/a
On Sep 14, 3:23 pm, Anonymous <anonym...@nowhere.invalidwrote:
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

Sep 14 '07 #4

P: n/a
On Sep 14, 8:20 am, Reggie <joelregisfo...@hotmail.comwrote:
>
Where did i miss a semicolon.I cant see it.Am new to PHP
Little things like that happen all to often - to all of us. :-)

Sep 14 '07 #5

P: n/a
On 14 Sep, 16:20, Reggie <joelregisfo...@hotmail.comwrote:
On Sep 14, 3:23 pm, Anonymous <anonym...@nowhere.invalidwrote:


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.

Sep 14 '07 #6

P: n/a
Reggie wrote:
>
On Sep 14, 3:23 pm, Anonymous <anonym...@nowhere.invalidwrote:
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']) <-
Sep 14 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.