Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing value of a field undefined error
    primarykey
    data
    text
    <p>I am getting Undefined error and I don't understand why...</p> <p><strong>"<b>Notice</b>: Undefined index: test in ..."</strong></p> <p>Here is pageA Full source code:</p> <pre><code>&lt;?php if(isset($_POST['save'])) { print "&lt;pre&gt;"; print_r($_POST); print "&lt;/pre&gt;"; } ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;title&gt;&lt;/title&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"&gt;&lt;/script&gt; &lt;script&gt; $(document).ready(function(){ $('#my_form').submit(function(event) { event.preventDefault(); $.post("pageB.php", {'elm1' : tinyMCE.get('elm1').getContent()}, function (response) { alert(response) }); }); }); &lt;/script&gt; &lt;!-- TinyMCE --&gt; &lt;script type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; tinyMCE.init({ // General options mode : "textareas", theme : "advanced", plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount", // Theme options theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect", theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor", theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen", theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_statusbar_location : "bottom", theme_advanced_resizing : true, // Example content CSS (should be your site CSS) content_css : "css/content.css", // Drop lists for link/image/media/template dialogs template_external_list_url : "lists/template_list.js", external_link_list_url : "lists/link_list.js", external_image_list_url : "lists/image_list.js", media_external_list_url : "lists/media_list.js", // Replace values for the template plugin template_replace_values : { username : "Some User", staffid : "991234" } }); &lt;/script&gt; &lt;!-- /TinyMCE --&gt; &lt;script&gt; function doSomething(elem) { var currentval = elem.options[elem.selectedIndex].value; // you could navigate away at that point ? window.location = currentval; } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;?php $con = mysql_connect('localhost', 'root', 'dev'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("myDB"); $request = mysql_query("select id FROM pages"); echo "&lt;select onchange='doSomething(this)'&gt;"; while ($drow = mysql_fetch_assoc($request)) { echo '&lt;option value="view.php?id='.$drow['id'].'"&gt;'.$drow['id'].'&lt;/option&gt;'; } echo "&lt;/select&gt;"; ?&gt; &lt;form id="my_form" method="post" action="pageB.php?id=&lt;?php echo (int)id; ?&gt;"&gt; &lt;div&gt; &lt;h3&gt;View Page&lt;/h3&gt; &lt;!-- Gets replaced with TinyMCE, remember HTML in a textarea should be encoded --&gt; &lt;div&gt; &lt;textarea id="elm1" name="elm1" rows="15" cols="80" style="width: 80%"&gt; &lt;?php $con = mysql_connect('localhost', 'root', 'dev'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("myDB"); $id = (int)$_GET['id']; $query = "SELECT * FROM pages where id=$id"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); $contents = $row['content']; echo $contents; ?&gt; &lt;/textarea&gt; &lt;/div&gt; &lt;br /&gt; &lt;input id="submit_page_changes" type="submit" name="save" value="Submit" /&gt; &lt;input type="reset" name="reset" value="Reset" /&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>THIS IS THE FULL CODE OF PAGEB</p> <pre><code>&lt;?php $con = mysql_connect("localhost","root","dev"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("myDB"); $id = (int)$_GET['id']; //ERROR POINTS TO HERE $sql="UPDATE pages SET content=('$_POST[elm1]') WHERE id='.$id.'"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; $query = "SELECT * FROM pages where id=1"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); $contents = $row['content']; echo $contents; mysql_close($con) ?&gt; </code></pre> <p>ERROR IS:</p> <p><strong><br /> <b>Notice</b>: Undefined index: id in <b>C:\wamp\www\pageB.php</b> on line <b>10</b><br /> 1 record added<p>Test 212345</p></strong></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