0

I have a variable retrieved from a mysqli database called eBayURL. I am attempting to assign the variable to a button.

However I get an error when using

echo "<a target='"_blank"' href='".$row['eBayURL']."' class="btn btn-outlined btn-primary btn-md">Click Here <br> To Book Now </a></li>'";

I have also tried with { but also seems to fail. What is the correct syntax please?

Nigel Ren
  • 56,122
  • 11
  • 43
  • 55
bitzer
  • 3
  • 2

2 Answers2

0

You have an incorrect mix of single and double quotes.

Try the following instead:

echo '<a target="_blank" href="'.$row['eBayURL'].'" class="btn btn-outlined btn-primary btn-md">Click Here <br> To Book Now </a></li>';

Or you can use:

echo "<a target=\"_blank\" href=\"".$row['eBayURL']."\" class=\"btn btn-outlined btn-primary btn-md\">Click Here <br> To Book Now </a></li>";

You could get crazy and use printf() as well if you like:

$format = '<a target="_blank" href="%s" class="btn btn-outlined btn-primary btn-md">Click Here <br> To Book Now </a></li>';
printf($format,$row['eBayURL']);

If that fails, please check the value of $row['eBayURL'] like so:

var_dump($row['eBayURL']);
Tigger
  • 8,980
  • 5
  • 36
  • 40
0

You mixed double quote and single quote in your anchor tag, try this -

echo "<a target='_blank' href='".$row['eBayURL']."' class='btn btn-outlined btn-primary btn-md'>Click Here <br> To Book Now </a></li>";
Shubham Baranwal
  • 2,492
  • 3
  • 14
  • 26