Page 1 of 1
mysql not running on localhost
Posted: Mon Apr 11, 2011 8:47 am
by atrichtch
Hi,
I have a weird problem with MySQL queries- they execute on the remote server, but not on the localhost.
Code: Select all
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$data = mysql_query($query) or die(mysql_error());
The mysql_error never shows up, but the query doesn't fetch anything. What could cause it?
Thanks.
Re: mysql not running on localhost
Posted: Mon Apr 11, 2011 12:44 pm
by califdon
What DOES happen? Do you have any indication that your web server is running, your PHP is running, your MySQL is running? Check those things first. Use temporary echo statements to see if anything is being sent to your browser, such as echo "Hello!"; and assign the mysql connection to a variable so you can echo whether the variable has been set.
Re: mysql not running on localhost
Posted: Tue Apr 12, 2011 8:12 am
by atrichtch
Apache server is running (indicated in the bottom right-hand corner of my screen); the page does get output (everything except for the SQL data does show up), MySQL is running (otherwise it would give MySQL connection errors), but the query doesn't fetch anything when I'm certain it should (it does return several record in the command line). So what could be wrong? The browser configuration?
Re: mysql not running on localhost
Posted: Tue Apr 12, 2011 11:24 am
by califdon
atrichtch wrote:Apache server is running (indicated in the bottom right-hand corner of my screen); the page does get output (everything except for the SQL data does show up), MySQL is running (otherwise it would give MySQL connection errors), but the query doesn't fetch anything when I'm certain it should (it does return several record in the command line). So what could be wrong? The browser configuration?
OK, then I would check the query, itself, and run the same query from the command line. It's certainly possible that, with the data in your table(s) on your localhost, and the requirements of the query, there are just no rows to return. I don't think there's anything in your browser configuration that could result in that.
Re: mysql not running on localhost
Posted: Tue Apr 12, 2011 8:05 pm
by atrichtch
OK, my problem was using the empty string as a password instead of not specifying it at all.
Re: mysql not running on localhost
Posted: Wed Apr 13, 2011 12:45 am
by waytoecommerce
if every thing is running then i am sure your port has been allotted to other software installed in your system. In this condition you have to edit this file. Please look below : -
Just go to X:\wamp\bin\apache\apache2.2.8\conf\httpd.conf
and search for "Listen 80" change 80 to whatever you want ....
hope it will help...
thanks!
waytoecommerce.com
Re: mysql not running on localhost
Posted: Thu Apr 14, 2011 8:36 am
by atrichtch
Thanks for the reply, waytoe.
I thought it's a small syntax error, but it wasn't. Apparently the browser can't find the server localhost, giving the following error: php_network_getaddresses: getaddrinfo failed: No such host is known. I'll play around with the configuration; there ought to be a solution.
Thanks again.
Re: mysql not running on localhost
Posted: Mon Apr 18, 2011 1:27 pm
by atrichtch
OK, what did solve the problem was opening my.ini and realize it runs on port 3307. So the first parameter in the connection should've been "localhost:3307" and not "localhost" since the server assumes it to be port 80.
In general, using Apache server is a little tricky. For instance, if you want to execute desktop applications remotely, you need to go to services.mcs in the System folder and check the "allow interaction with desktop" box in the properties menu; otherwise the browser hangs (see my other thread).