aixen083 Posted February 19, 2015 Share Posted February 19, 2015 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 Quote Link to comment https://forums.phpfreaks.com/topic/294729-notice-undefined-index/ Share on other sites More sharing options...
NotionCommotion Posted February 19, 2015 Share Posted February 19, 2015 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. Quote Link to comment https://forums.phpfreaks.com/topic/294729-notice-undefined-index/#findComment-1506164 Share on other sites More sharing options...
aixen083 Posted February 19, 2015 Author Share Posted February 19, 2015 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 Quote Link to comment https://forums.phpfreaks.com/topic/294729-notice-undefined-index/#findComment-1506165 Share on other sites More sharing options...
Barand Posted February 19, 2015 Share Posted February 19, 2015 You do the check on line 4. Do the same on line 3. Quote Link to comment https://forums.phpfreaks.com/topic/294729-notice-undefined-index/#findComment-1506167 Share on other sites More sharing options...
ginerjm Posted February 19, 2015 Share Posted February 19, 2015 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? Quote Link to comment https://forums.phpfreaks.com/topic/294729-notice-undefined-index/#findComment-1506168 Share on other sites More sharing options...
aixen083 Posted February 19, 2015 Author Share Posted February 19, 2015 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 Quote Link to comment https://forums.phpfreaks.com/topic/294729-notice-undefined-index/#findComment-1506169 Share on other sites More sharing options...
NotionCommotion Posted February 19, 2015 Share Posted February 19, 2015 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. Quote Link to comment https://forums.phpfreaks.com/topic/294729-notice-undefined-index/#findComment-1506171 Share on other sites More sharing options...
aixen083 Posted February 19, 2015 Author Share Posted February 19, 2015 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 ? Quote Link to comment https://forums.phpfreaks.com/topic/294729-notice-undefined-index/#findComment-1506172 Share on other sites More sharing options...
NotionCommotion Posted February 19, 2015 Share Posted February 19, 2015 what do you this is the best way on how to solve this problem ? See the last sentence in my first post. Or see Barand's post. Quote Link to comment https://forums.phpfreaks.com/topic/294729-notice-undefined-index/#findComment-1506174 Share on other sites More sharing options...
ginerjm Posted February 19, 2015 Share Posted February 19, 2015 You didnt' show us the url that is calling this script. That is expected to have the org_id defined in it and apparently doesn't. You ARE doing a GET from your calling screen's form and not a POST? Quote Link to comment https://forums.phpfreaks.com/topic/294729-notice-undefined-index/#findComment-1506175 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.