Notice: Undefined index: action in /opt/lampp/htdocs/contacts.php on line 6 [duplicate]
This question already has an answer here:
“Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHP
27 answers
I was developing one simple PHP script in window machine and was testing in xampp. I have completed it and its working fine in my windows machine. Now I have tried to move it in my centos 7 machine which also have xampp. Its giving me error like below
Notice: Undefined index: action in /opt/lampp/htdocs/contacts.php on line 6
My code for that function is like below
if($_GET['action']=="change_status" && $_GET['contact_id']>0 )
{
$upd_qry = "update contacts set status = ? where id=?";
$stmt = mysqli_prepare($mysqli, $upd_qry);
mysqli_stmt_bind_param($stmt, "ii", $_GET['status'],$_GET['contact_id']);
$result = mysqli_stmt_execute($stmt);
$_SESSION['msg']="11";
header( "Location:contacts.php");
exit;
}
I have marked that similar errors in 1-2 more files too. I do not understanding why this happening. I have php 7.2 in my windows machine and in centos its 7.0
let me know if someone know what is wrong with it.
Thanks
php html
marked as duplicate by deceze♦
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 9:43
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
“Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHP
27 answers
I was developing one simple PHP script in window machine and was testing in xampp. I have completed it and its working fine in my windows machine. Now I have tried to move it in my centos 7 machine which also have xampp. Its giving me error like below
Notice: Undefined index: action in /opt/lampp/htdocs/contacts.php on line 6
My code for that function is like below
if($_GET['action']=="change_status" && $_GET['contact_id']>0 )
{
$upd_qry = "update contacts set status = ? where id=?";
$stmt = mysqli_prepare($mysqli, $upd_qry);
mysqli_stmt_bind_param($stmt, "ii", $_GET['status'],$_GET['contact_id']);
$result = mysqli_stmt_execute($stmt);
$_SESSION['msg']="11";
header( "Location:contacts.php");
exit;
}
I have marked that similar errors in 1-2 more files too. I do not understanding why this happening. I have php 7.2 in my windows machine and in centos its 7.0
let me know if someone know what is wrong with it.
Thanks
php html
marked as duplicate by deceze♦
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 9:43
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
How are you callingcontacts.php
? Is there a get parameter calledaction
?
– kerbholz
Nov 21 '18 at 9:36
add a comment |
This question already has an answer here:
“Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHP
27 answers
I was developing one simple PHP script in window machine and was testing in xampp. I have completed it and its working fine in my windows machine. Now I have tried to move it in my centos 7 machine which also have xampp. Its giving me error like below
Notice: Undefined index: action in /opt/lampp/htdocs/contacts.php on line 6
My code for that function is like below
if($_GET['action']=="change_status" && $_GET['contact_id']>0 )
{
$upd_qry = "update contacts set status = ? where id=?";
$stmt = mysqli_prepare($mysqli, $upd_qry);
mysqli_stmt_bind_param($stmt, "ii", $_GET['status'],$_GET['contact_id']);
$result = mysqli_stmt_execute($stmt);
$_SESSION['msg']="11";
header( "Location:contacts.php");
exit;
}
I have marked that similar errors in 1-2 more files too. I do not understanding why this happening. I have php 7.2 in my windows machine and in centos its 7.0
let me know if someone know what is wrong with it.
Thanks
php html
This question already has an answer here:
“Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHP
27 answers
I was developing one simple PHP script in window machine and was testing in xampp. I have completed it and its working fine in my windows machine. Now I have tried to move it in my centos 7 machine which also have xampp. Its giving me error like below
Notice: Undefined index: action in /opt/lampp/htdocs/contacts.php on line 6
My code for that function is like below
if($_GET['action']=="change_status" && $_GET['contact_id']>0 )
{
$upd_qry = "update contacts set status = ? where id=?";
$stmt = mysqli_prepare($mysqli, $upd_qry);
mysqli_stmt_bind_param($stmt, "ii", $_GET['status'],$_GET['contact_id']);
$result = mysqli_stmt_execute($stmt);
$_SESSION['msg']="11";
header( "Location:contacts.php");
exit;
}
I have marked that similar errors in 1-2 more files too. I do not understanding why this happening. I have php 7.2 in my windows machine and in centos its 7.0
let me know if someone know what is wrong with it.
Thanks
This question already has an answer here:
“Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHP
27 answers
php html
php html
asked Nov 21 '18 at 9:32
MiraMira
204
204
marked as duplicate by deceze♦
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 9:43
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by deceze♦
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 9:43
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
How are you callingcontacts.php
? Is there a get parameter calledaction
?
– kerbholz
Nov 21 '18 at 9:36
add a comment |
How are you callingcontacts.php
? Is there a get parameter calledaction
?
– kerbholz
Nov 21 '18 at 9:36
How are you calling
contacts.php
? Is there a get parameter called action
?– kerbholz
Nov 21 '18 at 9:36
How are you calling
contacts.php
? Is there a get parameter called action
?– kerbholz
Nov 21 '18 at 9:36
add a comment |
1 Answer
1
active
oldest
votes
The problem is that $_GET['action']
does not exist, when you don't add it in the URL. You can work it around by adding a isset-check
if(isset($_GET['action']) && $_GET['action']=="change_status" && $_GET['contact_id']>0 )
{
$upd_qry = "update contacts set status = ? where id=?";
$stmt = mysqli_prepare($mysqli, $upd_qry);
mysqli_stmt_bind_param($stmt, "ii", $_GET['status'],$_GET['contact_id']);
$result = mysqli_stmt_execute($stmt);
$_SESSION['msg']="11";
header( "Location:contacts.php");
exit;
}
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The problem is that $_GET['action']
does not exist, when you don't add it in the URL. You can work it around by adding a isset-check
if(isset($_GET['action']) && $_GET['action']=="change_status" && $_GET['contact_id']>0 )
{
$upd_qry = "update contacts set status = ? where id=?";
$stmt = mysqli_prepare($mysqli, $upd_qry);
mysqli_stmt_bind_param($stmt, "ii", $_GET['status'],$_GET['contact_id']);
$result = mysqli_stmt_execute($stmt);
$_SESSION['msg']="11";
header( "Location:contacts.php");
exit;
}
add a comment |
The problem is that $_GET['action']
does not exist, when you don't add it in the URL. You can work it around by adding a isset-check
if(isset($_GET['action']) && $_GET['action']=="change_status" && $_GET['contact_id']>0 )
{
$upd_qry = "update contacts set status = ? where id=?";
$stmt = mysqli_prepare($mysqli, $upd_qry);
mysqli_stmt_bind_param($stmt, "ii", $_GET['status'],$_GET['contact_id']);
$result = mysqli_stmt_execute($stmt);
$_SESSION['msg']="11";
header( "Location:contacts.php");
exit;
}
add a comment |
The problem is that $_GET['action']
does not exist, when you don't add it in the URL. You can work it around by adding a isset-check
if(isset($_GET['action']) && $_GET['action']=="change_status" && $_GET['contact_id']>0 )
{
$upd_qry = "update contacts set status = ? where id=?";
$stmt = mysqli_prepare($mysqli, $upd_qry);
mysqli_stmt_bind_param($stmt, "ii", $_GET['status'],$_GET['contact_id']);
$result = mysqli_stmt_execute($stmt);
$_SESSION['msg']="11";
header( "Location:contacts.php");
exit;
}
The problem is that $_GET['action']
does not exist, when you don't add it in the URL. You can work it around by adding a isset-check
if(isset($_GET['action']) && $_GET['action']=="change_status" && $_GET['contact_id']>0 )
{
$upd_qry = "update contacts set status = ? where id=?";
$stmt = mysqli_prepare($mysqli, $upd_qry);
mysqli_stmt_bind_param($stmt, "ii", $_GET['status'],$_GET['contact_id']);
$result = mysqli_stmt_execute($stmt);
$_SESSION['msg']="11";
header( "Location:contacts.php");
exit;
}
answered Nov 21 '18 at 9:33
Koen HollanderKoen Hollander
1,03731729
1,03731729
add a comment |
add a comment |
How are you calling
contacts.php
? Is there a get parameter calledaction
?– kerbholz
Nov 21 '18 at 9:36