cturner Posted January 28, 2007 Share Posted January 28, 2007 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 More sharing options...
Tandem Posted January 28, 2007 Share Posted January 28, 2007 You left a single quote out of echo $row['other1]; Link to comment https://forums.phpfreaks.com/topic/36008-solved-undefined-index/#findComment-170822 Share on other sites More sharing options...
cturner Posted January 28, 2007 Author Share Posted January 28, 2007 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] Link to comment https://forums.phpfreaks.com/topic/36008-solved-undefined-index/#findComment-170851 Share on other sites More sharing options...
Tandem Posted January 28, 2007 Share Posted January 28, 2007 You don't have an argument for mysql_affected_rows().That's most likely what it is. Link to comment https://forums.phpfreaks.com/topic/36008-solved-undefined-index/#findComment-170853 Share on other sites More sharing options...
smc Posted January 28, 2007 Share Posted January 28, 2007 Yes you didn't define the mysql_query for mysql_affect_rows()Also, you didn't specify a mysql_fetch_array($query) to get the row information other1 Link to comment https://forums.phpfreaks.com/topic/36008-solved-undefined-index/#findComment-170857 Share on other sites More sharing options...
utexas_pjm Posted January 28, 2007 Share Posted January 28, 2007 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]<?phperror_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);if($foo['bar'] == 1){ echo 'This will never happen';}?>[/code]Hope this helps.Best,Patrick Link to comment https://forums.phpfreaks.com/topic/36008-solved-undefined-index/#findComment-170862 Share on other sites More sharing options...
cturner Posted January 28, 2007 Author Share Posted January 28, 2007 [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. Link to comment https://forums.phpfreaks.com/topic/36008-solved-undefined-index/#findComment-170882 Share on other sites More sharing options...
cturner Posted January 28, 2007 Author Share Posted January 28, 2007 No need to explain. I have worked it out. Link to comment https://forums.phpfreaks.com/topic/36008-solved-undefined-index/#findComment-170884 Share on other sites More sharing options...
smc Posted January 28, 2007 Share Posted January 28, 2007 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] Link to comment https://forums.phpfreaks.com/topic/36008-solved-undefined-index/#findComment-170888 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.