0

I'm new to php, I have been getting this error in my code

echo "<a href=\"PHadmin_deletePatient.php?id=<?php echo $row["PatientID"]; ?>\" class='delete' title='Delete' data-toggle='tooltip'><i class='material-icons'>&#xE872;</i></a>";

I found out that the error is within ?id=<?php echo $row["PatientID"]; ?> this part of the code but I couldn't solve it.

Full error- Parse error: syntax error, unexpected double-quote mark, expecting "-" or identifier or variable or number in

yukang
  • 43
  • 1
  • 8
  • What error? Please post the code before and the actual error but first [see this answer](https://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php) – mplungjan Oct 11 '21 at 05:58
  • You do not need to use `` within an existing echo statement – Professor Abronsius Oct 11 '21 at 06:01
  • `echo "";` - the variable, when encased within double-quotes, will be parsed correctly so you can simply include it within the string ~ the use of curly quotes around the variable is mainly optional – Professor Abronsius Oct 11 '21 at 06:04

3 Answers3

0

You don't need to write echo inside the already present PHP echo code. Update your code and try to use single quotes if you double quote for your attribute.

echo '<a href="PHadmin_deletePatient.php?id='.$row['PatientID'].'" class="delete" title="Delete" data-toggle="tooltip"><i class="material-icons">&#xE872;</i> </a>';

Mainul Hasan
  • 691
  • 3
  • 12
0

Use single quotes. Write this

echo "<a href='PHadmin_deletePatient.php?id=' class='delete' title='Delete' data-toggle='tooltip'>";

Zasha
  • 56
  • 1
  • 13
0

I think I understand what you want to do. You want to print link html with echo and you don't want quotation marks to be a problem.

echo '<a href="testlink">Test Link</a>';

// or

echo "<a href='testlink'>Test Link</a>";

Above I showed both ways to get rid of quotation marks. If you are going to use double quotes in echo, echo should start with single quotes. If you are going to use single quotes, it should start with double quotes.

If my answer worked please mark as correct

Burak.H
  • 91
  • 8