php already defined,PHP error - Constant DB_HOST already defined?

原文:

I am doing a little homework assignment in which we are making a very rudimentary CMS. We are to fill in a form containing title, body, permalink. The CMS then takes the permalink, and adds it to the main nav bar. When that permalink is clicked on the navbar, the title, content, datestamp created and datestamp modified are to be displayed.

I have that stuff working, only problem is that when I click on the nav link,

I receive this notice:

Notice: Constant DB_HOST already defined in C:\Program

Files\xampp\htdocs\php\assignment_6\config.php on line 2

Notice: Constant DB_USER already defined in C:\Program

Files\xampp\htdocs\php\assignment_6\config.php on line 3

Notice: Constant DB_PASS already defined in C:\Program

Files\xampp\htdocs\php\assignment_6\config.php on line 4

Notice: Constant DB_NAME already defined in C:\Program

Files\xampp\htdocs\php\assignment_6\config.php on line 5

I have a config.php file that I use to establish a DB connection:

define('DB_HOST','******');

define('DB_USER','******');

define('DB_PASS','******');

define('DB_NAME','******');

$cms_db = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);

if(!$cms_db){

echo"Could not connect: ".mysql_error();

}

?>

Here is the code from the file calling config.php causing this notice:

require('config.php');

$perm = $_GET['p'];

$query = "SELECT * FROM cms WHERE permalink = '$perm'";

$result = $cms_db->query($query);

$row = $result->fetch_assoc();

$page_title = $perm;

require('header.php');

?>

=$row['title'];?>


=$row['content']?>

A small amount of simple code, but what is the problem? It is not a fatal error but it is annoying.

# Answer 1

4d350fd91e33782268f371d7edaa8a76.png

You're probably including config.php multiple times. Check all your scripts and find this duplicity. You can use require_once() instead of require() to prevent this.

# Answer 2

Do either header.php or footer.php include config.php?

If so thats your problem.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
下面是我 运行终端代码后的返回,请帮我解释下:shenhaibo@bogon webAssembly % emcc add.c -s WASM=1 -o add.wasm wasm-ld: error: /opt/homebrew/Cellar/emscripten/3.1.40/libexec/cache/sysroot/lib/wasm32-emscripten/libstandalonewasm-nocatch.a(__main_void.o): undefined symbol: main emcc: error: '/opt/homebrew/Cellar/emscripten/3.1.40/libexec/llvm/bin/wasm-ld -o add.wasm /var/folders/hd/zkctfvz128366gcjfw9pgslr0000gn/T/emscripten_temp_0gmz58hs/add_0.o -L/opt/homebrew/Cellar/emscripten/3.1.40/libexec/cache/sysroot/lib/wasm32-emscripten /opt/homebrew/Cellar/emscripten/3.1.40/libexec/cache/sysroot/lib/wasm32-emscripten/crt1.o -lGL -lal -lhtml5 -lstandalonewasm-nocatch -lstubs-debug -lc-debug -ldlmalloc -lcompiler_rt -lc++-noexcept -lc++abi-debug-noexcept -lsockets -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr /var/folders/hd/zkctfvz128366gcjfw9pgslr0000gn/T/tmp6m8wb6r0libemscripten_js_symbols.so --strip-debug --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export-if-defined=__start_em_lib_deps --export-if-defined=__stop_em_lib_deps --export-if-defined=__start_em_js --export-if-defined=__stop_em_js --export=emscripten_stack_get_end --export=emscripten_stack_get_free --export=emscripten_stack_get_base --export=emscripten_stack_get_current --export=emscripten_stack_init --export=stackSave --export=stackRestore --export=stackAlloc --export=__errno_location --export-table -z stack-size=65536 --initial-memory=16777216 --max-memory=16777216 --stack-first' failed (returned 1) shenhaibo@bogon webAssembly %
最新发布
06-07

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值