Jump to content

[SOLVED] Please help me!


kankaro

Recommended Posts

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);

?>

 

Link to comment
Share on other sites

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);
?>

Link to comment
Share on other sites

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);

 

?>

Link to comment
Share on other sites

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>";
    }
  }

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.