gpt4 book ai didi

php_network_getaddress 错误

转载 作者:行者123 更新时间:2023-11-30 00:28:09 35 4
gpt4 key购买 nike

我正在尝试从数据库中获取数据,并且查询在 sql 引擎上运行良好。但是当我尝试从实际需要的 php 文件中触发它时,我收到 php_network_getaddress 错误。

表单正在成功提交数据,变量正在成功存储值,查询没有错误,但仍然发生错误。我无法理解。任何帮助将不胜感激。

这是我的 php 文件:

<?php

$con = mysql_connect('localhost', 'root', '') or die('Error connecting to server');

mysql_select_db('db_MarkitBerry', $con);

$cust_flow_1=0;
$cust_flow_2=0;
$coll_flow_1=0;
$coll_flow_2=0;
if(isset($_GET['submit']))
{
$date1=$_GET['datepicker'];
$date2=$_GET['datepicker1'];

$query=mysql_connect("SELECT DATE( date_time ) AS DATE, SUM( bill ) as amount , SUM( members ) as customers FROM tbl_transaction WHERE DATE( date_time ) = '2014-03-17' OR DATE( date_time ) = '2014-03-18' GROUP BY DATE( date_time )");
while($row=mysql_fetch_array($query))
{
$cust_flow_2=$row['customers'];
$coll_flow_2=$row['amount'];
echo $cust_flow_2;
echo $coll_flow_2;
}
}

?>

这是 html 格式的表单:

            <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="get" >
<td width="200px" style="padding:5px;" valign="top">
<div class="style2" style="color:#FFFFFF; padding:10px; font:bold 13px Arial, Helvetica;">First Date</div>
<div>
<p><input type="text" class="datepicker" id="datepicker" name="datepicker" /></p>
</div>
<div class="style2" style="color:#FFFFFF; padding:10px; font:bold 13px Arial, Helvetica;">Second Date</div>
<div><p><input type="text" class="datepicker" id="datepicker1" name="datepicker1"/></p></div>
<div>
<input type="submit" name="submit" id="submit" />
</div>
</td>
</form>

这是错误:

Warning: mysql_connect(): php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\xampp\htdocs\markitberry\compare.php on line 16

Warning: mysql_connect(): php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\xampp\htdocs\markitberry\compare.php on line 16

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\markitberry\compare.php on line 17

最佳答案

这是您的问题:

$query=mysql_connect("SELECT DATE( date_time ) AS DATE, SUM( bill ) as amount , SUM(members ) as customer FROM tbl_transaction WHERE DATE( date_time ) = '2014-03-17' OR DATE ( date_time ) = '2014-03-18' 按日期分组( date_time )");

您应该使用mysql_query而不是mysql_connect(您的连接已处于事件状态)

PS。我知道名称并不重要,但您应该注意您的 $query 变量保存查询结果,而不是查询本身。

注意:mysql_* 函数已弃用!考虑使用 mysqli/PDO。

关于php_network_getaddress 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22715352/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com