Page 1 of 1

Parse error: syntax error, unexpected '=' in on line 23

Posted: Sun Feb 18, 2007 3:01 pm
by chaser7016
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I receive the following above error when using the code below.....

Code: Select all

<html>
<head>
<title>Download File From MySQL</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php
include 'config.php';
include 'opendb.php';

$query = "SELECT id, name FROM upload";
$result = mysql_query($query) or die('Error, query failed');
if(mysql_num_rows($result) == 0)
{
echo "Database is empty <br>";
}
else
{
while(list($id, $name) = mysql_fetch_array($result))
{
?>
<a href="download.php?id=<?php=$id;?>"><?php=$name;?></a> <br>   /// < -- THIS IS LINE 23
<?php
}
}
include 'closedb.php';
?>
</body>
</html>
<?php
if(isset($_GET['id']))
{
// if id is set then get the file with the id from database

include 'config.php';
include 'opendb.php';

$id    = $_GET['id'];
$query = "SELECT name, type, size, content " .
         "FROM upload WHERE id = '$id'";

$result = mysql_query($query) or die('Error, query failed');
list($name, $type, $size, $content) =                                  mysql_fetch_array($result);

header("Content-length: $size");
header("Content-type: $type");
header("Content-Disposition: attachment; filename=$name");
echo $content;

include 'closedb.php';
exit;
}

?>
Thanks to anyone who can help! Im a newbie, but very eager to learn.

Cheers, Chaser


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Sun Feb 18, 2007 4:30 pm
by feyd
<?php= is not valid.

Why do you insist on not using the highlighting tags?

Posted: Sun Feb 18, 2007 4:37 pm
by Kieran Huggins
as far as I know you can't use echo shorthand with long open tags

Code: Select all

//use either: 
<?php echo $id;?> 
//or:
<?=$id;?>