Why can't I access a php namespace after upgrading to latest wampserver?
Posted by: FasterTowhee (---.oc.oc.cox.net)
Date: January 31, 2015 09:55AM

I'm using WAMPSERVER 2.5 and PHP version 5.5.12 on Windows 8 PC. I created a namespace which worked fine when I was running PHP version 5.2.12. After upgrading to php version 5.5.12 I'm getting error message about undefined index which seem to mean that the namespace is not being used.

Here's what the error message looks like:

Notice: Undefined index: postmax in C:\Users\my\Documents\sports\uploads\form.php on line 60 Call Stack #TimeMemoryFunctionLocation 10.0028256592{main}( )..\form.php:0 " data-displaymax="

Here's what the file UploadFile.php looks like:

<?php
namespace foundationphp;

class UploadFile
{
.....
}



and here's form.php
<?php
use namespace\UploadFile;

$max = 50 * 1024;
$result = array();
if (isset($_POST['upload'])) {
require_once 'src/namespace/UploadFile.php';
$destination = __DIR__ . '/uploaded/';
try {
$upload = new UploadFile($destination);
$upload->setMaxSize($max);
$upload->allowAllTypes();
$upload->upload();
$result = $upload->getMessages();
} catch (Exception $e) {
$result[] = $e->getMessage();
}
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>File Uploads</title>
<link href="styles/form.css" rel="stylesheet" type="text/css">
</head>
<body>
....
</body>
</html>

I haven't changed anything in the code. I simply installed the latest version of WAMPSERVER 2.5. What do I need to configure on the new version to have access to namespaces? Thanks for any help!

Options: ReplyQuote
Re: Why can't I access a php namespace after upgrading to latest wampserver?
Posted by: Otomatic (Moderator)
Date: January 31, 2015 10:52AM

Hi,

> Here's what the file UploadFile.php looks like:
The error is not in this file but in C:\Users\my\Documents\sports\uploads\form.php on line 60

Surely you have not changed anything in the script, but PHP 5.5.12 will not tolerate some errors that were not displayed with PHP 5.2.12.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: Why can't I access a php namespace after upgrading to latest wampserver?
Posted by: FasterTowhee (---.oc.oc.cox.net)
Date: January 31, 2015 06:09PM

...but I haven't changed anything in the file... I just upgraded the version of php by installing the latest wampserver. Here's what's on line 60

data-postmax="<?php echo $_SESSION['postmax'];?>"

is it formatted wrong for version 5.5.12 perhaps?

Options: ReplyQuote
Re: Why can't I access a php namespace after upgrading to latest wampserver?
Posted by: RiggsFolly (---.as43234.net)
Date: January 31, 2015 06:52PM

The basic statement is functionally correct.

However, it is coded very badly. You should always check for the existance of a variable that may or may not be there before trying to make use of it.


I would bet money that this is just a PHP configuration change that you forgot to move from your old php.ini to your new one.

When you want to run Badly Written PHP code it is usual to change this php.ini parameter to Off

display_errors = Off

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: Why can't I access a php namespace after upgrading to latest wampserver?
Posted by: Otomatic (Moderator)
Date: January 31, 2015 06:53PM

Hi,

No, the error said that $_SESSION['postmax']; does not exist ie the index 'postmax' is not defined anywhere before you want to "echo" the content.

May be there is some PHP extension or parameter that was enabled with PHP 5.2.12 and not enabled with PHP 5.5.12 or a PHP parameter.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: Why can't I access a php namespace after upgrading to latest wampserver?
Posted by: FasterTowhee (---.oc.oc.cox.net)
Date: February 01, 2015 06:26AM

So I turned of display_errors=Off and all but one error is now showing. This one says:

php_network_getaddresses: getaddrinfo failed: No such host is known. (2002).

Nothing else is on the page just this message.

I think Otomatic is correct buwhat parameter could it be that needs changing. I didn't think that i needed to make a copy of the old php.ini file so I'm at a lost.

Also I seem to have php.ini in two locations. One in wamp\bin\php\php5.5.12\php.ini and the other in wamp\bin\apache\apache 2.4.9\bin\php.ini. Since I didn't know which one to modify I did the same to both then restarted all services.

Still the same error: php_network_getaddresses: getaddrinfo failed: No such host is known. (2002).

Any adea what I may need to change in php.ini?

Options: ReplyQuote
Re: Why can't I access a php namespace after upgrading to latest wampserver?
Posted by: Otomatic (Moderator)
Date: February 01, 2015 10:08AM

Hi,

The "good" php.ini is:
Wampmamaner Icon->PHP->php.ini
that correspond to wamp/apache/apachex.y.z/bin/php.ini

May be these parameter should be validated:
Wampmanager Icon->PHP->PHP Settings->allow url fopen
Wampmanager Icon->PHP->PHP Settings->allow url include

and these extension should be validated
Wampmanager Icon->PHP->PHP extensions->php_sockets

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote


Sorry, only registered users may post in this forum.