1

I am experiencing a strange issue. The MYSQL row 'ID' is not echoed through to another PHP page. It should for example be editrecord.php?id=1000005 and now I only get editrecord.php?id=

It's strange because it works if I link from a search member page to an edit member page but not from a search member page to a profile page even though pretty much the same code is used.

Am I missing something? This is the code...

    // connect to the DB
include('includes/connect.php');
// get value of id that sent from address bar
$id=$_GET['id'];

// Retrieve data from database 
$sql="SELECT * FROM Customers WHERE id='$id'";
$result=mysqli_query($con, $sql);
$rows=mysqli_fetch_array($result);

?>


<h4> Member Profile </h4>

<div class="fixed-action-btn horizontal" style="top: 110px; right: 1100px;">
    <a href="editrecord.php?id=<? echo $row['id']; ?>" <a class="waves-effect waves-light btn">
      <i class="large material-icons">mode_edit</i>
    </a>
mush
  • 165
  • 1
  • 8
  • 1
    Consult these following links http://php.net/manual/en/mysqli.error.php and http://php.net/manual/en/function.error-reporting.php and apply that to your code. You're using the wrong variable and error reporting would have told you that. – Funk Forty Niner Dec 08 '15 at 15:21
  • 1
    look at this very carefully ` echo $row['id']; ?>` for 2 reasons. it should be `$rows` and not `$row`. – Funk Forty Niner Dec 08 '15 at 15:26
  • This is open to SQL injections, see http://php.net/manual/en/mysqli.quickstart.prepared-statements.php. – chris85 Dec 08 '15 at 15:30
  • 1
    @chris85 yeah I edited my comment above *before* you posted that lol I wanted to make the OP *"think"* about it ;-) – Funk Forty Niner Dec 08 '15 at 15:31
  • 1
    not to mention if short tags are enabled also. plus, if on the same page, use `isset()`. – Funk Forty Niner Dec 08 '15 at 15:31
  • 1
    All good points, well OP should have things to work with now. – chris85 Dec 08 '15 at 15:34
  • Hi Fred... Thanks for the comment. Changing from row to rows doesn't seem to make a difference. On another page i've used row and it worked. Short tags also worked on that page, so don't think there's an issue with short tags... The link is directing towards another page called editrecord.php. The page it's directing from is profile.php... Not sure where I am going wrong here. – mush Dec 08 '15 at 15:55

0 Answers0