MySQL CMS连接问题

问题描述 投票:1回答:1

好的,

因此,在最近的发现中,我决定在我的网站上试一试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' );
?>
php mysql database content-management-system connect
1个回答
0
投票

如果之后

echo "Sorry, a problem occurred. Please try later.";

添加行

echo $exception->getMessage();

你可以看到更多关于错误的信息它是

对不起,发生了一个问题。请稍后再试。调用未定义的函数mysql_escape_string()

下一步 - 找到所有mysql_escape_string()(在Article.php和Category.php中)并替换mysqli_escape_string()

© www.soinside.com 2019 - 2024. All rights reserved.