-1

I am passing a variable in a URL from create_topic.php, but the variable is empty. The page passing the variable uses that variable in a mysql query OK, so I know that its not empty then, but when I click a link in that page to go to another page, the variable is not being passed.

in create_topic.php I have:

$author_pk = $_GET['author_pk'];

Then in the query on that page:

$query = "INSERT INTO topic (topic_pk,title,topic,majors,sub_discipline_fk,author_fk,created,place)
  VALUES ('','$title','$topic','$majors_string','$sub_discipline','$author_pk',NOW(),'$place')";
$result = mysql_query($query, $connection) or die(mysql_error());

$author_pk contains the passed value OK.

But in a link in create_topic.php I have:

<a href="create_author.php?author_pk="<?php echo $author_pk; ?>>Create</a>

$author_pk is then empty in the URL...

IlludiumPu36
  • 4,196
  • 10
  • 61
  • 100
  • [Please, don't use `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php#answer-12860140). – Joseph Silber Jan 23 '13 at 01:32
  • 1
    Not to sound obvious, but is your link written before that $author_pk = $_GET['author_pk']; line? Also, you should sanitize your input. This query is open to attack. – Kai Qing Jan 23 '13 at 01:34

1 Answers1

3

Your double quote is out of place. A simple syntax highlighter (like that on StackOverflow) will reveal this to you.

This:

<a href="create_author.php?author_pk="<?php echo $author_pk; ?>>Create</a>

Should be:

<a href="create_author.php?author_pk=<?php echo $author_pk; ?>">Create</a>
Mike Brant
  • 70,514
  • 10
  • 99
  • 103