Jump to content

Recommended Posts

Hello Everyone,

 

I am working on a project where I have to go in and grab the names of the fields in a table. I got it to work and for it to show me the field names but it also displays a lot more than what I would like for it to do.

 

I keep getting the following error. It is repeated over my screen like 15 times.

 

Warning: mysql_field_name() [function.mysql-field-name]: Field 5 is invalid for MySQL result index 7 in C:\xampp\htdocs\CMS\admin\includes\get_table.php on line 44

 

This is the section of code that it is referring to. Line 44 is

 

$tablecolumn .= "<p>" . mysql_field_name($fieldnamesquery_result, $table_field) . "<input type='text' name='" . mysql_field_name($fieldnamesquery_result, $table_field) . "' id='" . mysql_field_name($fieldnamesquery_result, $table_field) . "'/>";

 

$tablecolumn = "<form name='insert_table' id='insert_table' action='get_database.php' method='post' >
<fieldset>
<legend>table information</legend>";
    for ($table_field = 2; $table_field < $fieldnamesquery_result; $table_field++) {
        $tablecolumn .= "<p>" . mysql_field_name($fieldnamesquery_result, $table_field) . "<input type='text' name='" . mysql_field_name($fieldnamesquery_result, $table_field) . "' id='" . mysql_field_name($fieldnamesquery_result, $table_field) . "'/>"; <-----This is line 44
    }
    $tablecolumn .= "
<p>
<input type='submit' name='submit_info' id='submit_info' />
</p>
</fieldset>
</form>
";

    echo $tablecolumn;

Link to comment
https://forums.phpfreaks.com/topic/259672-for-loop-giving-to-much-out-put/
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.