我在程序PHP应用程序中第一次使用mysqli。对不起复杂的层次结构。以下是它的结构。
index.php 包括 config.php 包含 db_conn.php
index.php 包括 gallery.php
的index.php
include('config.php');
<html>
<body>
<?php include('gallery.php');?>
</body>
</html
的config.php
include('db_conn.php');
include('setttings.php')
#more code..
db_conn.php
?php
$con=mysqli_connect("localhost","my_user","my_password","my_db");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
gallery.php
$sql_pa = "SELECT * FROM `pasal` WHERE `deleted` = 0 ORDER BY `datetime`";
$query_pa = mysqli_query($con, $sql_pa);
# more code...
所以我的连接存储在位于 db_conn.php 文件中的变量 $ con 中,该文件在 gallery.php中不可用文件。我该如何解决?
答案 0 :(得分:-1)
db_conn.php
apply plugin: 'com.android.application'
dependencies {
compile ('com.google.android.gms:play-services:9.0.2')
compile 'com.android.support:appcompat-v7:24.0.0'
compile files('libs/appcompat_v7.jar')
compile files('libs/ksoap2-android-assembly-2.5.8-jar-with-dependencies.jar')
compile files('libs/gcm.jar')
compile files('libs/android.jar')
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')
compile ('com.google.android.gms:play-services-analytics:9.0.2')
compile files('libs/libGoogleAnalyticsServices.jar')
compile files('libs/mail.jar')
compile "com.android.support:support-v4:24.0.0"
compile "com.android.support:design:24.0.0"
compile 'com.android.support:multidex:1.0.1'
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.expedite.apps.vedant"
minSdkVersion 9
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
gallery.php
$con
双N