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
https://forums.phpfreaks.com/topic/242833-no-connection-no-error/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.