{"id":1138,"date":"2022-08-30T15:13:01","date_gmt":"2022-08-30T15:13:01","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/notice-undefined-index-php-error-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:13:01","modified_gmt":"2022-08-30T15:13:01","slug":"notice-undefined-index-php-error-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/notice-undefined-index-php-error-collection-of-common-programming-errors\/","title":{"rendered":"Notice: Undefined index PHP error-Collection of common programming errors"},"content":{"rendered":"<p>This line:<\/p>\n<pre><code>\n<\/code><\/pre>\n<p>is giving me the undefined index error. But I don&#8217;t understand why that is giving me an error when other queries don&#8217;t. Here&#8217;s the query I used. This is all made in Dreamweaver<\/p>\n<pre><code>mysql_select_db($database_project, $project);\n$query_stuCompSci = \"SELECT compsci.CSid FROM compsci WHERE NOT EXISTS  ( SELECT      studentcourses.Cid FROM studentcourses WHERE studentcourses.Cid=compsci.CSid )\";\n$stuCompSci = mysql_query($query_stuCompSci, $project) or die(mysql_error());\n$row_stuCompSci = mysql_fetch_assoc($stuCompSci);\n$totalRows_stuCompSci = mysql_num_rows($stuCompSci);\n<\/code><\/pre>\n<p>In the query, the table studentcourses has two columns (Sid, Cid) and the 2nd table compsci has two columns as well (CSid, Credits).<\/p>\n<p>The query gets whatever Cid does not exist in student courses and when I test the query it works fine, however, when I try to see my website live it gives me the index error. If need be, I can copy my whole code in here but it about 220 lines long.<\/p>\n<ol>\n<li>\n<p>Your query contained:<\/p>\n<pre><code>SELECT compsci.CSid FROM ...\n<\/code><\/pre>\n<p>Note the query is <code>CSid<\/code>, not <code>Cid<\/code><\/p>\n<\/li>\n<li>\n<p>it mean that you havent selected <code>Cid<\/code> in query try<\/p>\n<pre><code> \"SELECT compsci.Cid,compsci.CSid FROM compsci WHERE NOT EXISTS  ( SELECT      studentcourses.Cid FROM studentcourses WHERE studentcourses.Cid=compsci.CSid )\";\n<\/code><\/pre>\n<\/li>\n<li>\n<p>You are calling <code>Cid<\/code> in Php<\/p>\n<pre><code>\n<\/code><\/pre>\n<p>but haven&#8217;t selected <code>Cid<\/code> in query. Do this<\/p>\n<pre><code>SELECT compsci.Cid,compsci.CSid FROM ....\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-09 23:31:45. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>This line: is giving me the undefined index error. But I don&#8217;t understand why that is giving me an error when other queries don&#8217;t. Here&#8217;s the query I used. This is all made in Dreamweaver mysql_select_db($database_project, $project); $query_stuCompSci = &#8220;SELECT compsci.CSid FROM compsci WHERE NOT EXISTS ( SELECT studentcourses.Cid FROM studentcourses WHERE studentcourses.Cid=compsci.CSid )&#8221;; $stuCompSci [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1138","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1138","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1138"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1138\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1138"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}