我找到了四篇关于同一问题的文章,我没有运气就尝试了他们的答案。
我的问题是当我尝试从( MYSQL )迁移到( MYSQLi )并且我仔细阅读本书时,但是我有错误( 警告:mysqli_query():无法获取mysqli )指向以下行:
$IDS = mysqli_query($Connection, $SQL1);opendb.php
<?php require_once("config.php"); $Connection = mysqli_connect(DB_SERVER, DB_USER, DB_PASS, DB_NAME); if (mysqli_connect_errno()){ die("Database connection failed: " . mysqli_connect_error() . " (" . mysqli_connect_errno() . ")" ); } ?>我遇到的代码:
require_once("../includes/opendb.php"); $SQL1 = "SELECT EmployeeID, Name FROM employees;"; $IDS = mysqli_query($Connection, $SQL1); if (!$IDS) { die("Error " . mysqli_error($Connection)); } require_once("../includes/closedb.php");closedb.php
<?php if (!empty($Connection)) { mysqli_close($Connection); } ?>我不知道我做错了什么。 如果您需要更多详细信息,请与我们联系。 谢谢。
I found four articles about the same issue and I tried their answers with no luck.
My issue is when I tried to migrate from (MYSQL) into (MYSQLi) and I did it carefully and by the book, but I had the error (Warning: mysqli_query(): Couldn't fetch mysqli) pointing to the following line:
$IDS = mysqli_query($Connection, $SQL1);opendb.php
<?php require_once("config.php"); $Connection = mysqli_connect(DB_SERVER, DB_USER, DB_PASS, DB_NAME); if (mysqli_connect_errno()){ die("Database connection failed: " . mysqli_connect_error() . " (" . mysqli_connect_errno() . ")" ); } ?>The code I'm having issue with:
require_once("../includes/opendb.php"); $SQL1 = "SELECT EmployeeID, Name FROM employees;"; $IDS = mysqli_query($Connection, $SQL1); if (!$IDS) { die("Error " . mysqli_error($Connection)); } require_once("../includes/closedb.php");closedb.php
<?php if (!empty($Connection)) { mysqli_close($Connection); } ?>I don't know what I'm doing wrong. Please let me know if you need more details . Thank you.
最满意答案
我找到了答案。 我搜索了所有PHP文件并找到了函数:
mysqli_close($Connection);在(functions.php)的末尾,包括:
include("functions.php");所以基本上该函数在我开始生成错误的查询之前关闭了连接。 感谢所有花时间试图解决这个问题的人。
I found out the answer. I did a search on all PHP files and found the function:
mysqli_close($Connection);At the end of the (functions.php) which was included through:
include("functions.php");So basically the function closed the connection before I start the query which generated the error. Thanks to everyone who took the time trying to solve this.
更多推荐
发布评论