0

I'm trying to get a string value passed through the $_GET function.

url (excluding beginning url): viewarticle.php?articleid=string-value-that-needs-to-be-passed

and then echo it.

echo '<p>'.$_GET['articleid'].'</p>';

Except then it keeps returning a value of 0. If I pass an integer, it works perfectly fine, I also tried passing the string without the dashes, but to no avail. What am I doing wrong? Thank you.

Sully
  • 21
  • 4
  • 1
    please post the real "string-value-that-needs-to-be-passed" – Alberto Sinigaglia Apr 11 '20 at 20:50
  • Provided a value is set in the url, it shouldn't matter what value is set if you are calling on the key for that value it should pass the value once called using the $_GET global. – dale landry Apr 11 '20 at 21:01
  • (`articleid` sounds like it should only contain integers though.) Do you int-cast it anywhere before that code? Something like `$_GET['articleid'] = (int) $_GET['articleid'];` ? – brombeer Apr 11 '20 at 21:06
  • Go through the answers of this question https://stackoverflow.com/questions/8469767/get-url-query-string-parameters. I think it might help you. – omar jayed Apr 11 '20 at 22:05
  • Accidentally int-casted the variable. Fixed by using another variable. Thanks! – Sully Apr 11 '20 at 22:38

0 Answers0