Notice: Undefined index: category - php

Notice: Undefined index: category in /opt/lampp/htdocs/content/cron/check_deposits.php on line 18
$deposits=mysql_query("SELECT * FROM `deposits`");
while ($dp=mysql_fetch_array($deposits)) {
$received=0;
$txid='';
$txs=$wallet->listtransactions('',2000);
$txs=array_reverse($txs);
foreach ($txs as $tx) {
if($tx['category']!='receive') continue;
if ($tx['confirmations']<1) continue;
if ($tx['address']!=$dp['address']) continue;
$received=$tx['amount'];
$txid=$tx['txid'];
break;
This is how it came out of the box. I contacted support about the issue and they told me to make sure I was using PHP 5.3.1 which I am. What is wrong with this?
Here is a link to the full code:
http://diceking.tk/deposit.txt

You need to change from
if($tx['category']!='receive') continue;
to
if(isset($tx['category']) && $tx['category']!='receive') continue;

Check if the variables are set.
So, for the error about confirmations, you can use this:
if(isset($tx['confirmations']) && $tx['confirmations'] < 1) continue;
For the error about the undefined index: Category you can use this:
if(isset($tx['category']) && $tx['category']!='receive') continue;
I hope I'll helped you.
If this helped, please vote my answer.

Notice: Undefined index: amount in /opt/lampp/htdocs/content/cron/check_deposits.php on line 21
Notice: Undefined index: txid in /opt/lampp/htdocs/content/cron/check_deposits.php on line 22
Notice: Undefined index: amount in /opt/lampp/htdocs/content/cron/check_deposits.php on line 21
Notice: Undefined index: txid in /opt/lampp/htdocs/content/cron/check_deposits.php on line 22
Ahh so we have made it this far.. I tried this trick and it hated me for it:
if(isset($received=$tx['amount']) && $received=$tx['amount']) continue;

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.

Notice: Undefined offset: 22 in C:\xampp\htdocs\authen.php on line 82

line numbber 82 is the if statement
$re_arr is an array containing 25 elements
if ($pass[0]==substr($re_arr[$i],0,1))
{
$pass1[0]=$re_arr[$i];
unset($re_arr[$i]);
$re_arr=array_values($re_arr);
}
what could be done to avoid the notice
Add a check if $re_arr[$i] exists.
if (!empty($re_arr[$i]) && $pass[0]==substr($re_arr[$i],0,1))
{
$pass1[0]=$re_arr[$i];
unset($re_arr[$i]);
$re_arr=array_values($re_arr);
}

Get a specific line from object (php)

i get some URLS from HTML site by using
foreach($html->find('source') as $video)
if($video->type =='video/mp4') {
echo $video->src. '<br>';
my output looks like :
http://video.csfd.cz/321/321909/130228151/360.mp4
http://video.csfd.cz/321/321909/130228151/720.mp4
http://video.csfd.cz/321/321909/99476124/360.mp4
http://video.csfd.cz/321/321909/99476124/720.mp4
http://video.csfd.cz/321/321909/99476124/1080.mp4
and i have just no idea how to get just one of this links, i dont know much about objects so it looks pretty impossible for me to solve this problem.
What i try:
I was thinking about converting object to array and work with it, which sound pretty easy, problem is that if i use :
$pole = (array)$video;
echo "$pole[0]";
it says:
http://video.csfd.cz/321/321909/130228151/360.mp4
Notice: Undefined offset: 0 in C:\xampp\htdocs\xampp\ocul\subor.php on line 61
http://video.csfd.cz/321/321909/130228151/720.mp4
Notice: Undefined offset: 0 in C:\xampp\htdocs\xampp\ocul\subor.php on line 61
http://video.csfd.cz/321/321909/99476124/360.mp4
Notice: Undefined offset: 0 in C:\xampp\htdocs\xampp\ocul\subor.php on line 61
http://video.csfd.cz/321/321909/99476124/720.mp4
Notice: Undefined offset: 0 in C:\xampp\htdocs\xampp\ocul\subor.php on line 61
http://video.csfd.cz/321/321909/99476124/1080.mp4
Notice: Undefined offset: 0 in C:\xampp\htdocs\xampp\ocul\subor.php on line 61
if i use print_r the output is like tons of code , atleast for 1-2x A4 page, soemthing really crazy
So is there a way how to get one specific line from this (prefer to let me chose which one) , or some way to convert this output to array or anything like that?
It is a bad idea to convert objects into arrays. You could basicly store the links in an array while looping. Try this :
$links = array();
foreach ($html->find('source') as $video) {
if ($video->type == 'video/mp4') {
array_push($links, $video->src);
}
}
And then just use the $links array however you want :
echo $links[0];

Undefined index: do in

I am trying to install a arcade script and keep getting these errors, can anyone help out?
Notice: Undefined index: do in C:\xampp\htdocs\meggiemoos\arcade\install\new.php on line 34
Notice: Use of undefined constant sql - assumed 'sql' in C:\xampp\htdocs\meggiemoos\arcade\install\new.php on line 34
Notice: Undefined index: do in C:\xampp\htdocs\meggiemoos\arcade\install\new.php on line 37
Notice: Use of undefined constant sql2 - assumed 'sql2' in C:\xampp\htdocs\meggiemoos\arcade\install\new.php on line 37
This is line 34 to 38
<? if ($_GET['do'] == sql) {
include ('sql1.php');
}
else if ($_GET['do'] == sql2) {
include ('sql2.php');
I have tried if isset($_GET but I might have done it wrong as of the closed bracket { for next line, I was told to add another bracket as well but never told where.
Thanks for your help :)
Try
if (isset($_GET['do']) && $_GET['do'] == 'sql')
sql by itself is nothing to PHP. You need to have it as a string or variable, as follows:
<? if ($_GET['do'] == "sql") {
or
$var = "sql";
<? if ($_GET['do'] == $var) {
As for the line 37 error, the server cannot find the GET variable named 'do', so you need to find out why it's not being set. You might consider adding this to earlier parts of your script:
if (!isset($_GET['do'])) {
exit("do variable was not set!");
}
else {
$do = $_GET['do'];
}
That way, you don't have to keep typing $_GET['do'], which can get tedious.

Categories