gammaman Posted April 21, 2008 Share Posted April 21, 2008 Can I test for NULL in a query, something like this, but this does not work. $result=mysql_query("select CourseID,StudentID, Grade FROM Rcourse WHERE CourseID ='$CourseID' AND StudentID = '{$_SESSION['student']['user']}' AND Grade = NULL"); Quote Link to comment Share on other sites More sharing options...
dptr1988 Posted April 21, 2008 Share Posted April 21, 2008 Use 'Grade IS NULL' rather then 'Grade = null' Quote Link to comment Share on other sites More sharing options...
dptr1988 Posted April 21, 2008 Share Posted April 21, 2008 Some more info from the mysql manual: http://dev.mysql.com/doc/refman/5.0/en/working-with-null.html Quote Link to comment Share on other sites More sharing options...
gammaman Posted April 21, 2008 Author Share Posted April 21, 2008 No, that did not work. Maybe I am not explaining myself correctly. I want the query to select the row where the Grade field has no value yet. Quote Link to comment Share on other sites More sharing options...
dptr1988 Posted April 21, 2008 Share Posted April 21, 2008 What is the default value for the grade column? If the column definition contains a default value, then use that value. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted April 21, 2008 Share Posted April 21, 2008 $result=mysql_query("select CourseID,StudentID, Grade FROM Rcourse WHERE CourseID ='$CourseID' AND StudentID = '{$_SESSION['student']['user']}' AND Grade IS NULL"); That SHOULD work. O_O Works for me. Quote Link to comment Share on other sites More sharing options...
gammaman Posted April 21, 2008 Author Share Posted April 21, 2008 The default value is NULL, meaning there is no defalut value. Still cannot get it working. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted April 21, 2008 Share Posted April 21, 2008 Do you get any mysql errors, or just no rows returned? Quote Link to comment Share on other sites More sharing options...
gammaman Posted April 21, 2008 Author Share Posted April 21, 2008 Funny, but your code seems to be working now, I think I may have forgotten to reload the page after uploading the new version onto the server. I will let you know if I run into any more problems. P.S. : I don't have the code available right now but you were helping me with an insert query using $_SESSIONS early today and I still cannot get that working either. Thanks for all of your help. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted April 21, 2008 Share Posted April 21, 2008 If you want me to really look at the INSERT issue, censor out your database details and send me the connect, config, and insert scripts and I'll have a look. Put them all in a zip or tar file and put them on like, megaupload. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.