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.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > Database not connecting - Wamp Server

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-25-11, 20:10
xuhaib xuhaib is offline
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';
?>
Reply With Quote
  #2 (permalink)  
Old 05-29-11, 23:29
Serien Serien is offline
Registered User
 
Join Date: May 2011
Posts: 4
From what I've seen, variables can be a little testy sometimes in PHP script. I would try not defining quite so much of the script. Instead perhaps use

PHP Code:

<?php
$db 
'scorecard';

$conn mysql_connect("localhost""root""xyz");
if (!
$conn)
{
die(
'Could not connect: ' mysql_error());
}
echo 
'Connected successfully';
?>
You were also missing a bracket on your "if" statement, that could be the issue.

If neither of those fixes work, I would double check and make sure that the account information you are using is correct and that the user that you have named has the proper permissions to access the database you are trying to connect to.

Hope that helps a little!
Reply With Quote
  #3 (permalink)  
Old 05-30-11, 06:35
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
why are you asking the same question in a new thread?
it just causes confusion, please do not do this

if you are having problems in getting an answer to your problem then bump the old post or add further infortmation


as suggested in Database not connecting - Wamp Server then first things you need to do are:-

prove you have a working PHP insterpreter ont he web server. I suggested using a PHP script that uses the PHPinfo() function to display how the server is configured

prove you are getting PHP error messages. I'd suggest error_reporting.... in the absence of that you will not be able to develop anything in PHP.
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #4 (permalink)  
Old 06-12-11, 02:31
Backslider Backslider is offline
Banned
 
Join Date: Jun 2011
Posts: 40
You are getting a parse error:

PHP Code:
<?php
$dbhost 
'localhost';
$dbuser 'root';
$dbpass 'xyz';
$db 'scorecard';

$conn mysql_connect($dbhost,$dbuser,$dbpass);
if (!
$conn)    // <<<  MISSING CURLY BRACKET HERE!!!!
die('Could not connect: ' mysql_error());
}
echo 
'Connected successfully';
?>
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On