| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |

05-25-11, 20:09
|
|
Registered User
|
|
Join Date: May 2011
Posts: 6
|
|
|
Database not connecting - Wamp Server
|
|
Hi
I got to develop my whole database in Wampserver 2.1 (it's the latest set). But now I cannot connect to MySQL through PHP in Wamp. I have searched a lot but still have no clue as to what is causing problems.
No errors are being displayed. I have tried a number of code combination including "if(!)" and nothing has worked.
CAN ANYONE HELP PLEASE.
Here is the current code I am trying which returns blank page:
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'xyz';
$db = 'scorecard';
$conn = mysql_connect($dbhost,$dbuser,$dbpass);
if (!$conn)
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
?>
|
|

05-26-11, 04:46
|
|
Registered User
|
|
Join Date: Sep 2009
Location: San Sebastian, Spain
Posts: 823
|
|
You should check your php.ini settings. It might be the case that you are not reporting the errors. Alternatively you can force displaying the errors by adding this line into your code at the top:
ini_set("display_errors",1);
Here is the link to the explanation:
PHP: Runtime Configuration - Manual
__________________
Ronan Cashell
Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
http://www.it-iss.com
|
|

05-26-11, 13:32
|
|
Registered User
|
|
Join Date: May 2011
Posts: 6
|
|
|
RE: php.ini not helping to report errors in Database Connection - Wamp
|
|
Thanks Ronan for your reply.
I have tried your suggestion but i still get blank page. No error messages are being displayed.
Moreover, where does php.ini reside in Wamp directory?
Now the code looks like this:
<?php
ini_set("display_errors",1);
$dbhost = 'localhost:3360';
$dbuser = 'root';
$dbpass = '7years';
$db = 'scorecard';
$conn = mysql_connect($dbhost,$dbuser,$dbpass);
if (!$conn)
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
?>
PLEASE HELP.
|
|

05-26-11, 13:54
|
|
Registered User
|
|
Join Date: Sep 2009
Location: San Sebastian, Spain
Posts: 823
|
|
The default port for MySQL is 3306 and not 3360 as you have put in. Perhaps this is the issue? Also if you have a firewall enabled make sure connections to 3306 are open.
__________________
Ronan Cashell
Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
http://www.it-iss.com
|
|

05-26-11, 14:40
|
|
Registered User
|
|
Join Date: May 2011
Posts: 6
|
|
|
Database not connecting - Port is also open - Wamp
Thx Ronan for pointing out the error in port number.
However, I have corrected the port number and have specifically opened the port as well but still blank page.
Do you think it can have anything to do with MySQL? But then PHP must give error.
Do you need MySQL log for any further details on that?
Thanks again. Looking forward to more help.
|
|

05-26-11, 16:08
|
|
Registered User
|
|
Join Date: Sep 2009
Location: San Sebastian, Spain
Posts: 823
|
|
Can you log in to MySQL with the mysql command line application? Let's start there to see if the MySQL service is running.
You are correct in so far as PHP should be returning some kind of error. But as there are so many components involved i.e. MySQL, MySQL client and PHP we need to try and logically work out where the problem lies.
__________________
Ronan Cashell
Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
http://www.it-iss.com
|
|

05-26-11, 16:36
|
|
Jaded Developer
|
|
Join Date: Nov 2004
Location: out on a limb
Posts: 10,513
|
|
consider changing
PHP Code:
ini_set("display_errors",1);
to
PHP Code:
Error_Reporting (E_ALL | E_STRICT);
PHP: error_reporting - Manual
consider changing the
PHP Code:
$conn = mysql_connect($dbhost,$dbuser,$dbpass);
if (!$conn) die('Could not connect: ' . mysql_error()); ...
to
PHP Code:
$conn = mysql_connect($dbhost,$dbuser,$dbpass) or die('Could not connect: '.mysql_error());...
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
|
|

05-26-11, 16:37
|
|
Jaded Developer
|
|
Join Date: Nov 2004
Location: out on a limb
Posts: 10,513
|
|
there may be an issue with the spaces before and aftere the concatenation of the could not connect
Ive seen errors before when unable to establish a connection.
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
|
|

05-26-11, 18:28
|
|
Registered User
|
|
Join Date: May 2011
Posts: 6
|
|
|
Database not connecting - MySQL Console is OK - Wamp
Dear Ronan
MySQL Console is working fine. MySQL is running. Yet it doesn't connect with php.
Do you have msn or skype id where we could talk abt it in detail in a go?
Thanks for bearing with me.
|
|

05-26-11, 19:38
|
|
Registered User
|
|
Join Date: May 2008
Posts: 277
|
|
Quote:
Originally Posted by xuhaib
PHP Code:
if (!$conn)
die('Could not connect: ' . mysql_error());
}
|
This should be raising a syntax error, which would prevent the script from running at all. However, that should be displayed in your browser, unless you've totally disabled error reporting.
This is correct:
PHP Code:
if (!$conn)
die('Could not connect: ' . mysql_error());
or:
PHP Code:
if (!$conn) {
die('Could not connect: ' . mysql_error());
}
|
|

05-27-11, 03:52
|
|
Jaded Developer
|
|
Join Date: Nov 2004
Location: out on a limb
Posts: 10,513
|
|
it is a PHP you should be tracking down first
until you have got a reliable error report you dont' knwo if this is PHP problem or MySQL problem
the failure to report anything tell sme you don't have the error reporting correctly set up. PHP out of the box used to report any and all errors that changed IIRC PHP 5, so you know have to explicitly tell PHP to report errors.
Theres things you can do to check if its MySQL though
run a copy of MySQL Workbench and connect to the database, using the smae user id and password you are usign in your script. if the db server is on the same computer as the script runs on then consider connecting to the local host using the userid + password combo
if its on another computer as the webserver this test doenst' prove anything as you may need to assign the permissions.
consider running a PHP script
PHP Code:
<?PHP phpinfo() ?>
however get a PHP script that reports errors
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
|
|

11-03-12, 01:15
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 2
|
|
|
database not connecting - wamp sever
ERROR is
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'SYSTEM'@'localhost' (using password: NO) in C:\wamp\www\ols\insert.php on line 2
Could not connect: Access denied for user 'SYSTEM'@'localhost' (using password: NO)
my code
<?php
$con = mysql_connect("","","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$con = mysql_connect("","","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("osl", $con);
mysql_query("INSERT INTO details (name, emailid, phno, pswd)
VALUES (('$_POST[name]', '$_POST[emailid]', '$_POST[phno]', '$_POST[pswd]')");
mysql_close($con);
?>
plz reply soon
|
|

11-03-12, 04:52
|
|
Jaded Developer
|
|
Join Date: Nov 2004
Location: out on a limb
Posts: 10,513
|
|
what that error is telling you is that your server is up and running but you do not have permission to connect the specified user to the specified database
it could be
you have mistyped the user ID or password or database or some combination thereof
you haven't GRANTed permissions for your user to that DB for that host
whether you use the MySQL coimmand line client (such as MySQL.exe in windows) or a GUI client such as MySQL's own Workbench or HeidiSQL or similar is up to you
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
|
|

11-05-12, 06:26
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 2
|
|
i have checked the user name and password are crt. i guess the problem is sql and php are not getting connected. am using wammp server so r v suppose to install anythin else to get them connected.
|
|

11-05-12, 15:30
|
|
Jaded Developer
|
|
Join Date: Nov 2004
Location: out on a limb
Posts: 10,513
|
|
check the userid, password AND the computer or host(s) this user id is allowed to connect with
Check the user (once authenticated) has access to the specified database
as said before the error message is telling you that PHP CAN talk to the server but the server is rejecting the connection because of a permissions issue
the error message is telling you that your code is not using a password when trying to establish the connection
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|