Jump to content

Change from XAMPP to WAMPP -> Problems with PHP Scripts


mkswanson

Recommended Posts

I just changed from an XAMPP installation to WAMPP.  My PHP scripts were working perfectly, but now they aren't.

 

I get a number of undefined constant errors:

 


Notice: Use of undefined constant EntityID - assumed 'EntityID' in C:\WebServer\www\PollingCenter\SearchResults.php on line 145

Notice: Use of undefined constant CustomerName - assumed 'CustomerName' in C:\WebServer\www\PollingCenter\SearchResults.php on line 145

 

An example that is throwing the error is:

 

$EntityID = @$_GET['EntityID'] ;
$CustomerName = str_replace("'", "", (@$_GET['CustomerName'])) ;
$ProductLine = @$_GET['ProductLine'] ;
$ProductVersion = @$_GET['ProductVersion'] ;
$Format=@$_GET['Format'];
$SQLQuery=@$_GET['SQLQuery'];
$TodayDate=date("Y-m-d");

$SearchEntityID = trim($EntityID);
$SearchCustomerName = trim($CustomerName);
$SearchProductLine = trim($ProductLine);
$SearchProductVersion = trim($ProductVersion);

 

$query = "SELECT ed.EntityID, ed.CustomerName, ed.IsActive, pd.ProductLine, pd.ProductVersion ";
$query .= "FROM ENTITY_DATA ed INNER JOIN ";
$query .= "(SELECT ProductLine, ProductVersion, EntityID, PollingID FROM POLLING_DATA) pd ";
$query .= "ON ed.EntityID = pd.EntityID ";
$query .= "WHERE pd.PollingID = (SELECT max(pollingID) FROM POLLING_DATA WHERE EntityID = ed.EntityID) ";
$query .= "AND ed.IsActive = '1' ";


IF ($SearchEntityID != "" ) {
  $query .= "AND pd.EntityID LIKE '%".$SearchEntityID."%' ";
  }
IF ($SearchCustomerName != "" ) {
  $query .= "AND ed.CustomerName LIKE '%".$SearchCustomerName."%' ";
  }
IF ($SearchProductLine != "" ) {
  $query .= "AND pd.ProductLine LIKE '%".$SearchProductLine."%' ";
  }
IF ($SearchProductVersion != "" ) {
  $query .= "AND pd.ProductVersion LIKE '%".$SearchProductVersion."%' ";
  }

 

//display the results

while($row = mysql_fetch_array($result))

{
  echo '<tr>';
  echo '<td><a href="SiteDetails.php?SiteID=' . $row[EntityID] . '">'. $row[CustomerName] . '</a></td>';
  echo '<td>' . $row[ProductLine] . '</td>';
  echo '<td>' . $row[ProductVersion] . '</td>';
  echo '</tr>';
}

 

Is there a global setting in PHP that might be affecting this?  I have tried multiple versions of PHP (5.3.0, 5.2.11, and 5.2.9-2) with no effect.

 

Thanks for any help!

 

Link to comment
Share on other sites

If you considered your code to be running perfectly before, then good news it's still running just as perfectly. By default XAMPP has error messaging set to E_ALL & ~E_NOTICE, which means show all error messages but not notices. I imagine that the default setting in WAMP must be set to E_ALL. Meaning show me everything.

 

Generally speaking you get undefined constant if you have a line like

 

$EntityID = $_GET[EntityID] ;

 

Because the key isn't enclosed in quotation marks it assumes its a constant not a sting, upon realising it's not a constant it uses a string with the value of the constant name. Obviously in your situation your getting when you do have the string. I can only assume this is something todo with the @ sign which surpresses errors. Normally on the line of code you have  you'd expect to see...

 

Notice: Undifined index

 

Anyway, you can either ignore the notices as that's what you were doing before, or you can go through sorting them out, it's up to you.

 

EDIT: Never read your code carefully enough, it's the code further down throwing that error, ignore the stuff about the @ sign.

Link to comment
Share on other sites

Yeah, as cags said, it's of course up to you, but I strongly suggest that you fix it.

 

 

Notices are there for a reason, and generally you should try to straighten them all out.  In this case, there are two main pittfalls:

 

Performance.  It's a slight performance hit every time a notice is thrown.

Later on if a constant is defined as one of those then your code will break.

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.