Note that there are some explanatory texts on larger screens.

plurals
  1. POUndefined index for ID with $_GET
    primarykey
    data
    text
    <p>Well, yet another undefined index appears :</p> <p>I am trying to change a select row in a database, but so far it doesn't seem to work, I only get </p> <blockquote> <p><code>Notice: Undefined index: EierID in C:\WampServer\www\Hundeklubben\ChangeO.php on line 19.</code></p> </blockquote> <p>I have tried some fixes, but none worked.</p> <pre><code>&lt;?php require_once('Connections/hundeklubb.php'); ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Endring av eier&lt;/title&gt; &lt;link rel="stylesheet" href="index.css" /&gt; &lt;/head&gt; &lt;body&gt; &lt;?php if(isset($_GET['EierID'])){ $name = $_GET['EierID']; } //Tried with both $_GET and $_POST ?&gt; &lt;?php $UID = (int)$_GET['EierID']; $query = mysql_query("SELECT * FROM eiere WHERE EierID = '$UID'") or die(mysql_error()); if(mysql_num_rows($query)&gt;=1){ while($row = mysql_fetch_array($query)) { $navn = $row['Navn']; $bosted = $row['Bosted']; } ?&gt; &lt;form name="form1" action="update.php" method="POST" id="form1"&gt; &lt;input type="hidden" name="ID" value="&lt;?=$UID;?&gt;"&gt; Navn: &lt;input type="text" name="ud_navn" value="&lt;?=$navn?&gt;"&gt;&lt;br&gt; Bosted: &lt;input type="text" name="ud_bosted" value="&lt;?=$bosted?&gt;"&gt;&lt;br&gt; &lt;input type="Submit" value="Oppdater"&gt; &lt;/form&gt; &lt;?php }else{ echo 'No entry found. &lt;a href="javascript:history.back()"&gt;Go back&lt;/a&gt;'; } ?&gt; &lt;?php var_dump($UID); ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The <code>var_dump</code> gives me <code>int 0</code>. I'm not sure what it is supposed to be.</p> <p><strong>update.php</strong></p> <pre><code>&lt;?php require_once('Connections/hundeklubb.php'); ?&gt; &lt;?php $ud_ID = (int)$_POST["ID"]; $ud_navn = mysql_real_escape_string($_POST["ud_navn"]); $ud_bosted = mysql_real_escape_string($_POST["ud_bosted"]); $query="UPDATE eiere SET navn = '$ud_navn', bosted = '$ud_bosted' WHERE ID='$ud_ID'"; mysql_query($query)or die(mysql_error()); if(mysql_affected_rows()&gt;=1){ echo "&lt;p&gt;($ud_ID) Record Updated&lt;p&gt;"; }else{ echo "&lt;p&gt;($ud_ID) Not Updated&lt;p&gt;"; } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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