首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >php中包含函数覆盖的级别是什么?

php中包含函数覆盖的级别是什么?
EN

Stack Overflow用户
提问于 2012-07-02 15:55:44
回答 1查看 123关注 0票数 0

我使用的是include函数。我想知道它的使用水平。说到点子上,我有一个名为hitcounter.php的页面,我想知道在我的应用程序中有多少人点击了该页面。所以我创建了hitcounter.php

我的问题是,我在我的一个页面中包含了这个hitcounter.php,我想知道那个特定的点击率,并将其存储在数据库中。在hitcounter.php中,我包含了dbconnection.php.When,我登录到了我的应用程序中,然后我访问了包含hitcounter.php的特定页面,它显示错误:没有选择数据库。

在我2.8年的经验中,我第一次得到这个错误,我谷歌了很多次,但我没有找到这个问题的答案。

我的hitcountercode代码:

代码语言:javascript
复制
include"dbconnection.php";
//Adds one to the counter 
mysql_query("UPDATE counter SET patient_dashboard = patient_dashboard + 1")or die (mysql_error());

//Retreives the current count 
$count = mysql_fetch_row(mysql_query("SELECT patient_dashboard FROM counter"))or die(mysql_error());

//Displays the count on your site
 print "$count[0]";

这就是我包含hit counter.php的方式

代码语言:javascript
复制
<?php include"../includes/subpageheader.php";
      include"../includes/hitcounter.php"; 
?>

mydatabase连接代码:

代码语言:javascript
复制
$conn=mysql_connect('localhost','root','');
//echo $conn."<br/>";
$db=mysql_select_db('health');

我想知道我们在php中使用了多少层的include函数。

那么,如何解决这个错误,有没有人可以帮我。

EN

回答 1

Stack Overflow用户

发布于 2012-07-02 16:03:12

在我看来,你的错误与include无关,问题是你没有选择数据库,看看这个例子:

代码语言:javascript
复制
 <?php

 $link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
 if (!$link) {
 die('Not connected : ' . mysql_error());
 }

// make foo the current db
$db_selected = mysql_select_db('foo', $link);
if (!$db_selected) {
 die ('Can\'t use foo : ' . mysql_error());
}
?>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11289705

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档