Warning: Invalid argument supplied for foreach() in C:\wamp64\www\add_vhost.php on line 1065
Posted by: DJMarvin54 (---.us-east-2.compute.amazonaws.com)
Date: August 28, 2022 04:12PM

I am trying to set up a WordPress site on my PC but haven't been able to. I have done the WP install many times without any issues but am now running into one snag after another. I must be doing something wrong but don't know what that is. I went through my system and followed instructions from this forum to remove all virtual hosts and all WP files, etc. I thought I had everything set up correctly and tried to setup a new virtual host. I got this warning and the set up stopped:

Warning: Invalid argument supplied for foreach() in C:\wamp64\www\add_vhost.php on line 1065

1. Even though the "W" is green, is it possible that my instance of WAMPServer is corrupt and needs to be reinstalled?

2. If I need to reinstall WampServer, what is the correct process to follow? (I couldn't find any instructions when I searched the forum.)

I followed all the pre-install instructions for installing WampServer. I verified that all the MS Windows Visual C++ Packages are installed.

I don't recall whether I installed WAMPServer as administrator. My user role is set as "Administrator" but I believe I have to specify "Run as Administrator" when I run the setup. I just don't recall doing this.

Here are my answers to the questions about my setup:

1 - Windows version used: Windows 11 Pro Version 21H2 64-bit

2 - Version of WampServer: 3.2.9 64 bits

3 - Apache Version: Apache 2.4.46 Port 80

4 - PHP Version: PHP 7.4.9

5 - PHP 5.6.40 for CLI (Command-Line Interface)

5 - MySQL Version: MySQL 5.7.31 Port 3306

5a - MariaDB version if applicable: Not applicable

6 - What color is the WampServer icon: Green

Options: ReplyQuote
Re: Warning: Invalid argument supplied for foreach() in C:\wamp64\www\add_vhost.php on line 1065
Posted by: Otomatic (Moderator)
Date: August 28, 2022 04:45PM

Hi,

You can reinstall the 3.2.9 update several times in a row without any problem, but before that it is necessary to :

- Verify that all VC ++ packages are installed and with the latest versions.
To do this, use the tool:
Checks VC++ packages installed
Do not use a previously loaded tool. Make a new download to make sure you are using the correct version.
To download missing packages, do not rely on Microsoft links, they are not reliable, download packages on http://wampserver.aviatechno.net in section Visual C++ Redistribuable Packages
Do not forget that if you have a 64 bit Windows, you must install both 32 and 64 bit versions of each package.
You must install each package "as an administrator", so right-click the exe file and then run as Administrator.

- Apply Update 3.2.9 to your version of Wampserver
Wampserver update 3.2.9

Apache 2.4.46 and php 7.4.9 are very old. Install Apache 2.5.54 and PHP 7.4.30 addons then switch to these versions.

Remember that the VirtualHost must exist before installing WordPress.
Why to create a VirtualHost BEFORE installing a CMS

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

Options: ReplyQuote
Re: Warning: Invalid argument supplied for foreach() in C:\wamp64\www\add_vhost.php on line 1065
Posted by: DJMarvin54 (---.us-east-2.compute.amazonaws.com)
Date: September 30, 2022 11:02PM

Time for an update about this issue. In a nutshell, WampServer was not the problem. I am hoping others will find some this information useful.

I did everything as directed but continued to have problems. I then decided to try everything on a different PC. Both met all the requirements and I did the install as administrator. The second PC worked perfectly.
This indicates to me that my various issues were caused by something on the PC itself and not with WAMP.

The computer I was having trouble with is a Dell XPS 17 9700.

The network adaptor is a Killer(R) Wi-Fi 6 AX1650s 160MHz Wireless Network Adapter (201D2W)

I believe the issue has something to do with the network adaptor and its settings. This suspicion arises from other issues I've been having since upgrading to Windows 11. The most obvious and annoying one is not be able to sign into sites like the Microsoft Store. I get errors that I have not yet deciphered. I reset the adaptor using the software app it comes with - something called "Killer Intelligence Center" and updated the driver for the adaptor. This fixed some of my issues.

I then focused on WAMPServer. I took the following steps and was able to get my WordPress issues resolved in WAMPServer:

I updated PHP to 7.4.9 which cleared all the errors I was getting. I now have to go to PHP 8.0.24 to fix an unrelated WordPress issue. This will require updating phpMyAdmin which I am about to tackle.

Options: ReplyQuote
Re: Warning: Invalid argument supplied for foreach() in C:\wamp64\www\add_vhost.php on line 1065
Posted by: foo (---.bb.vodafone.cz)
Date: November 09, 2022 09:26AM

Warning: Invalid argument supplied for foreach() in C:\wamp64\www\add_vhost.php on line 1065 is caused by a bug introduced to add_vhost.php with update adding FCGI select PHP version form to virtual host creation page.

In this script, $message array is used to collect messages from script to display them later (on line 1065). The problem is that on line 763, newly added code assign string to $message variable (it uses it only for its own purpose, so that is just a name collision).


If you want to fix this issue before official fix is available, seek code below starting on line 763 of add_vhost.php:


$message = str_replace(' ','  ',$langues['fcgi_mode_help']);
$message = str_replace('<code>',"<code class='normal'>",$message);
$message = nl2br($message);
//Dialog modal help FCGI
$divHelpFCGI = <<< EOF
<div id="helpfcgi" class="modalOtoArial">
<div>
<div class='modalOtoBar'><input type='button' value='Copy' class='js-copyb' data-target='#tocopyb'>
<a href="#closeOto" title="Close" class="closeOto">X</a>
</div>
<div id="tocopyb">{$message}</div>

and replace every use of $message in this piece of code with another variable name, for example $messageFCGI.

That shoul fix error in subject.

Options: ReplyQuote
Re: Warning: Invalid argument supplied for foreach() in C:\wamp64\www\add_vhost.php on line 1065
Posted by: Otomatic (Moderator)
Date: November 09, 2022 10:46AM

Hi,

Thank you. This is exactly the correction that needs to be made and will be effective with the 3.3.0 update.
This update, along with a new full version 3.3.0 will be released with PHP 8.2.0 official.

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

Options: ReplyQuote


Sorry, only registered users may post in this forum.