好的,
因此,根据最近的发现,我决定尝试在我的网站上尝试http://www.elated.com/articles/cms-in-an-afternoon-php-mysql/。不幸的是,每当我加载索引时,它只会向我发送此消息。 “很抱歉,发生了问题。请稍后再试。”这显然是由我应该填写的Connect.php引起的。现在,由于某种原因,我似乎无法真正设法正确连接。在本教程中,他使用了客户端MySql,但我没有使用它(我正在使用phpmyadmin)。我将mysql文件导入其中并且可以正常工作,但是我不确定如何连接等。
<?php
ini_set( "display_errors", true);
date_default_timezone_set( "Europe/Stockholm" ); // http://www.php.net/manual/en/timezones.php
define( "DB_DSN", "****;******=*****" );
define( "DB_USERNAME", "******" );
define( "DB_PASSWORD", "******" );
define( "CLASS_PATH", "classes" );
define( "TEMPLATE_PATH", "templates" );
define( "HOMEPAGE_NUM_ARTICLES", 5 );
define( "ADMIN_USERNAME", "admin" );
define( "ADMIN_PASSWORD", "mypass" );
require( CLASS_PATH . "/Article.php" );
function handleException( $exception ) {
echo "Sorry, a problem occurred. Please try later.";
error_log( $exception->getMessage() );
}
set_exception_handler( 'handleException' );
?>
您看到的代码只是默认代码,因此不会保留密码或类似内容。但是,正如您在顶部看到的那样,我对放置在其中的内容(例如特定的信息行)绝对不零。有人介意给我一个例子吗?我不想使用客户端mysql服务器,我希望它通过phpmyadmin并仅在那里工作。我究竟做错了什么?..
这是原始代码:
<?php
ini_set( "display_errors", true );
date_default_timezone_set( "Australia/Sydney" ); // http://www.php.net/manual/en/timezones.php
define( "DB_DSN", "mysql:host=localhost;dbname=cms" );
define( "DB_USERNAME", "username" );
define( "DB_PASSWORD", "password" );
define( "CLASS_PATH", "classes" );
define( "TEMPLATE_PATH", "templates" );
define( "HOMEPAGE_NUM_ARTICLES", 5 );
define( "ADMIN_USERNAME", "admin" );
define( "ADMIN_PASSWORD", "mypass" );
require( CLASS_PATH . "/Article.php" );
function handleException( $exception ) {
echo "Sorry, a problem occurred. Please try later.";
error_log( $exception->getMessage() );
}
set_exception_handler( 'handleException' );
?>
最佳答案
如果之后
echo "Sorry, a problem occurred. Please try later.";
加线
echo $exception->getMessage();
您可以了解有关错误的更多信息。它是
抱歉,出现问题。请稍后再试。调用未定义的函数mysql_escape_string()
下一步-找到所有
mysql_escape_string()
(在Article.php和Category.php中)并替换为mysqli_escape_string()
关于php - MySQL CMS连接问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25699023/