PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
include'global.php';
$result=mysql_query("SELECT * FROM articles ORDER BY id DESC LIMIT 20");
?>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p align=right>
<?
while( $row=mysql_fetch_array($result)) {
$id=$row['id'];
echo "<a href=\"readarticle.php?id=$id\">$row['title']</a>" ,' ', 'نوشته',' ', $row['name'] , "<br />";
}
?>
and get this error:
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in g:\programs\easyphp1-8\www\takfekr\htdocs\home.php on line 13
<?php
include'global.php';
$result=mysql_query("SELECT * FROM articles ORDER BY id DESC LIMIT 20");
?>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p align=right>
<?
while( $row=mysql_fetch_array($result)) {
$id=$row['id'];
echo "<a href=\"readarticle.php?id=$id\">$row['title']</a>" .' '. 'by'.' '. $row['name'] . "<br />";
}
?>
is sending:
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in g:\programs\easyphp1-8\www\takfekr\htdocs\home.php on line 13
too
Your problem was with the attempt to parse $row['title']. In the case of your original code, you would have either had to have removed the quotes around the array index or wrapped the entire var in curly braces.