$_GET not being set - php

When printing $_GET there is an error:
Notice: Undefined variable: _GET
Testing code:
echo "query string: ".($_SERVER['QUERY_STRING']);
print_r($_GET);
The testing URL:
http://localhost/?foo=bar
The resulting output is this:
query string: foo=bar
Notice: Undefined variable: _GET in C:\Users\DGmoN\Google Drive\Code\Web\CMS2\index.php on line 3

Related

how to access array in array when inserting json data to database?

I have json file that contains of 50 lines of similar
"results":[{"score":0,"team_id":126266},{"score":0,"team_id":125798}].
I need to insert this to database, but I keep getting errors:
Notice: Undefined index: results[0]:score[0] in D:\xampp\htdocs\json\index.php on line 26
Notice: Undefined index: results[1]:score[0] in D:\xampp\htdocs\json\index.php on line 27
Notice: Undefined index: results[0]:team_id[0] in D:\xampp\htdocs\json\index.php on line 32
Notice: Undefined index: results[1]:team_id[0] in D:\xampp\htdocs\json\index.php on line 33
Here's the code:
$pirmo_oponento_rezultatas = $row['results[0]:score[0]'];
$antro_oponento_rezultatas = $row['results[1]:score[0]'];
$fk_Komandosid_Komandos = $row['results[0]:team_id[0]'];
$fk_Komandosid_Komandos1 = $row['results[1]:team_id[0]'];
$sql="INSERT INTO rungtynes (pirmo_oponento_rezultatas,antro_oponento_rezultatas,fk_Komandosid_Komandos,
fk_Komandosid_Komandos1) VALUES ('$pirmo_oponento_rezultatas','$antro_oponento_rezultatas',
'$fk_Komandosid_Komandos','$fk_Komandosid_Komandos1')";
You can access as below
$pirmo_oponento_rezultatas = $row['results'][0]['score'];
$antro_oponento_rezultatas = $row['results'][1]['score'];

What does it mean: Undefined variable: filter in ...?

Full error message:
Notice: Undefined variable: filter in
/srv/www/htdocs/test/tiltangle/dpd/query.php on line 104
line 104:
if (!($b1=="")) $filter=$filter." and b>=$b1";
line 35:
$b1=$_POST["b1"];
As you see it was defined.
I could imagine that your code looks like this:
if(...) {
$b1=$_POST["b1"];
}
...
if (!($b1=="")) $filter=$filter." and b>=$b1";
So it is possible that the first if-Condition is false, so $b1 is never set.

Referencing a dynamic variable?

for ($count = 1; $count <= 5; ++$count) {
$test = ${'node->field_aw_score_' . $count}[LANGUAGE_NONE][0]['value'];
echo $test;
}
Throws the error:
Notice: Undefined variable: node->field_aw_score_1
Notice: Undefined variable: node->field_aw_score_2
Notice: Undefined variable: node->field_aw_score_3
Notice: Undefined variable: node->field_aw_score_4
Notice: Undefined variable: node->field_aw_score_5
However, the variables do exist. I'm trying to reference:
$node->field_aw_score_1[LANGUAGE_NONE][0]['value']
then
$node->field_aw_score_2[LANGUAGE_NONE][0]['value']
etc. A dynamic variable. What am I doing wrong? Thanks.
Try this instead:
$node->{'field_aw_score_' . $count}

Undefined index - strange?

I experience something strange with an undefined index..
$vatcode = 'U25';
echo $this->vatcode_ids['U25']."\n";
echo $this->vatcode_ids[$vatcode]."\n";
foreach($this->vatcode_account_ids as $id => $vatcode){
echo $vatcode."\n";
echo $this->vatcode_ids[$vatcode]; // undefined index
}
this returns:
681
681
U25
Notice: Undefined index: U25 in /var/www/.....php on line 64
I don't get it?!
From empty line printed before Notice massage i assume your $vatcode variable contains some ending new line character. If so it does not match any key in $this->vatcode_ids array.
You should use some trimming function as Dan Lee suggested in comments.

Php GET notice problem

Calling "index.php?pConta=1&pDataInicial=01-01-2000&pDataFinal=31-12-2000" I get this notices:
[08-Oct-2009 17:30:35] PHP Notice: Undefined index: pConta in index.php on line 1
[08-Oct-2009 17:30:35] PHP Notice: Undefined index: pDataInicial in index.php on line 2
[08-Oct-2009 17:30:35] PHP Notice: Undefined index: pDataFinal in index.php on line 3
index.php source:
<?php
$conta = $_GET['pConta'];
$dtIni = $_GET['pDataInicial'];
$dtFin = $_GET['pDataFinal'];
?>
And the "var_dump($_GET)" shows me following:
array(3) { ["pConta"]=> string(1) "1" ["pDataInicial"]=> string(10) "01-01-2000" ["pDataFinal"]=> string(10) "31-12-2000" }
And $conta, $dtIni and $dtFin have excepted values.
I found the problem! I'm using xajax (an ajax php library) and it was calling the url without params.

Categories