ikscovski Posted July 4, 2007 Share Posted July 4, 2007 hi, i have a query that supose to return all the classes that are taged as 'Available', but i keep getting "use of undefine constant Available" error. the same piece of coide worked befor with my last version of php and now i have upgraded to version 5.2 and i have encountered this error. Is it something in the php.ini file i need to change? Incase its a syntax or my error here is the code $query = "SELECT Class.ClassName, Class.StartDate, Site.SiteName FROM Class INNER JOIN Site ON Class.SiteId = Site.SiteId WHERE Class.ClassId='".$Classid."' AND Class.Space='".Available."';"; $result = mssql_query($query,$db) or die ("Error with Query"); Quote Link to comment Share on other sites More sharing options...
redarrow Posted July 4, 2007 Share Posted July 4, 2007 try this ok. edited sorry <?php $query = "SELECT Class.ClassName, Class.StartDate, Site.SiteName FROM Class as a JOIN Site as b ON (a.Classid = b.SiteId) WHERE a.ClassId='".$Classid."' AND a.Space='".Available."';"; $result = mssql_query($query,$db) or die ("Error with Query") ?> Quote Link to comment Share on other sites More sharing options...
redarrow Posted July 4, 2007 Share Posted July 4, 2007 did it work echo the query out ok. <?php $query = "SELECT Class.ClassName, Class.StartDate, Site.SiteName FROM Class as a JOIN Site as b ON (a.ClassId = b.SiteId) WHERE a.ClassId='".$Classid."' AND a.Space='".Available."';"; $result = mssql_query($query,$db) or die ("mysql_error") echo $query; ?> Quote Link to comment Share on other sites More sharing options...
ikscovski Posted July 4, 2007 Author Share Posted July 4, 2007 tried it...getting errors that says ; Notice: Use of undefined constant Available - assumed 'Available' in C:\Inetpub\wwwroot\php\periodselect.php on line 86 Warning: mssql_query() [function.mssql-query]: message: The multi-part identifier "Class.ClassName" could not be bound. (severity 16) in C:\Inetpub\wwwroot\php\periodselect.php on line 88 Warning: mssql_query() [function.mssql-query]: message: The multi-part identifier "Class.StartDate" could not be bound. (severity 16) in C:\Inetpub\wwwroot\php\periodselect.php on line 88 Warning: mssql_query() [function.mssql-query]: message: The multi-part identifier "Site.SiteName" could not be bound. (severity 16) in C:\Inetpub\wwwroot\php\periodselect.php on line 88 Warning: mssql_query() [function.mssql-query]: Query failed in C:\Inetpub\wwwroot\php\periodselect.php on line 88 mysql_error Quote Link to comment Share on other sites More sharing options...
Varma69 Posted July 4, 2007 Share Posted July 4, 2007 I read somewhere that php has changed it quoting rules either 'from or for' the 4.3 version. Not sure but i think it could be something with that. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 4, 2007 Share Posted July 4, 2007 Im not 100% sure about the mysql errors, but the problem with the undefined constant is that you've closed the quotes - so php thinks your wanting to use a constant called Available. Try: <?php $query = "SELECT Class.ClassName, Class.StartDate, Site.SiteName FROM Class as a JOIN Site as b ON (a.ClassId = b.SiteId) WHERE a.ClassId='".$Classid."' AND a.Space='Available'"; $result = mssql_query($query,$db) or die ("mysql_error") echo $query; ?> They changed which errors were reported in php 5 to include undefined constants and variables. Hence why you've only just seen the error, even though it was there all along. Quote Link to comment Share on other sites More sharing options...
ikscovski Posted July 4, 2007 Author Share Posted July 4, 2007 thanks guys...got it to work but i would just like to know why did it work with my original code and not with the new version of php? thanks again. Quote Link to comment Share on other sites More sharing options...
redarrow Posted July 4, 2007 Share Posted July 4, 2007 you need to use $_POST['']; ok. Quote Link to comment Share on other sites More sharing options...
ikscovski Posted July 4, 2007 Author Share Posted July 4, 2007 GingerRobot...just saw the last part of ur message...ignore my last post. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 4, 2007 Share Posted July 4, 2007 As i said above: They changed which errors were reported in php 5 to include undefined constants and variables. Hence why you've only just seen the error, even though it was there all along. If you look at the error message, it says that it assumes that you wanted to use the string "available". Therefore, php is capable of dealing with the error - basically it just guesses what you wanted. The default setting for error_reporting prior to php 5 did not report errors of this kind. It just attempted to deal with them. Edit: Whoops, saw there was added messages but only registered redarrow's . Ah well, ill leave this here - perhaps it explains a bit further. Glad you understand. 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.