Undefined index: do in - php

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.

Related

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 index: category

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;

How to solve "Notice: Undefined index: ..."

how can i hide the php notice by solving the issue.
my code
if(empty($_GET['mode']) && !$_GET['page']) {
include($basepath.'/templates/template.home.php');
}
Notice: Undefined index: page in /var/www/public_html/index.php on line 1
i tried like this
if(empty($_GET['mode']) && !isset($_GET['page']) && !$_GET['page']) {
include($basepath.'/templates/template.home.php');
}
but still showing the
Notice: Undefined index: page in /var/www/public_html/index.php on line 1
how can i solve/fix it ?
The problem is that you use in both statements !$_GET['page'] when using && operator.
When you use !$_GET['page'] in both cases even if you added !isset($_GET['page'] this condition is checked in $_GET['mode'] is empty.
You simple should probably change your statement from:
if(empty($_GET['mode']) && !$_GET['page']) {
include($basepath.'/templates/template.home.php');
}
into
if(empty($_GET['mode']) && !isset($_GET['page'])) {
include($basepath.'/templates/template.home.php');
}
In this case simple if $_GET['page'] is not set (and of course mode is empty) you should include homepage template
Either mode or page isn't present in the array $_GET - so you need to test for it using array_key_exists

Checking if email is valid using Pregmatch error? [duplicate]

This question already has answers here:
How to validate an Email in PHP?
(7 answers)
Closed 8 years ago.
Hello I want to check if email is valid like blabla#blabla.com and not like just plain text 'BLbalbalba'.
I have this function:
function VerifyEmail($address)
{
$Syntax='#^[w.-]+#[w.-]+.[a-zA-Z]{2,5}$#';
if(preg_match($Syntaxe,$adrdess))
return true;
else
return false;
}
And checking it like this:
$email = htmlentities($_POST['email']);
if (!empty($email) && !empty($password) && !empty($message) && VerifyEmail($email) === true) {
Getting these errors:
Notice: Undefined variable: Syntaxe in C:\xampp\htdocs\recover\inc\functions.inc.php on line 20
Notice: Undefined variable: adrdess in C:\xampp\htdocs\recover\inc\functions.inc.php on line 20
Warning: preg_match() [function.preg-match]: Empty regular expression in C:\xampp\htdocs\recover\inc\functions.inc.php on line 20
Notice: Undefined variable: Syntaxe in C:\xampp\htdocs\recover\inc\functions.inc.php on line 20
Notice: Undefined variable: adrdess in C:\xampp\htdocs\recover\inc\functions.inc.php on line 20
Warning: preg_match() [function.preg-match]: Empty regular expression in C:\xampp\htdocs\recover\inc\functions.inc.php on line 20
Why is this happening? What did I do wrong? Is it a stable way of checking if email is valid?
Thanks!
No, it's not "stable", it's not "valid", and it will not do a good job. use
filter_var($email, FILTER_VALIDATE_EMAIL)
instead. relevant docs: http://www.php.net/manual/en/function.filter-var.php
some spelling mistakes here
should be
function VerifyEmail($address)
{
$Syntax='#^[w.-]+#[w.-]+.[a-zA-Z]{2,5}$#';
if(preg_match($Syntax,$address))

Undefined variable, but it is there

I've got an array, but when I try to use it, I get the Undefined variable notice.
Here's the relevant lines:
$varEvents = array();
...
if ($selectedResult) {
while ($row = mysql_fetch_assoc($selectedResult)) {
array_push($varEvents, $row['eventID']);
}
mysql_free_result($selectedResult);
}
...
print_r($varEvents);
if (is_array($varEvents)) {
if (count($varEvents) > 0) {
if (in_array($id, $varEvents)) {
$varRegistered = 1;
}
}
unset($varEvents);
}
and the result shows as:
Array ( [0] => 4 )
Notice: Undefined variable: varEvents in /home/.../www/registration.php on line 143
Notice: Undefined variable: varEvents in /home/.../www/registration.php on line 145
line 143: print_r($varEvents);
line 145: if (is_array($varEvents)) {
All relevant lines are in the same loop and I do get most of the results I expect, except $varRegistered never changes to 1 and that messes up my result.
It is most likely because of this line:
unset($varEvents);
You are unsetting the variable within the loop and next iterations don't find it again.

Categories