Notice: Undefined index PHP error-Collection of common programming errors
This line:
is giving me the undefined index error. But I don’t understand why that is giving me an error when other queries don’t. Here’s the query I used. This is all made in Dreamweaver
mysql_select_db($database_project, $project);
$query_stuCompSci = "SELECT compsci.CSid FROM compsci WHERE NOT EXISTS ( SELECT studentcourses.Cid FROM studentcourses WHERE studentcourses.Cid=compsci.CSid )";
$stuCompSci = mysql_query($query_stuCompSci, $project) or die(mysql_error());
$row_stuCompSci = mysql_fetch_assoc($stuCompSci);
$totalRows_stuCompSci = mysql_num_rows($stuCompSci);
In the query, the table studentcourses has two columns (Sid, Cid) and the 2nd table compsci has two columns as well (CSid, Credits).
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.
-
Your query contained:
SELECT compsci.CSid FROM ...
Note the query is
CSid
, notCid
-
it mean that you havent selected
Cid
in query try"SELECT compsci.Cid,compsci.CSid FROM compsci WHERE NOT EXISTS ( SELECT studentcourses.Cid FROM studentcourses WHERE studentcourses.Cid=compsci.CSid )";
-
You are calling
Cid
in Phpbut haven’t selected
Cid
in query. Do thisSELECT compsci.Cid,compsci.CSid FROM ....
Originally posted 2013-11-09 23:31:45.