0

I have this code:

<p><a href="./page.html?msubject=<?php echo $_GET['msubject']?>&subject=thingy">Page</a></p>

According to this previously asked question, it should be right,

yet I get errors of a

malformed URI reference and subject being an unknown entity.

Community
  • 1
  • 1
p26528
  • 31
  • 5

4 Answers4

1

You didn't close your PHP tag correctly.

<?php echo $_GET['msubject']>

change to this

<a href="<?= urlencode('./page.html?msubject=' . $_GET['msubject'] . '&subject=thingy') ?>">Page</a>
hamed
  • 91
  • 5
  • When editing for formatting, I accidentally deleted it. It's not the problem. What else could be the problem? – p26528 Apr 12 '17 at 06:14
  • Ok then try what other guys suggest, use `urlencode`, I will edit my answer. @p26528 – hamed Apr 12 '17 at 06:27
0

check if the msubject doesn't have spaces. I'm not a php programmer but I know I have to urlencode my string before loading them in an URL

Davy Quyo
  • 102
  • 6
  • How would you urlencode before putting it into the URL? Can it not be done in 1 go? The example on php.net shows it being used on the php part, which would make it so the php would not run. – p26528 Apr 14 '17 at 02:08
  • like I said I'm not a php developer but I hope this helps http://php.net/manual/en/function.urlencode.php – Davy Quyo Apr 16 '17 at 22:07
0

Try this

<p><a href="./page.html?msubject=<?php echo $_GET['msubject'];?>&subject=thingy">Page</a></p>

You miss **<?php ?>**

ThataL
  • 165
  • 3
  • 12
0

Please try this code,

<?php $query = array('msubject' => $_GET['msubject'],'subject' => 'thingy'); ?>
<a href="./page.html?<?php echo http_build_query($query, null, '&amp;', PHP_QUERY_RFC3986); ?>">Page</a>

Please refer the below url for 'http_build_query' function

http://php.net/manual/en/function.http-build-query.php

manian
  • 1,418
  • 2
  • 16
  • 32