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
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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.