S
S
superman19842016-02-11 12:33:51
PHP
superman1984, 2016-02-11 12:33:51

PHP code error on nic.ru hosting. What to fix?

Hello!
I ask you right away - do not judge strictly, PHP has just begun to study.
There is a code that !works! to localhost (pulls record from database)

<?php

$host = 'myLogin.mysql';
$database = 'myLogin_test';
$user = 'myLogin_mysql';
$pswd = 'password';

$dbh =  mysqli_connect ($host, $user, $pswd) or die ("No connect to server: " . mysql_error());
mysql_select_db ($database) or die ("No connect do db: " . mysql_error());

$query = "SELECT * FROM `my_sql_table`";
$res = mysql_query($query);
while($row = mysql_fetch_array($res))
{
    echo "Номер: ".$row['id']."<br>\n";
    echo "Имя: ".$row['firstname']."<br>\n";
    echo "Фамилия: ".$row['surname']."<br><hr>\n";
}
?>

But when I host (nic.ru) I get an error -
Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user ''@'10.3.227.221' (using password: NO) in /home/ ***/***/docs/index.php on line 9
Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/divancho/***/ ***/index.php on line 9
No connect do db: Access denied for user ''@'10.3.227.221' (using password: NO)
I can assume that I'm specifying the parameter incorrectly here:
$host = 'myLogin.mysql';
Please help me figure it out.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey, 2016-02-11
@superman1984

mysql i _connect
but
mysql_select_db
won't work like that

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question