Jump to content

No connection, No error


Nodral

Recommended Posts

Hi

 

I have just set up a hosted site and cannot connect to the MySQL DB. 

 

I have set up the correct DB and User but it just keeps failing at the 1st attempt

 

My code is

<?php
session_start();
$link = mysql_connect('localhost', 'styles', '******');
if (!$link)
{
echo'1Unable to connect to the database server.';
echo mysql_errno($link) . ": " . mysql_error($link). "\n";


exit();
}

if (!mysql_set_charset('utf8', $link))
{
echo'2Unable to connect to the database server.';
echo mysql_errno($link) . ": " . mysql_error($link). "\n";


exit();
}

if(!mysql_select_db('learning_styles', $link))
{
echo'3Unable to connect to the database server.';
echo mysql_errno($link) . ": " . mysql_error($link). "\n";


exit();
}

?>

 

All I get output is

1Unable to connect to the database server.:

 

But no error message.  Any ideas?

Link to comment
Share on other sites

Are your PHP errors hidden? Use

 

error_reporting(E_ALL);
ini_set('display_errors', '1');

 

Also check your hosts control panel for the error log.

 

Your host may be using a pipe for MySQL connections in which case you use '.' as your host, or your host may be using an external server for MySQL.

 

Edit: nevermind, glad you solved it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.