Jump to content

PHP && GET Method, sending variables?


newyear498

Recommended Posts

I have this script which I will post below.. the problem is that the following script only works with number..

 

when I use this script the error.txt will only write numbers and if I send text like... ?trueId=hey  nothing happens

 

but ?trueId=1 works just fine.. heres the script

 

 

<?php
$handle = fopen('error.txt', 'r+');
$trueId = $_GET[trueId];
$nextLine = false;
$realText = false;
while(!feof($handle) && $realText != $trueId)
  {
  $nextLine = fgets($handle);
  $realText = $nextLine + "\n";
  }
  
if($realText != $trueId){
$break = "\n";
$text = $trueId;
fwrite($handle, $break);
fwrite($handle, $text);
fclose($handle);
?>

 

THANK YOU! Appreciate the help!

Link to comment
https://forums.phpfreaks.com/topic/210614-php-get-method-sending-variables/
Share on other sites

You should also have quotes around that array index. It will throw an undefined constant warning if you have your error reporting turned up high enough.

 

 

I never knew you were supposed to do quotes around that, I never really considered the GET/POST methods to be array indexs, good thing to know, appreciate it!!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.