PHP:Why I get notice when running in Xampp server?
When I run a code in wamp server it displays output but when I run the same code in Xampp server why it shows so many notices(with output) like-
Notice:Undefined index:
Replies
-
Kaustubh Katdare#-Link-Snipped-# - Two things -
1. Is that the full error message? Is there any detail included after Undefined index:.. ?
2. Possible for you to post the code so that experts here can dig deeper? -
Whats In NameThe_Big_K#-Link-Snipped-# - Two things -
1. Is that the full error message? Is there any detail included after Undefined index:.. ?
2. Possible for you to post the code so that experts here can dig deeper?
Actually,here's the full message-
Notice: Undefined index: uname in C:\xampp\htdocs\project\login.php on line 5
Notice: Undefined index: pwd in C:\xampp\htdocs\project\login.php on line 6
and code-
php
session_start();
include("connection.php");
ob_start();
$a=$_REQUEST['uname'];
$b=$_REQUEST['pwd'];
if(isset($_REQUEST['sub_login']))
{
$query="select * from register where uname='$a' and pwd='$b'";
$queryexe=mysql_query($query);
$count=mysql_num_rows($queryexe);
$row=mysql_fetch_array($queryexe);
$id=$row['user_id'];
$_SESSION['user_id']=$id;
if($count>0)
{
header("location:profile.php");
}
else
{
?>}
}
?>Login
-
Kaustubh Katdare#-Link-Snipped-# , #-Link-Snipped-# - over to you, folks. 😀
-
Manish GoyalThat's a bad coding art, you must check if there is any data in $_REQUEST or not assuming uname and pwd will always be present in data, if not then check isset($_REQUEST['uname'])
if(!empty($_REQUEST)){ }
-
PraveenKumar PurushothamanChange the part:
It is a temporary fix only.$a=@$_REQUEST['uname'];
$b=@$_REQUEST['pwd']; -
simplycoderI agree with goyal, never assume that the program would behave the way you think it will be.
When a developer develops something, he/she performs unit testing without much of destructive cases(a happy flow), but ideally this is a bad and a wrong practice to assume. Always check for values, same applies when session variables are being stored or retrieved. -
Whats In Name@all,Thanks a lot for the replies,they were really informative,
#-Link-Snipped-#,it solved my problem,thank you.And I will keep it in mind to check for values.
You are reading an archived discussion.
Related Posts
my power supply just broke and I want to build my own power supply which can be adjusted by a potentiometer that outputs 0-12Volts and a current of 1A or...
FM, P. Chidambaram is presenting Union Budget 2013 in parliament. Let's discuss the highlights and good / bad things about the same.
-Cb
😁 Hi guyz... M sruti currently getin trained in CDAC, kolkata😁 Was njoying the chit chats for Yashyant Kanetkar... so joined u guyz...
Dear All,
We have one user who is not able to use internet. I have changed the ip address , dns etc. but still it is not pinging, we have...
Hi Guys,
This is Sreekumar, I'm a Network engineer posted in Bangalore (ttkhealthcareservices). I found this site through browsing seeking to interact with the best in the Business.