Php code not executing on web browsers [duplicate] - php

I just did a fresh install of Apache server 2.2.
Everything works. When I go to localhost I get: "It Works!"
I just installed mySQL5.5 and when I go to localhost:3306 I just get gibberish:
J���
5.5.22�'���4[LM{D~p�ÿ÷!�€����������6[I=4/+,9z{|�mysql_native_password�!��ÿ„#08S01Got
packets out of order
I see many posts on the internet with users with similar problems, but I can't figure out a solution.
Can anyone help?

The mysql service is not a web interface - you cannot connect using a browser. You will need to install a mysql client of some kind.

If you try to start phpmyadmin then do it like this:
localhost/phpmyadmin

I'm a jsp beginner.
I have a same problem with you.
I guess it's kind of port problem.
For me, I had set the port for Apache server connector as 9090.
Later, when I installed mysql, the port for mysql was 3306 as its default port.
In my jsp file,
i loaded jdbc driver like 'jdbc:mysql://localhost:9090/dbname'
and then i call 'http://localhost:9090/my.jsp' on my web browser.
That's when I got the same problem with you.
I fixed the port part in my jsp file like 'jdbc:mysql://localhost:3306/dbname'
and I could get it all right.
I think you need to check the port for your Apache server.
You can check out \conf\server.xml file in your Apache directory.
The part starts with "Connector port=8080...." in server.xml file.
If so, you need to put 'http://localhost:8080... on your browser.

Try just to write http://localhost/ without the port and it will work , Or go to your phpmyadmin and click on My websites and it will take you immediately to your localhost

I'm having exactly the same problem, so far I have :
1)Manually changed the Collation (it seemed to be defaulting to cp850)
2)altered the ini/cnf file (located under services.msc -> MySQL)
3)Changed the max_packet_size to 2G
3)rebooted the server.
As a start to this please run this script from MySQL
'SHOW VARIABLES WHERE Variable_name LIKE 'character_set_%' OR Variable_name LIKE 'collation%';'
It should bring up a table of your collations, they should all read utf8
Possible causes

Related

How to fix WAMP page access when using IP Address instead of localhost in the URL

I have recently built my local test server WAMP by using Windows 7 Pro 64bit OS. I have also chosen to use the 32bit programs (Apache, MySQL & PHP) so my WAMP spec would be x86 V11 binary Thread Safe (TS). I want to keep all development related items into the C:\dev folder or directory, so my file system looks like this:
C:\dev\bin\apache24\
C:\dev\bin\MySQL5.6\
C:\dev\bin\PHP5.6\
C:\dev\www\phpMysqlAdmin
C:\dev\www\HollyGhost.com\login.php
Settings: my.ini
# Path to the installation directory.
basedir = "C:/dev/bin/MySQL5.6/"
# Path to the database data directory
datadir = "C:/dev/bin/MySQL5.6/data/"
# The TCP/IP Port the MySQL Server will listen on
port = 3306
# Server Id.
server_id = 1
C:\Winows\System32\drivers\etc\hosts
127.0.0.1 localhost
If I need to view the web site: http://localhost/HollyGhost.com/login.php the site comes up without any issues and works great; but if I rewrite the URL on the same box to: http://127.0.0.1/HollyGhost.com/login.php the site renders the login page but I cannot log into the system. All I am getting when I attempt to log in is the login page keeps refreshing. I tried to do the same from another PC and I am getting the same result. I need to do this so I can test other devices locally.
Any help is greatly appreciated. I am not sure if this issue is a permission problem based on the fact that MySQL data is stored in the \MySQl5.6\data directory. If so, how do I go about fixing it.
The problem was in the Windows Firewall -> Advance setting -> Inbound Rules. The Inbound Rules for MySQL Profile was set to Private and the Program was set to Any. I change Profile to "Domain, Private" and set Program to point to MySQL installation directory "MySQL.exe" this works for me after rebooting all network devices and PCs.

WordPress Error establishing a database connection

I am new to WordPress, and I am trying to setup it at my local machine.
I am getting error like "Error establishing a database connection".
I tried all solutions from WP blogs,
created new user with all privileges
tired with root user.
created and deleted the target database multiple times.
Nothing is working.
Does anyone know anything else I can try?
Error establishing a database connection doesn't get any simpler than that. Your password, database name, user name, or host is wrong. See http://codex.wordpress.org/Common_WordPress_Errors#Error_Establishing_Database_Connection
Are you sure about using localhost as the server? Are you using MAMP or WAMP?
Try using Adminer http://www.adminer.org/ on your PC/Mac to find the database name, etc., and to admin the database when needed.
If you know can use a shell, try logging into the MySQL server and trying
mysql> show databases;
to list all databases to check your database name.
And try
mysql> mysqlserverinfo --server=root:pass#localhost -d --format=vertical
to get port info, etc. See http://dev.mysql.com/doc/mysql-utilities/1.6/en/mysqlserverinfo.html
I used MAMP for the MySQL server, and used its phpMyAdmin interface to create the database for WordPress and specify its user and password.
Host, for the new database, was "%" on the "User" tab of phpMyAdmin, which it said was supposed to allow any value, and did let me get a certain way through the process. But, I ended up going into "Login Information" under the "User" tab in phpMyAdmin, and changing "%" to "localhost".
That allowed me to finish setting up WordPress.
For future readers, if you are on OSX Yosemite (possibly other versions of OSX as well) and get "Error establishing a database connection" with a local WordPress installation, you may need to do the following:
sudo mkdir /var/mysql
sudo chmod 755 /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
Yosemite looks in the wrong location for the mysql.sock file, so creating this symlink to the correct location solves the problem.
The reason the missing symlink is a problem for WordPress specifically is because in your wp-config.php file, define('DB_HOST', 'localhost'); will not work. An alternative workaround is to change this value in your wp-config file to define('DB_HOST', '127.0.0.1');.
The OP didn't say what details they changed in their wp-config file to solve the problem (perhaps it was this DB_HOST parameter) so I just thought I'd post this since I wasted a lot of time trying to figure it out!
I tried all these suggestions and still couldn't get it to work. However, I had installed MySQL v8.0.12 and noticed that in the 'Users and Privileges' section, under the user I had set up, the 'Authentication Type' for the password was set to some kind of 'sha2' setting.
After trying 100 different things, I eventually fixed this by uninstalling then re-installing MySQL, and during the re-installation, specifically choosing the option button that refers to maintaining compatibility with previous versions of MySQL.
I think this resulted in my passwords not being automatically hashed, which enabled Wordpress to successfully connect to my MySQL database.
What worked for me:
-I moved the wp-config.php file into another folder
-Refreshed the browser and Wordpress will try to re-install
-choose a language
-A message should say Wordpress is already installed and will take you to the database setup page.
-Enter the same db name, username, password, and host (usually localhost).
-Got to www.yoursite.com/admin and you should be able to log in.
I had this issue and I have searched a lot but no one mentioned a fix like mine!
I checked my disk size and I found that my disk size was 100% used. I tried to clean up some of the files but still there were very large files taking up a lot of space. I kept looking and found that the mysql ./data folder occupied 90% of my disk space. It was the binlog files! Very large files I ended up cleaning them up using the Reset Master method. There is another method PURGE BINARY LOGS which didn't work for me. I had to use Reset Master. Just follow the steps and make sure you have a good backup. Good Luck.
Try this before anything! It fixed my issue.
sudo service mysql restart

xampp not working, just installed

I just downloaded xampp from "https://www.apachefriends.org/index.html" this link, and switched off my defender as it asked me to, after instaling, i ran it and switched on mysql and clicked admin on the gui but i get this " The web page is not available ", even though mysql is stil higlighited green in the ui, i even tried localhost:3306 as my port is 3306 and my pid is 4584, but still got " the web page not available" am i doing anything wrong here?
Check your server error logs under <XAMPP_INSTALLATION_PATH>/apache/logs/ directory. It will guide you if any port is already occupied.
I agree with #ErasmoOliveira as most of the time I faced similar thing & exiting skype fixed this issue.
run your XAMPP, then click Setup (Apache line), click on Apache (httpd.conf). in this file find the line Listen 80, change 80 with another port, example: type 81 or 8080 or whatever you want but that it respects the format /^[8]{1}[\d]{1, 3}$/
restart apache again, you will surely work correctly by tapping to your browser http://localhost:81 (if you replaced the port to 81)

Blank pages shown by wamp server even after changing port number

When i run my wamp server and run localhost:80 in chrome browser, It is showing me blank page. Then i changed my port number to 84 in httpd.conf file. Even then it is showing blank page.
I tried with different port numbers(85, 86, 8084) and also stopped skype process which uses port 80.
Could any one suggest me how to solve this problem?
You'd likely get a 404 if your webserver were misconfigured. A blank page typically means a PHP error.
Check your error logs. You can find the log location in httpd.conf
Fix your PHP issue. The logs have the file and line number.
1) You have to restart wamp server every time you change something in your config
2) Set everything back to default in wamp server or just re-install it
3) Open up skype, go to Tools -> Options..., Go to Advanced -> Connection And uncheck Use port 80 and 443 as alternatives for incoming connections -> Save
4) Launch WAMP again -> enjoy :)
Same issue, here is the solution !
(there is more than one file to change in order to go to different port)
Cause :
Another program (Skype but not only) is using the port80 (which is by default the one used by wamp).
You can see it typing the following command "netstat -ano" and looking what is on "localadress 0.0.0.0.80", if you want to see the concerned program open, note the number at the end of the line (4 for example), then open taskmanager, services, and see who is on PID 4.
Solution :
Let's change wamp port to 81 !
Change wamp port from 80 to 81

http://localhost/ not working on Windows 7. What's the problem?

I have a big problem opening http://localhost/ on Windows 7 (beta). I installed this os and everything went great; when I installed Wamp I saw that localhost is not working at all. I just see this error:
Failed to Connect
Firefox can't establish a connection to the server at localhost.
in Mozilla and Explorer.
I removed Wamp and after some weeks (that means two weeks from today) I installed NetBeans on Windows 7. I created a test PHP script and when I debug it, I get the same error again. I tried to access it with ip 127.... but still the same. What is the problem?
When i installed NetBeans I installed it in port 8080.
If you installed it on port 8080, you need to access it on port 8080:
http://localhost:8080 or http://127.0.0.1:8080
To fix the port 80 problem do:
From cmd as administrator:
sc config http start= demand (you need a space after the equal sign and not before)
Reboot
Run the command (netsh http show servicestate) as administrator to check that the port 80 is in use
After you have run this command, you can disable http.sys as follows:
net stop http (stop the process)
Sc config http start= disabled (if you want to disable the service forever)
it works for me.
Edit your C:\Windows\System32\drivers\etc\hosts file
Make sure there is an entry that looks like this:
127.0.0.1 localhost
If there is an entry like
:: localhost
Comment it out to look like this
\#:: localhost
This should fix your problem, I've had this problem in the past.
For me, it was skype causing the problem. Once I stopped skype, everything worked. I have 1.7.1 xampp (mysql and apache) running on Windows 7 x64.
It sounds like you have no web server running at all anywhere.
Have you tried enabling IIS and using it to display a basic html file first?
Programs & Features -> Turn Windows Features On/Off -> Internet Information Servcies
Then, place your html file in C:\inetpub\wwwroot\index.html and browse to http://localhost.
Once this works, try to get WAMP/php working. Be careful of port conflicts.
My initial thought is that you are missing an entry in the hosts file. Something like "127.0.0.1 localhost", however, you mention that you are getting a 404 error. That means that the webserver is connecting to your client/browser and responding to the request for a particular webpage.
I'm not familiar enough with Windows 7, however, I'm pretty sure that it does not include a webserver by default. Also, unless you actually code, build and run a webserver application using netbeans you're not going to get the desired response.
When it comes down to it.... your issue is going to be one of the following:
1) you're serving static documents and the webserver is not configured to serve the files from whatever the proper DOCROOT should be. This includes PUBLIC folders in the user's directories. (the basic apache install include a basic homepage)
2) you have a dynamic webserver application where the controller is looking at the application path in order to decide what page to display or what function to execute. (see MVC - Controller). Basically incomplete implementation.
3) yet another configuration error: your website might actually define a virtual domain. (something other than localhost) so when you look for localhost in the URL the server might not be configured to provide a default page.
Uncommenting the following line in host file worked for me,
#127.0.0.1 localhost
Well you are getting a 404, so the web server is running, it just can't find the file.
Check the http.conf file. If it pointing to the right root directory?
If you are using different ports, then check http.conf to see if Apache is listening on the right port, or if apache is redirecting traffic on the port to anther root directory.
Maybe posting your http.conf file might help?
If you're still having this problem, try this:
Edit your hosts file (with elevated privileges)
Uncomment the line "#127.0.0.1 localhost" (ie- remove the #)
Save the file as is. hosts with no extension
In Win7 MS has decided to comment the localhost line with that msg that says it's handled in dns. I'm still not exactly clear what they're getting at, except maybe that they're telling folks to use dns for localhost resolution instead of the hosts file. Probably safer that way, anyway.
Yea, this was a pain for me as well.
So what i did was find the "Start Wampserver", just hit the start button and type it in.
Then right click on it , select properties.
I set it to run in XP servive pack 3 on the capatability tab.
I also checked the box "Run this program as an administrator".
Then I right clicked the WAMPSERVER on the System Tray, and re-started all services.
This worked perfect for me, hope this will help you as well.
Rob
Got any other Programs running ? msn ect... ? some bind to port 8080 then your webserver wouldnt start and would cause a 404 , try binding it to a different port 80 which its default should be
I got a 404 could not connect error then I set wampmanager.exe to run as Xp Sp3 and it seems to be working fine this can be done by
Right Clicking on it
Properties
click tab labled "Compatibility"
Tick Box just undeder "Compatibility
mode"
Select Windows XP (Service Pack 3)
Click Apply then OK
It was Skype interfering for me too. I changed the Skype settings (in Skype go to Tools > options > advanced > Connection and UNCHECK "use port 80 and 443 as alternatives for incoming connections") save then close Skype. I have Win 7 HomePremium 64 bit, had installed Xampp fine with MySQL running fine, but no matter how many times I started Apache (and console showed "Apache started") I still got the "firefox can't establish a connection" error in the browser. After Skype changes were saved, Apache showed the green "Running" and all working now thanks
For me this did the trick at port 80 in the end:
You have to disable the http.sys service manually via the registry:
Launch RegEdit:
Go to: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP
Add a new DWORD (32-bit) value
Name it ‘NoRun’ not including the quotes
Double click the new property
In the Value data field type ’1' not including quotes and click OK
Re-boot your computer
You should now find that Apache will start on port 80!
Have you try the iis? Go to Control Panel->Programs and Features->Turn Windows features on or off (side bar). Try installing or reinstalling the Internet Information Service. I've a windows 7 with iis, with .net and php, and it works great...
you have to install the service, go to wamp->Apache->Service->Install service, then a command prompt window will pop up, then press enter, and after a few seconds go to the same route Services-> and click Start/Resume service, and you ready
I had the exact same issue, and the solution is what someone has already said:
In the taskbar, click on the WAMP icon.
Go to Apache-->Service-->Install Service
Then go back by clicking and selecting Apache-->Service-->Start/Resume Service
This will allow the localhost function to work (keep in mind I had already changed the host file located under c:\windows\system32\drivers\etc to remove the # from the 127.0.0.1 line)
If you need to edit that file still, you need to right click on it and select Properties. Then go to the Security tab, and click the Advanced button. You then need to select the Users, click Edit and select "Full Control". This will enable you to edit it.
That being said, you need to ALSO install the MySQL service following the same procedure.
MySQL-->Service-->Install Service
Then go back by right clicking yet again and selecting MySQL-->Service-->Start/Resume Service.
And that should fix it all up in Windows 7!
Before installing Wamp, go to controlpanel=> Adminstrative tools => IIS Manager and turn off the IIS server. Install wamp and everything works fine. When IIS is on it also uses port 80. You can go through a lot of changing the ports and permissions for wamp but I have found this the quickest and easiest method of getting wamp to run successfully.
Try adding the following tags in the wwwroot folder web.config file. These tags should be added as a child of the configuration tags as below.
-configuration-
--system.webServer--
---validation validateIntegratedModeConfiguration="false" ---
--/system.webServer--
-/configuration-
Maybe Skype or other Application is using port 80.
This you can check in
Tools->Settings->Advanced->Connection
See the above solutions are very good.But whenever you get this 404 eroor,first see this.I am sure the problem will be solved...
Just go to httpd.conf file by clicking wamp server symbol in bottom right taskbar-Apache->httpd.conf... or c:\\wampt\\bin\\apache\\apache2.2.1\\conf\\httpd.conf and approximate on line no 46 you will find "Listen 80"...just make sure it is written "80" after Listen...if it not then change it to 80...And your problem will be solved...
Assuming there is no problem doing a lookup on localhost (to 127.0.0.1), you need to make sure your server is listening to 127.0.0.1.
netstat works in both windows an UNIX. You probably need "netstat -a" to display listeners.

Categories