当 php mysql 应用程序移植到 Web 服务器时数据库失败

发布于 2024-10-22 13:36:47 字数 1547 浏览 1 评论 0原文

我是网络开发新手,在阅读了黑客新闻中有关网络托管的一些评论后,我决定尝试一下近乎自由语音(NFS)。我一直在本地主机上使用 PHP/MySQL/Apache 进行一些离线开发,一切都运行良好。现在,我正处于想将其移植到网络服务器的阶段。

按照他们的程序,我得到了一个 MySQL 进程,并使用他们内置的 Phpmyadmin 创建了一个新数据库。但是,当我上传整个项目文件夹时,出现此错误:

代码:数据库错误数据库错误 发生。错误信息: SQLSTATE[42S22]:未找到列: 1054 未知列 “where 子句”中的“Products.categoryID”

这告诉我 SQL 查询无法访问数据库。我在 phpmyadmin 中运行了 .sql 文件,所以我知道数据库名称是正确的。我使用 $_SERVER['DOCUMENT_ROOT'] 以便路径保持完整。

Code:
$doc_root = $_SERVER['DOCUMENT_ROOT']; 

// Get the application path 
$uri = $_SERVER['REQUEST_URI']; 
//echo "URI is $uri"; 
$dirs = explode('/', $uri); 
$app_path = '/' . $dirs[1] . '/'; 
//$app_path = '/' . $dirs[1] . '/' . $dirs[2] . '/'; 
// $app_path = '/' . $dirs[1] . '/' . $dirs[2] . '/' . $dirs[3] . '/' . $dirs[4] . '/'; 
//echo "APP_PATH is $app_path"; 

// Set the include path 
set_include_path($doc_root . $app_path);

我有一个连接到数据库的 .php 文件,并且我已填写这些文件。yko.db

Code:
$dsn = 'mysql:host=yko.db;dbname=my_guitar_shop2'; 
$username = 'myphpmyadminusername'; 
$password = 'myphpmyadminpassword';

是我制作的 mysql 进程,使用 phpmyadmin 制作的数据库是 my_guitar_shop2。我查看了 phpmyadmin 并确认数据库确实存在。

所以,我现在是树桩。一切似乎都在本地主机上工作,但在网络服务器上却不起作用。

我使用 netbeans 作为 IDE,并按照他们的说明上传我放入 /home/public/projectFolder 的文件

是否需要查看或更改任何设置才能使其正常工作?我使用本地主机重试了它,一切似乎都正常。我还可以在源代码中查看哪些内容来使其发挥作用。

非常感谢!!!

PS:或者,我会学习一个教程,帮助初学者注册域名、设置 Web 服务器、数据库、phpmyadmin 等,然后使用 IDE(netbeans、eclipse)上传项目。我不介意再次为另一个网络托管付费。我只是想让它运行起来并弄湿我的脚。

I am new to web development and after reading some reviews on web hosting from hacker news, I decided to try out nearlyfreespeech (NFS). I have been doing some offline development using PHP/MySQL/Apache on localhost and everything have been running well. Now, I am at the stage where I would like to port it to a web server.

Following their procedure, I got a MySQL process and created a new database using their built in Phpmyadmin. But, when I upload the entire project folder, I get this error:

Code: Database Error A database error
occurred. Error message:
SQLSTATE[42S22]: Column not found:
1054 Unknown column
'Products.categoryID' in 'where clause

This tells me that the SQL queries are not able to access the database. I ran .sql file in phpmyadmin so I know that the database name is correct. I use $_SERVER['DOCUMENT_ROOT'] so that the paths will stay intact.

Code:
$doc_root = $_SERVER['DOCUMENT_ROOT']; 

// Get the application path 
$uri = $_SERVER['REQUEST_URI']; 
//echo "URI is $uri"; 
$dirs = explode('/', $uri); 
$app_path = '/' . $dirs[1] . '/'; 
//$app_path = '/' . $dirs[1] . '/' . $dirs[2] . '/'; 
// $app_path = '/' . $dirs[1] . '/' . $dirs[2] . '/' . $dirs[3] . '/' . $dirs[4] . '/'; 
//echo "APP_PATH is $app_path"; 

// Set the include path 
set_include_path($doc_root . $app_path);

I have a .php file which connects to the database and I have these filled in.

Code:
$dsn = 'mysql:host=yko.db;dbname=my_guitar_shop2'; 
$username = 'myphpmyadminusername'; 
$password = 'myphpmyadminpassword';

yko.db is the mysql process that I made and the database made using phpmyadmin is my_guitar_shop2. I looked at the phpmyadmin and confirmed that the database does exist.

So, I am stump right now. Everything seems to be working on localhost and it is not working on the web server.

I use netbeans as the IDE and followed their instructions upload the files which I put into /home/public/projectFolder

Is there any settings I need to look at or change to get this to work? I retried it using localhost and everything seems to work. What else in the source can I possibly look at to get this to work.

Thanks much!!!

PS: Alternatively, I would take a tutorial that will take a begineer from registering for a domain, setting up a web server, database, phpmyadmin, etc and then uploading projects using an IDE (netbeans, eclipse). I don't mind paying again for another web hosting. I just want to get it running and get my feet wet.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一绘本一梦想 2024-10-29 13:36:47

您是否在列名中使用了点(Products.categoryID 表明您是)...MySQL 从版本 5.1.6 开始支持列名中的点(参考:对象名称

可能需要检查您的远程版本(通过 phpmyadmin)。

Are you using a DOT in your column name (Products.categoryID would indicate you are)... MySQL support for dots in column names started with version 5.1.6 (Reference: Object Names)

Might want to check your remote version (through phpmyadmin).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文