Notice: Undefined index: action in /opt/lampp/htdocs/contacts.php on line 6 [duplicate]












-2
















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










share|improve this question













marked as duplicate by deceze html
Users with the  html badge can single-handedly close html questions as duplicates and reopen them as needed.

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 calling contacts.php? Is there a get parameter called action?

    – kerbholz
    Nov 21 '18 at 9:36
















-2
















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










share|improve this question













marked as duplicate by deceze html
Users with the  html badge can single-handedly close html questions as duplicates and reopen them as needed.

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 calling contacts.php? Is there a get parameter called action?

    – kerbholz
    Nov 21 '18 at 9:36














-2












-2








-2









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










share|improve this question















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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 21 '18 at 9:32









MiraMira

204




204




marked as duplicate by deceze html
Users with the  html badge can single-handedly close html questions as duplicates and reopen them as needed.

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 html
Users with the  html badge can single-handedly close html questions as duplicates and reopen them as needed.

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 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

















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












1 Answer
1






active

oldest

votes


















0














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;

}





share|improve this answer






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    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;

    }





    share|improve this answer




























      0














      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;

      }





      share|improve this answer


























        0












        0








        0







        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;

        }





        share|improve this answer













        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;

        }






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 21 '18 at 9:33









        Koen HollanderKoen Hollander

        1,03731729




        1,03731729

















            Popular posts from this blog

            'app-layout' is not a known element: how to share Component with different Modules

            android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

            WPF add header to Image with URL pettitions [duplicate]