D
D
DromHour2017-03-13 12:00:22
PHP
DromHour, 2017-03-13 12:00:22

How to output specific mysql field via php?

I could not find anywhere exactly how the sql query is displayed in php, I tried like this:

$host='localhost'; 
        $database='hidden'; 
        $user='hidden'; 
        $pswd='hidden'; 
        
        $dbh = mysql_connect($host, $user, $pswd) or die("Не могу соединиться с MySQL.");
        mysql_select_db($database) or die("Не могу подключиться к базе.");
        $query = "SELECT * FROM `MusList` WHERE id = '1'";
        $res = mysql_query($query);
        
        
        while($row = mysql_fetch_array($res))
        {
          echo "Название: ".$row['name']."<br>\n";
          echo "Ссылка: ".$row['link']."<br>\n";
          echo "Дата: ".$row['date']."<br><hr>\n";
        }

, but nothing comes out

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Gordinsky, 2017-03-13
@SiriusZloy

Is the table empty?
Try to get something out of it:

$host='localhost'; 
        $database='hidden'; 
        $user='hidden'; 
        $pswd='hidden'; 
        
        $dbh = mysql_connect($host, $user, $pswd) or die("Не могу соединиться с MySQL.");
        mysql_select_db($database) or die("Не могу подключиться к базе.");
        $query = "SELECT * FROM `MusList`";
        $res = mysql_query($query);
        
        
        while($row = mysql_fetch_array($res))
        {
          var_dump($row);
        }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question