I am new to PHP/MYSQL so decieded to follow 1 of the tuorials. i worked through the tutorial and uploaded the files but unfortunatly it didnt work and just delivered the below error msg
Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/www/dataEPHE/news.php on line 17
so i decieded to go and look at line 17 in the php file but it was blank.
i would really appreciate if some 1 could suggest what i may have done wrong or look over the code i have to c how i could get it to work
need help with a Simple news driven sites
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
code
<html>
<title>test</title>
</head>
<body>
<?php
$db=mysql_connect("localhost","username","password") or die ("cant connect");
mysql_select_db("database",$db) or die ("cant change");
$news=mysql_query("select * from news ORDER BY date DESC LIMIT 8") or die ("cant get em");
while($rows=mysql_fetch_array($news)){
$date=date("F d, Y H:i ",$rows["date"]);
$author=$rows["author"];
$number="100%";
printf("<table cellpadding=2 cellspacing=0 border=0 width=%s>\n",$number);
echo "<td bgcolor=#496CB1 class='first'><b>$title</b></td>\n";
echo "<td align=right bgcolor=#496CB1 class='first'>$date</td><tr>\n";
echo "<td colspan=2><i>by <A href=\\"mailto:$email\\">$author</a></i>
$content</td></table><p>\n";
}
while($rows=mysql_fetch_array($news)){
$date=date("F d, Y H:i ",$rows["date"]);
$author=$rows["author"];
$number="100%";
printf("<table cellpadding=2 cellspacing=0 border=0 width=%s>\n",$number);
echo "<td bgcolor=#496CB1 class='first'><b>$title</b></td>\n";
echo "<td align=right bgcolor=#496CB1 class='first'>$date</td><tr>\n";
echo "<td colspan=2><i>by <A href=\\"mailto:$email\\">$author</a></i>
$content</td></table><p>\n";
}
?>
</body>
</html>
ok it is only a short document so i have posted it all
<title>test</title>
</head>
<body>
<?php
$db=mysql_connect("localhost","username","password") or die ("cant connect");
mysql_select_db("database",$db) or die ("cant change");
$news=mysql_query("select * from news ORDER BY date DESC LIMIT 8") or die ("cant get em");
while($rows=mysql_fetch_array($news)){
$date=date("F d, Y H:i ",$rows["date"]);
$author=$rows["author"];
$number="100%";
printf("<table cellpadding=2 cellspacing=0 border=0 width=%s>\n",$number);
echo "<td bgcolor=#496CB1 class='first'><b>$title</b></td>\n";
echo "<td align=right bgcolor=#496CB1 class='first'>$date</td><tr>\n";
echo "<td colspan=2><i>by <A href=\\"mailto:$email\\">$author</a></i>
$content</td></table><p>\n";
}
while($rows=mysql_fetch_array($news)){
$date=date("F d, Y H:i ",$rows["date"]);
$author=$rows["author"];
$number="100%";
printf("<table cellpadding=2 cellspacing=0 border=0 width=%s>\n",$number);
echo "<td bgcolor=#496CB1 class='first'><b>$title</b></td>\n";
echo "<td align=right bgcolor=#496CB1 class='first'>$date</td><tr>\n";
echo "<td colspan=2><i>by <A href=\\"mailto:$email\\">$author</a></i>
$content</td></table><p>\n";
}
?>
</body>
</html>
ok it is only a short document so i have posted it all
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
The problem is occuring because of the
bit, if you change that to:
it should get rid of the parse error.
I think that you probably only need one while loop as well, so delete the second:
Mac
Code: Select all
A href="e;mailto:$email"e;>Code: Select all
A href="mailto:$email">I think that you probably only need one while loop as well, so delete the second:
Code: Select all
while($rows=mysql_fetch_array($news)){
$date=date("F d, Y H:i ",$rowsї"date"]);
$author=$rowsї"author"];
$number="100%";
printf("<table cellpadding=2 cellspacing=0 border=0 width=%s>\n",$number);
echo "<td bgcolor=#496CB1 class='first'><b>$title</b></td>\n";
echo "<td align=right bgcolor=#496CB1 class='first'>$date</td><tr>\n";
echo "<td colspan=2><i>by <A href="e;mailto:$email"e;>$author</a></i>
$content</td></table><p>\n";
}the below error msg is still occuring when i veiw the page
Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/www/dataEPHE/news.php on line 17
i have changed what u have suggest and the code that i am now using looks like this
<html>
<title>test</title>
</head>
<body>
<?php
$db=mysql_connect("localhost","username","password") or die ("cant connect");
mysql_select_db("database",$db) or die ("cant change");
$news=mysql_query("select * from news ORDER BY date DESC LIMIT 8") or die ("cant get em");
while($rows=mysql_fetch_array($news)){
$date=date("F d, Y H:i ",$rows["date"]);
$author=$rows["author"];
$number="100%";
printf("<table cellpadding=2 cellspacing=0 border=0 width=%s>\n",$number);
echo "<td bgcolor=#496CB1 class='first'><b>$title</b></td>\n";
echo "<td align=right bgcolor=#496CB1 class='first'>$date</td><tr>\n";
echo "<td colspan=2><i>by <A href=\\"mailto:$email\">$author</a></i>
$content</td></table><p>\n";
}
?>
</body>
</html>
is this what u meant for me 2 do? if so can u think of ne other reasons i may be having this problem
thx for your help
Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/www/dataEPHE/news.php on line 17
i have changed what u have suggest and the code that i am now using looks like this
<html>
<title>test</title>
</head>
<body>
<?php
$db=mysql_connect("localhost","username","password") or die ("cant connect");
mysql_select_db("database",$db) or die ("cant change");
$news=mysql_query("select * from news ORDER BY date DESC LIMIT 8") or die ("cant get em");
while($rows=mysql_fetch_array($news)){
$date=date("F d, Y H:i ",$rows["date"]);
$author=$rows["author"];
$number="100%";
printf("<table cellpadding=2 cellspacing=0 border=0 width=%s>\n",$number);
echo "<td bgcolor=#496CB1 class='first'><b>$title</b></td>\n";
echo "<td align=right bgcolor=#496CB1 class='first'>$date</td><tr>\n";
echo "<td colspan=2><i>by <A href=\\"mailto:$email\">$author</a></i>
$content</td></table><p>\n";
}
?>
</body>
</html>
is this what u meant for me 2 do? if so can u think of ne other reasons i may be having this problem
thx for your help
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
You have to change this:
to this:
note that there is only one backslash (\) each time.
Mac
Code: Select all
<A href="e;mailto:$email">Code: Select all
<A href="mailto:$email">Mac