0

From comprobar.php

marcarpagado.php gets NULL, why?

echo '<a href="marcarpagado.php?id=<?php echo $id; ?>">Marcar como pagado</a>';

In marcarpagado.php:

echo $_GET['id'];
  • what do you see in the source though? is there an actual value for id? i think you'll find $id isn't echoing out the way you think it is. – thescientist Feb 19 '14 at 12:29

8 Answers8

3

You are using echo two times.

It should be like this

echo "<a href='marcarpagado.php?id=".$id."'>Marcar como pagado</a>";
Sumit Bijvani
  • 8,154
  • 17
  • 50
  • 82
0

You are using php tag again inside php and echo inside echo .so

change

  echo '<a href="marcarpagado.php?id=<?php echo $id; ?>">Marcar como pagado</a>';

to

echo "<a href='marcarpagado.php?id=$id'>Marcar como pagado</a>";
krishna
  • 4,069
  • 2
  • 29
  • 56
0

invalid format php tag in echo statement

      echo '<a href="marcarpagado.php?id=<?php echo $id; ?>">Marcar como pagado</a>';

replace it with

echo "<a href='marcarpagado.php?id=$id'>Marcar como pagado</a>";
wild
  • 340
  • 1
  • 3
  • 14
0

You seem to be mixing your PHP

ie:

echo '<a href="marcarpagado.php?id=<?php echo $id; ?>">Marcar como pagado</a>';

within this string you another set of php tags, the string should read

echo '<a href="marcarpagado.php?id='.$id.'">Marcar como pagado</a>';

have a look here for string operators http://www.php.net/manual/en/language.operators.string.php

Marty
  • 4,619
  • 2
  • 24
  • 35
0

try this:

echo '<a href="marcarpagado.php?id='.$id.'">Marcar como pagado</a>';
Muthu
  • 1,022
  • 1
  • 7
  • 17
0

Change it to : echo '<a href="marcarpagado.php?id='. $id .'">Marcar como pagado</a>';

Prasanth Bendra
  • 31,145
  • 9
  • 53
  • 73
0

Use a function like sprintf :

echo sprintf('<a href="marcarpagado.php?id=%d">Marcar como pagado</a>',$id);
markcial
  • 9,041
  • 4
  • 31
  • 41
  • `echo sprintf()` is an "antipattern". There is absolutely no reason that anyone should ever write `echo sprintf()` in any code for any reason -- it should be `printf()` without `echo` every time. – mickmackusa Apr 09 '22 at 08:14
0

Nested echo is not supported in php.

Sven Hohenstein
  • 80,497
  • 17
  • 145
  • 168
Md. Helal Uddin
  • 1,943
  • 1
  • 14
  • 18