좋아요. PHP 프로그램/PHP 파일을 .exe 출력으로 변환하려고합니다. 따라서 파일을 제공하는 모든 사람이 어디서나 실행할 수 있습니다. 그것은 내 목표에 완벽하게 작동합니다. 그러나 내 친구가 자신의 컴퓨터에서 동일한 .exe 파일을 실행하면 데이터베이스에 연결할 수 없다는 오류가 발생합니다. 소프트웨어를 추가로 다운로드하지 않고도 프로그램에 액세스 할 수 있기를 바랍니다. 몇 가지 가능한 솔루션을 읽으려고했는데 내 데이터베이스 연결 코드에 이것을 포함시켜야한다는 것을 알게되었습니다.PHP Exe 출력 - 데이터베이스에 액세스 할 수 없습니다.
<?php
// ExeOutput for PHP: MySQL sample using the WAMP package Server2Go
// By default, Server2go comes with a sample database. Root admin is not password-protected.
$mysqlusername = "root";
$mysqlpass = "";
// Do not modify the following lines
$mysqlport = getenv('S2G_MYSQL_PORT');
$mysqlhost = "localhost:".$mysqlport;
// We verify that our ExeOutput application was started by Server2go, otherwise, the MySQL server may not have started.
if (empty($mysqlport)) die("This application cannot be started directly. Programmers: please use the Server2go EXE file, it will start this application automatically.");
?>
것은 내가 제대로 내가 현재 가지고있는 연결 코드에 통합하는 방법을 잘 모르겠습니다입니다 : 그들은 또한 작동하도록 Server2go을 사용했다. 오류는 항상 $ conn = mysqli_connect .... 부분을 참조합니다. 여기 내 기존 연결 코드가 있습니다. 제안 된 솔루션을 어떻게 통합합니까?
<?php
function db_connect()
{
$host = "localhost";
$user = "root";
$password = "";
$database = "csv_db";
$conn = mysqli_connect($host, $user, $password, $database);
if ($conn == FALSE)
{
echo "Error: Unable to connect to the database!";
return NULL;
}
return $conn;
}
function db_disconnect($conn)
{
mysqli_close($conn);
return;
}
function checkUserAccessCookie()
{
/* Check if the user has the "userAccess" cookie (set during login) */
if (isset($_COOKIE["userAccess"]))
{
return true;
}
return false;
}
function getDefaultUserFromCookie()
{
/* If the user has been here before, then a cookie named "userLogin"
* with the user's username will be available. */
if (isset($_COOKIE["userLogin"]))
{
return $_COOKIE["userLogin"];
}
/* If the cookie does not exist, then return blank instead */
return "";
}
?>
당신이 실행 파일을 원하는 경우, PHP가에서 쓸 수있는 최악의 언어이다 –
.exe (데스크톱 응용 프로그램)의 경우 mysql 대신 sqlite로 php를 연결해야합니다. –