Jump to content

[SOLVED] Undefined index


cturner

Recommended Posts

Can someone please have a look at my code and tell me why I am getting the error that is below:
Notice: Undefined index: other1 in /home/account/public_html/folder1/folder2/edit_property.php on line 627.

[code]
<input type="text" name="other1" size="26" style="display: none;" value="<?php if (mysql_affected_rows() >= 0) { echo $row['other1]; } else { echo $other1; } ?>" /> // this is line 627
[/code]
Link to comment
https://forums.phpfreaks.com/topic/36008-solved-undefined-index/
Share on other sites

I am still getting that error. I have posted the updated code here:
[code=php:0]
<input type="text" name="other1" size="26" style="display: none;" value="<?php if (mysql_affected_rows() >= 0) { echo $row['other1']; } else { echo $other1; } ?>" />
[/code]
That's not an error it's just a notice.  It's telling you that the index 'other1' is undefined in your $row array.

You can duplicate that notice by doing this:

[code]
<?php

error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

if($foo['bar'] == 1){
  echo 'This will never happen';
}

?>
[/code]

Hope this helps.

Best,

Patrick
[quote author=utexas_pjm link=topic=124355.msg515115#msg515115 date=1169948383]
That's not an error it's just a notice.  It's telling you that the index 'other1' is undefined in your $row array.
[/quote]
utexas_pjm, can you please explain what you mean by the above? And how I can get rid of the notice.
Well I'm not sure if you've set it up this way in the rest of your code but you should be award that in order to get the information for echoing a particular substance you need to specify where to echo it from.

This is the proper code format for bringing something to the surface for echoing, I've also included assigning it to a variable (as it's generally easier to remember)

[code]
$yourquery = mysql_query("SELECT * FROM mytable WHERE mycolumn = '$myvariabletocheck'");
while ( $row = mysql_fetch_array($yourquery) ) {
    $myvariabletoassign = $row['other1'];
}
echo $myvariabletoassign;
[/code]

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.