Parse error:syntax error, unexpected t_encapsed_and_whitespace, expecting t_string or t_variable or t_num_string in E:\am p\apache\htdocs\prod\viewcat.php on line 22
Encountered this error, the internet did not find the answer, trouble you can help me solve ha, loyal thanks.
My Code:
Require ("config.php");
if (Isset ($_get[' id ') ==true) {
if (Is_numeric ($id) ==false) {
$error = 1;
}
if (Isset ($error) && $error ==1) {
Header ("Location:". $config _basedir. " /viewcat.php ");
}
else{
$validcat =$_get[' id '];
}
}
else{
$validcat = 0;
}
$sql = "SELECT * FROM Categories";
$result =mysql_query ($sql);
while ($row =mysql_fetch_assoc ($result)) {
if ($validcat = = $row [' id ']) {
echo "
". $row [' Cat '].
";
$entriessql = "SELECT * FROM Entries WHERE cat_id=". $validcat.
"ORDER by dateposted DESC;";
$entriesres =mysql_query ($entriessql);
$numrows _entries=mysql_nums_rows ($entriesres);
echo "
";
if ($numrows _entries==0) {
echo "
- No entries!
";
}
else{
while ($entriesrow =mysql_fetch_assoc ($entriesres)) {
echo "
- ". Date (" D JS F Y G.ia ", Strtotime ($entriesrow [' dateposted ']))." -". $entriesrow [' Subject ']."
";
}
}
echo "
";
}
else{
echo "". $row [' Cat '].
";
}
}
Require ("footer.php");
?>
Reply to discussion (solution)
Do you want to mark the error line?
echo "". $row [' Cat '].
";
There's something wrong here, but I can't find the error.
The 1,MYSQL_FETCH_ASSOC function is case-sensitive. $row [' Cat '] cat is case-sensitive in the database?
2,MYSQL_FETCH_ASSOC can only return a row of arrays indexed by a field, mysql_fetch_array () is recommended.
$entriessql = "SELECT * FROM Entries WHERE cat_id=". $validcat. " ORDER by dateposted DESC; ";
There is a problem with this sentence, and a space is missing before ORDER by.
Change to the following should be possible.
$entriessql = "SELECT * FROM Entries WHERE cat_id=". $validcat. " ORDER by dateposted DESC; ";
$entriessql = "SELECT * FROM Entries WHERE cat_id=". $validcat.
"ORDER by dateposted DESC;";
Let's change to the bottom.
$entriessql = "SELECT * from entries WHERE cat_id= {$validcat} ORDER by dateposted DESC";
echo "{$row [' Cat ']}
"Try this.
$entriessql = "SELECT * FROM Entries WHERE cat_id=". $validcat.
"ORDER by dateposted DESC;";
The error is grammatical errors
Thank you for your help, I have to redo the blog once again, seemingly no problem, recently did not how on the forum, hope everyone understanding, thank you for your help