Page 1 of 1
need help with a Simple news driven sites
Posted: Mon Sep 16, 2002 7:21 am
by prib
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
Posted: Mon Sep 16, 2002 7:24 am
by twigletmac
If you post lines 1-17 then we'll be able to offer suggestions on how to fix the error. Parse errors can often occur on a line above that mentioned in the error message.
Mac
code
Posted: Mon Sep 16, 2002 7:28 am
by prib
<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
Posted: Mon Sep 16, 2002 7:42 am
by twigletmac
The problem is occuring because of the
Code: Select all
A href="e;mailto:$email"e;>
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:
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";
}
Mac
Posted: Mon Sep 16, 2002 8:13 am
by prib
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
Posted: Mon Sep 16, 2002 8:16 am
by twigletmac
You have to change this:
to this:
note that there is only one backslash (\) each time.
Mac
Posted: Mon Sep 16, 2002 8:30 am
by prib
Thx alot for your help