Skip navigation
ggourde
Currently Being Moderated

Link: works as an a href, but not in php

Mar 7, 2012 4:02 PM

Tags: #error #php #dreamweaver #link

Upon submitting a form I want it to redirect to where it came from.

 

Using this: <a href="form_update.php?beer_id=<?php echo $row_beer_update['beer_id']; ?>">

 

I can create a link that will take me to the page I want with the right information. Unfortunately into won't work on the submit button. So I'd have to click once to submit the info, and again on the link to go to the page I want.

 

Using this:

    

mysql_select_db($database_beer_diary, $beer_diary);

  $Result1 = mysql_query($updateSQL, $beer_diary) or die(mysql_error());

  $row_beer_update = mysql_fetch_assoc($Result1);

   $updateGoTo = "detail_sheet.php?recordID=";

    if (isset($_SERVER['QUERY_STRING'])) {

      $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";

      $updateGoTo .= $_SERVER['QUERY_STRING'];

    }

 

  header(sprintf("Location: %s", $updateGoTo));

}

 

It will go to the page I want, but it doesn't have the information I want on it.

 

So trying to combine the  two:

 

mysql_select_db($database_beer_diary, $beer_diary);

  $Result1 = mysql_query($updateSQL, $beer_diary) or die(mysql_error());

  $row_beer_update = mysql_fetch_assoc($Result1);

    $updateGoTo = "detail_sheet.php?recordID=".echo $row_beer_update['beer_id'];

   

This is the closest I got (I've tried several variations, but none worked). On this attempt I keep on getting "parse eror" but I can't see what's missing.

 

Any ideas?

Thanks

 
Replies
  • Currently Being Moderated
    Mar 7, 2012 4:58 PM   in reply to ggourde

    You are executing an update statement, so $Result1 contains only TRUE or FALSE; it is not a pointer to a recordset. Since you are updating a table, just use the primary key from your update's WHERE clause for the querystring value.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 8, 2012 11:00 AM   in reply to ggourde

    No, you don't want to append the entire SQL update statement to the querystring, you just want the ID.

     

      $updateGoTo = "detail_sheet.php?recordID=".$_POST['beer_id'];

     

    Also, I assume you are not showing us the entire sprintf() statement, as what you have posted would be invalid.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points