Jump to content

use of undefine constant..?


ikscovski

Recommended Posts

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");

Link to comment
Share on other sites

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")

?>

Link to comment
Share on other sites

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;

?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 :P. Ah well, ill leave this here - perhaps it explains a bit further. Glad you understand.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.