Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 用webservice连接MySQL数据库_Php_Html_Mysql_Web Services - Fatal编程技术网

Php 用webservice连接MySQL数据库

Php 用webservice连接MySQL数据库,php,html,mysql,web-services,Php,Html,Mysql,Web Services,我想将MySQL数据库连接到Web服务。我遵循了一个教程,但它不起作用。我不知道为什么它不起作用。表已构建,但应使用数据库中的值填充。我只是想展示一下。有人有主意吗?这是我的src代码: enter code here <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <he

我想将MySQL数据库连接到Web服务。我遵循了一个教程,但它不起作用。我不知道为什么它不起作用。表已构建,但应使用数据库中的值填充。我只是想展示一下。有人有主意吗?这是我的src代码:

enter code here
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
     <?php
       $mysqlhost="localhost"; // MySQL-Host angeben

       $mysqluser="root"; // MySQL-User angeben

       $mysqlpwd="webservice"; // Passwort angeben

       $mysqldb="**********"; // Gewuenschte Datenbank angeben



       $connection=mysql_connect($mysqlhost, $mysqluser, $mysqlpwd) or die ("Verbindungsversuch                    fehlgeschlagen");



        mysql_select_db($mysqldb, $connection) or die("Konnte die Datenbank nicht waehlen."); 
        mysql_select_db( MYSQL_DATENBANK ) or die("Auswahl der Datenbank fehlgeschlagen");

      $sql="SELECT * FROM car";

     $adressen_query = mysql_query($sql) or die("Anfrage nicht erfolgreich");
    ?>
    <table cellpadding="1" cellspacing="3" border="1">

    <tr>

    <td>ID</td>

    <td>Producer</td>

    <td>Type</td>

    <td>BJ</td>

    <td>HP</td>

    <td>Mileage</td>

    </tr>

    <?php

    while ($adr = mysql_fetch_array($adressen_query)){

    ?>

    <tr>

    <td><?=$adr['ID']?></td>

    <td><?=$adr['Producer']?></td>

    <td><?=$adr['Type']?></td>

    <td><?=$adr['BJ']?></td>

    <td><?=$adr['HP']?></td>

    <td><?=$adr['mileage']?></td>


    </tr>

    <?php

    }

    ?>
    </table>
    </body>
    </html>

. 它们不再得到维护。看到了吗?相反,学习,并使用or-将帮助您决定哪一个。如果选择PDO,。web服务是否与您的网站位于同一服务器上?如果没有,则需要将localhost更改为托管数据库服务器的URL或IP地址。但是如果使用mysql_*函数,请使用mysql_*错误来处理错误,请看:,@Maerlyn是对的,请使用PDO`或MySQLi。@Maerlyn是否有可能在mysql 5.4中使用mysql_*函数?这是我的问题还是另一个问题?我不能一般使用这些函数吗?还是最好不要使用它们,因为它们不再被维护?它们仍然在php中,5.5中也会有,它们只是不被推荐,部分原因是它们很难正确使用,部分原因是它们不再被维护。PDO和MySQLi是非常优秀的替代品,仔细研究一下。