hi i have this page for loading the projects for a current user if that user is admin it displays all the projects in a table thats fine
i aslso wanted a button to show up for admin to upload a new file but i get
"Parse error: syntax error, unexpected '<' in /Applications/MAMP/htdocs/Project/login_success.php on line 40"
heres line 40

echo <input name="Upload" type="button" id="Upload" onClick="document.location.href='/Project/Upload.html';" value="Upload New File">

and here is all the code

<? 
session_start();
if(!session_is_registered(myusername)){
header("location:main_login.php");
}
?>
<html>
<body>
Login Successful
<div id="welcome"><span class="welcomeHead">
Welome, <?= $_SESSION['myusername'] ?>.</span><br />
</body>
</html>
<html><head><title>Current Projects for <?= $_SESSION['myusername'] ?></title>
<style type="text/css">
<!--
@import url("csstable.css");
-->
</style>
</head><body>
<?php
$db_host = 'localhost';
$db_user = 'root';
$db_pwd = 'root';

$database = 'test';
$table = 'uploads';

if (!mysql_connect($db_host, $db_user, $db_pwd))
die("Can't connect to database");

if (!mysql_select_db($database))
die("Can't select database");

// sending query


// If current logged in user is admin show all user info from the database....
if (strtolower($_SESSION['myusername'])=='admin'){
	echo <input name="Upload" type="button" id="Upload" onClick="document.location.href='/Project/Upload.html';" value="Upload New File">
$result = mysql_query("SELECT id, filename, filesize, filetype, username   FROM $table");
}
else {
// If not an admin, display info for the current user only...
$result = mysql_query("SELECT id, filename, filesize, filetype, username FROM $table WHERE username = '" . mysql_real_escape_string($_SESSION['myusername']) . "'");
}  
if (!$result) {
die("Query to show fields from table failed");
}

$fields_num = mysql_num_fields($result);

echo "<h1>Table: {$table}</h1>";
echo "<table border='1'><tr>";
// printing table headers
for($i=0; $i<$fields_num; $i++)
{
$field = mysql_fetch_field($result);
echo "<td><b><u>{$field->name}</td>";
}
echo "</tr>\n";
// printing table rows
while($row = mysql_fetch_row($result))
{
echo "<tr>";

// $row is array... foreach( .. ) puts every element
// of $row to $cell variable
foreach($row as $cell)
echo "<td>$cell</td>";

echo "</tr>\n";
}
mysql_free_result($result);
?>

</body></html>

any ideas

thanks

Try and replace your echo statement with the following:

echo '<input name="Upload" type="button" id="Upload" onClick="document.location.href=\'/Project/Upload.html\';" value="Upload New File">';

You forgot to add the quotes and return symbol as corrected in the above script.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.