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.
Related
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'];
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.
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
I'm getting an undefined index notice, though the index is defined. PHP version is 5.6
Code:
$url = $_SERVER['REQUEST_URI'];
$array = explode('?', $url);
var_dump($array);
echo "<br>".$array[0]."<br>";
echo "this is value 1:".$array[1]."<br>"; //line 9
Output:
array(2) { [0]=> string(10) "/customers" [1]=> string(9) "name=test" }
/customers
this is value 1:name=test
This all makes sense, but I also get this notice:
PHP Notice: Undefined offset: 1 in
/var/source/united/magebo/api/api.php on line 9
Any idea where this notice is coming from?
I tried setting the url hard coded to the same value, the notice disappears. I found allot of questions about this issue but in my case the index IS defined.
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.