Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP to MS SQL Undefined Index Error
    primarykey
    data
    text
    <p>I am having an error populating a column in my sql table from my php form. I am getting an Undefined index: ID error. First I will show you my php/html code which displays all my data correctly, I will show screen shots, and then I will show the incorrect populating of answers in my sql table. Thank you for looking and the assistance!</p> <p>This first code is where I create my selection which is working correctly, I believe because everything that I am importing from my sql table shows up properly.</p> <pre><code>&lt;label for="animalCommony"&gt;Common Name&lt;/label&gt; &lt;select name="animalCommony" id="animalCommony" form="form1"&gt; &lt;option&gt;Select a Common Name:&lt;/option&gt; &lt;?php $db = get_db_connection('swcrc'); $db-&gt;connect(); $db-&gt;query("SELECT [Common Name] FROM dbo.All_Animals"); //THE BRACKETS WORK FINE I WILL SHOW //A SCREEN SHOT OF THE FUNCTIONAL FORM while($row = $db-&gt;fetch()) { ?&gt; &lt;option value="&lt;?php echo $row['ID'];?&gt;"&gt;&lt;?php echo $row[`Common Name`];?&gt;&lt;/option&gt; //THIS IS //WHERE I BELIEVE THE ERROR MAYBE COMING FROM THIS IS LINE 570 &lt;?php } ?&gt; &lt;/select&gt; &lt;/p&gt; </code></pre> <p>This next part of code is where I am inserting my select answers into my MS SQL table <em>NOTE</em> everything is populating in my MS SQL table properly except for my animalCommoner variable.</p> <pre><code> $animalClasser = (isset($_POST['animalClassy'])? $_POST['animalClassy']: null); $animalCommoner = (isset($_POST['animalCommony'])? $_POST['animalCommony']:null); //NOT //POPULATING INTO MS SQL DATABASE $db-&gt;query("UPDATE dbo.Request SET status='%s' WHERE ID=%d", $_POST['completed'], $_POST['request_id']); $db-&gt;query("INSERT INTO dbo.Response (request_ID, user_ID, complete, comment, response_date, animalClass, animalCommon) VALUES (%d, %d, '%s', 's', 's', '$animalClasser', '$animalCommoner')", $_POST['request_id'], $_POST['completed_by_user_id'], $_POST['completed'], $_POST['not_completed'], $_POST['date_completed']); </code></pre> <p>Next I will post a screen show of the incorrectly populated sql table. It's a very thin picture. <img src="https://i.stack.imgur.com/dAdFX.jpg" alt="enter image description here"></p> <p>Finally I will post a screen shot of my form to show that it is populating correctly. <img src="https://i.stack.imgur.com/sOuj3.jpg" alt="enter image description here"></p> <p>Thank you for looking and helping! THIS IS THE BLOWN UP MESSAGE OF THE ERROR <img src="https://i.stack.imgur.com/JuqML.jpg" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload