Jump to content

Notice: Undefined offset: 1


Carlton

Recommended Posts

Google has failed me once again  :'(. I'm getting this error, which I can't find out how to fix: Here's the code:

 

$Database_Factions = "factions";
$Database_Factions_1 = "Name";
$Database_FName_Num = 1;

$searchmemberdata = mysql_query("SELECT " . $Database_Factions_1 . " FROM " . $Database_Factions . " WHERE " . $Database_Factions_1 . " LIKE 
                        '" . mysql_real_escape_string($_GET['name']) . "%' LIMIT 1");

$searchdata = mysql_fetch_row($searchmemberdata);
echo($searchdata[$Database_FName_Num]);
echo("<meta http-equiv='refresh' content='55;url=member.php?action=ViewFaction&name=" . $searchdata[$Database_FName_Num] . "' />"); 
                                    

 

I know my code is not optimized, I'm fixing it after i'm done with what i'm doing. Everytime $searchdata[$Database_FName_Num] is called, the error: Notice: Undefined offset: 1 comes out. Any help?

Link to comment
https://forums.phpfreaks.com/topic/222553-notice-undefined-offset-1/
Share on other sites

You are only selecting one column in your query and that value would be accessed using the zero'th element of what mysql_fetch_row() returns.

 

Is there some reason you are not using mysql_fetch_assoc() so that the column name you are fetching in $Database_Factions_1 would be the same associative element name you access in the fetched data?

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.