0
<?php while($result = mysql_fetch_array( $resulta ))  { 
    echo "<tr>";
        echo "\t\t<td>{$result['denumire_locatie']}</td>\n";
        echo "\t\t<td>{$result['tip_locatie']}</td>\n";
        echo "\t\t<td>{$result['judet']}</td>\n";
        echo "\t\t<td>{$result['localitate']}</td>\n";
        echo "\t\t<td>{$result['strada']}</td>\n";
        echo "\t\t<td>{$result['numar']}</td>\n";
        echo "\t\t<td>{$result['telefon']}</td>\n";
        echo "\t\t<td>{$result['fax']}</td>\n";
        echo "\t\t<td>{$result['email']}</td>\n";
        echo "\t\t<td>{$result['descriere']}</td>\n";
        echo "\t\t<td><a href="/oferta.php?id={$result['id_oferta']}">click pentru detalii</a></td>\n";
    echo "</tr>";   
} 

When I run I get the following error message: Parse error: syntax error, unexpected '=' in C:\xampp\htdocs\SITE\index.php on line 157 Line 157 is the following one:

echo "\t\t<td><a href="/oferta.php?id={$result['id_oferta']}">click pentru detalii</a></td>\n";

Can anyone see the problem?

4

5 回答 5

1

在这一行中,双引号结束您的回显字符串。

echo "\t\t<td><a href="/oferta.php?id={$result['id_oferta']}">click pentru detalii</a></td>\n";
                      ^

为了避免(逃避)这种行为,在它前面放一个反斜杠

echo "\t\t<td><a href=\"/oferta.php?id={$result['id_oferta']}\">click pentru detalii</a></td>\n";
                      ^                                      ^
于 2013-06-07T12:39:53.323 回答
1

您正在尝试使用由双引号包裹的双引号...当您遇到这种情况时,要么交替单引号和双引号,要么使用\ like转义内部引号\"

但是在恕我直言,当您想在编写html标签属性时保持一致性时,转义是更好的选择。

任何一个:

 echo "\t\t<td><a href=\"/oferta.php?id={$result['id_oferta']}\">click pentru detalii</a></td>\n";

或者

echo "\t\t<td><a href='/oferta.php?id={$result['id_oferta']}'>click pentru detalii</a></td>\n";

更改代码:

<?php while($result = mysql_fetch_array( $resulta )) 
                     { 
                        echo "<tr>";
                        echo "\t\t<td>{$result['denumire_locatie']}</td>\n";
                        echo "\t\t<td>{$result['tip_locatie']}</td>\n";
                        echo "\t\t<td>{$result['judet']}</td>\n";
                        echo "\t\t<td>{$result['localitate']}</td>\n";
                        echo "\t\t<td>{$result['strada']}</td>\n";
                        echo "\t\t<td>{$result['numar']}</td>\n";
                        echo "\t\t<td>{$result['telefon']}</td>\n";
                        echo "\t\t<td>{$result['fax']}</td>\n";
                        echo "\t\t<td>{$result['email']}</td>\n";
                        echo "\t\t<td>{$result['descriere']}</td>\n";
                        echo "\t\t<td><a href=\"/oferta.php?id={$result['id_oferta']}\">click pentru detalii</a></td>\n";
                        echo "</tr>";   
                     } 
                     echo "</table>";
于 2013-06-07T12:38:28.677 回答
0
echo "\t\t<td><a href="
                      ^ end of string
于 2013-06-07T12:36:40.047 回答
0

用。。。来代替:

echo "\t\t<td><a href=\"/oferta.php?id={$result['id_oferta']}\">click pentru detalii</a></td>\n";

当您将其用作分隔符时,您必须转义它。

于 2013-06-07T12:37:08.140 回答
0

尝试这个:

echo "\t\t<td><a href=\"/oferta.php?id={$result['id_oferta']}\">click pentru detalii</a></td>\n";

你必须逃避你的“所以PHP不会混淆......。

于 2013-06-07T12:37:13.473 回答