How to add Sphider search to my website? “Cannot connect to database”

空扰寡人 提交于 2019-12-12 17:24:42

问题


I downloaded the Sphider search engine and I am currently trying to run it via my localhost. I extracted it in my root folder and made a search bar in HTML:

<div id="searchwrapper">
<form action="../sphider-1.3.5/search.php" method="get" title="eurobytes search">
<input type="text" class="searchbox" name="s" value="" action="../sphider-1.3.5/include/js_suggest/suggest.php" columns="2" autocomplete="off" delay="1500" bgcolor="transparent"/>
<input type="hidden" name="search" value="1">
<input type="image" src="../images/search.png" height="15" class="searchbox_submit" value="search" />
</form>
</div>

but when I type something in I get this error:

Cannot connect to database, check if username, password and host are correct.

I am pretty new to MySQL I read the install.txt, in the sphider-1.3.5 folder, and did the following:

mysql -u your username -p Enter your password when prompted. b) in MySQL, type: CREATE DATABASE sphider_db;

But, when I type in CREATE DATABASE sphider_db I get this:

I don't know what to type now. I tried sphider_db exit but nothing happens?

Sorry if this problem is common sense to most, but I just started playing with MySQL/Sphider.


回答1:


Have you edited settings/database.php? Sounds like a configuration issue... Here are 2 steps to start troubleshooting:

  1. Check what your database name, username and pw are.
  2. Make sure you've edited database.php with that information.

Here is the code snippet from database.php you need to edit with your db settings and user credentials (v1.3.5)

/*********************** 
Database 1 settings
***********************/

// Name of database
$database1 = "test";

// MySQL User
$mysql_user1 = "test-user";

// MySQL Password
$mysql_password1 = "test-user-pw";

// MySQL Host
$mysql_host1 = "localhost";

 // Prefix for tables
$mysql_table_prefix1 = "test_";

// Status of database
$db1_set = "1";


来源:https://stackoverflow.com/questions/11180289/how-to-add-sphider-search-to-my-website-cannot-connect-to-database

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!