kankaro Posted November 19, 2007 Share Posted November 19, 2007 hello every one im lyndon these is my first time to be here in this furom. Im a newbie in PHP Programming i need your help guys regarding my PHP code. the purpose of this is to pass a value of my query data to the field id in order for me to edit that data into another link. please help me guys. when i execute it i've got an error saying that: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in D:\Webserver\Apache2\Apache2.2\htdocs\test.php on line 13 i am using a PHP 5.2.4 version, Apache 2.2.4 version and MySQL 5.0.45 version. this is a binary configuration set up of my server.. please help me guys.. <?php include 'connect.php'; $result="SELECT * FROM try"; $r=mysql_query($result); echo" <table>"; while($row=mysql_fetch_array($r, MYSQL_ASSOC)){ echo "<tr><td><a href=\"http://edit.php?id=$row['id']\">".$row['id']."</a></td><td><a href=\"http://edit.php?id=$row['name']\">".$row['name']."</td></tr>"; } echo "</table>"; mysql_close($dbc); ?> Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted November 19, 2007 Share Posted November 19, 2007 you need conotation on those variables use the [c ode] brackets and try <?php include 'connect.php'; $result="SELECT * FROM try"; $r=mysql_query($result); echo" <table>"; while($row=mysql_fetch_array($r, MYSQL_ASSOC)){ echo "<tr><td><a href=\"edit.php?id=\"".$row['id']."\">".$row['id']."</a></td><td><a href=\"edit.php?id=\"".$row['name']."\">".$row['name']."</td></tr>"; } echo "</table>"; mysql_close($dbc); ?> Quote Link to comment Share on other sites More sharing options...
kankaro Posted November 19, 2007 Author Share Posted November 19, 2007 thnx to you cooldude832 thnx for the help... now my code works better.... thnx guys... <?php include 'connect.php'; $result="SELECT id, name FROM try"; $r=mysql_query($result); echo" <table>"; while($row=mysql_fetch_array($r, MYSQL_ASSOC)){ echo "<tr><td><a href=\"tryedit.php?name={$row['name']}&id={$row['id']}\">{$row['name']}</a></td><td> {$row['id']}</tr>"; } echo "</table>"; mysql_close($dbc); ?> Quote Link to comment Share on other sites More sharing options...
trq Posted November 19, 2007 Share Posted November 19, 2007 You really should always check your queries succeed before attempting to use any result they may produce. Your code would be much better as... <?php include 'connect.php'; $sql = "SELECT id, name FROM try"; if ($result = mysql_query($result)) { if (mysql_num_rows($result)) { echo"<table>"; while ($row=mysql_fetch_assoc($result)) { echo "<tr><td><a href=\"tryedit.php?name={$row['name']}&id={$row['id']}\">{$row['name']}</a></td><td>{$row['id']}</tr>"; } echo "</table>"; } } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.