undefined offset error in php
        Posted  
        
            by user225269
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by user225269
        
        
        
        Published on 2010-05-05T08:31:29Z
        Indexed on 
            2010/05/05
            8:38 UTC
        
        
        Read the original article
        Hit count: 238
        
I don't know why but the code below is working when I have a different query:
$result = mysql_query("SELECT * FROM student WHERE IDNO='".$_GET['id']."'")
   ?>
<?php while ( $row = mysql_fetch_array($result) ) {
    ?>
     <?php list($year,$month,$day)=explode("-", $row['BIRTHDAY']); ?>
    <tr>
    <td width="30" height="35"><font size="2">Month:</td>
    <td width="30"><input name="mm" type="text" id="mm"  onkeypress="return handleEnter(this, event)" value="<?php echo $month;?>">
    <td width="30" height="35"><font size="2">Day:</td>
    <td width="30"><input name="dd" type="text" id="dd" maxlength="25"  onkeypress="return handleEnter(this, event)" value="<?php echo $day;?>">
    <td width="30" height="35"><font size="2">Year:</td>
    <td width="30"><input name="yyyy" type="text" id="yyyy" maxlength="25"  onkeypress="return handleEnter(this, event)" value="<?php echo $year;?>">
And it works when this is my query:
$idnum = mysql_real_escape_string($_POST['idnum']);
mysql_select_db("school", $con);
  $result = mysql_query("SELECT * FROM student WHERE IDNO='$idnum'");
Please help, why do I get the undefined offset error when I use this query:
$result = mysql_query("SELECT * FROM student WHERE IDNO='".$_GET['id']."'")
I assume that the query is the problem because its the only thing that's different between the two.
© Stack Overflow or respective owner