Jump to content

Notice: Undefined index


aixen083

Recommended Posts

Please Help me to solve my problem.. 

I'm having some difficulties in solving the issue please HELP me

I have this code

<div class="span5">
<?php
$get_id = $_GET['org_id'];
$oid = isset($_GET['org_id'])?$_GET['org_id']:"";


$query_vote=mysql_query("select * from votes where position='President' and voters_id='$session_id'");
$count=mysql_num_rows($query_vote);
$row=mysql_fetch_array($query_vote);
$id=$row['vote_id'];

if ($count==1){ ?>
<script type="text/javascript">
jQuery(document).ready(function() {
$('#delete<?php echo $id; ?>').tooltip('show');
$('#delete<?php echo $id; ?>').tooltip('hide');
})
</script>
<h6>My Candidate for President</h6>
<div class="none"><img class="img-polaroid" src="admin/<?php echo $row['img']; ?>" width="88" height="88"/>
<a><?php echo $row['firstname']." ".$row['lastname']; ?></a>
<a class="btn btn-danger" data-placement="right" id="delete<?php echo $id; ?>"  title="Click to Remove"  href="#<?php echo $id; ?>"  data-toggle="modal">  <i class="icon-remove icon-large">
</i></a>
<!---delete modal -->
 <?php include('delete_user_modal.php'); ?>
<!---delete modal -->
<?php
}else{
?>	
<h6>Candidate for President</h6>
<?php

$result = mysql_query("SELECT candidates.candidates_id, candidates.firstname, candidates.lastname, candidates.img FROM candidates INNER JOIN voters ON voters.org_id = candidates.org_id WHERE position='President' AND candidates_id='$get_id' ");


while($row=mysql_fetch_assoc($result))
{

$id=$row['candidates_id'];
 ?>	

			<script type="text/javascript">
    jQuery(document).ready(function() 
	{
        $('#a<?php echo $id; ?>').tooltip('show');
        $('#a<?php echo $id; ?>').tooltip('hide');
    })
</script>			
<div class="picture"><img data-placement="bottom" id="a<?php echo $id; ?>"  title="Drag the Image to the ballot Box to Vote for 
<?php echo $row['firstname']." ".$row['lastname']; ?>" class="img-polaroid" src="admin/<?php echo $row['img']; ?>" width="88" height="128"/>
<br>
    
<a><?php echo $row['firstname']." ".$row['lastname']; ?></a>
</div>
<?php 				
}
?>


<?php } ?>
	
		<div>

But the problem is that im getting this error in my page

 Notice: Undefined index: org_id

please help me and give me some advice on how to resolve this

 

Link to comment
https://forums.phpfreaks.com/topic/294729-notice-undefined-index/
Share on other sites

At the top of your PHP script, add var_dump($_GET);.  What do you see?  Is it set?  You later use isset to first check which is the way to do it if you don't want a notice.

 

Sir it doesn't fix the error instead i get this error

array(0) { }
Notice: Undefined index: org_id

What line number gives you that error? I'm guessing the second line that says $get_id = $_GET['org_id'];

 

That means that your url does not contain a query var in the format of "&org_id=xyz" or "?org_id=xyz". Exactly what does your calling/incoming url look like?

What line number gives you that error? I'm guessing the second line that says $get_id = $_GET['org_id'];

 

That means that your url does not contain a query var in the format of "&org_id=xyz" or "?org_id=xyz". Exactly what does your calling/incoming url look like?

 

On line 3 sir

 

Sir it doesn't fix the error instead i get this error

array(0) { }
Notice: Undefined index: org_id

 

The var_dump command displays all the elements in the variable.  $_GET is an array.  As seen, there isn't any indexes the the array.  You then ask for $_GET['org_id'] which obviously does not exist, thus the error.

The var_dump command displays all the elements in the variable.  $_GET is an array.  As seen, there isn't any indexes the the array.  You then ask for $_GET['org_id'] which obviously does not exist, thus the error.

what do you this is the best way on how to solve this problem ?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.