Welcome Guest, Not a member yet? Register   Sign In
How to setup mysql database in wamp with codeigniter?
#1

[eluser]neodregan[/eluser]
I'm following the tutorial on devshed, but when I go to "http://localhost/ci/index.php/helloworld/". I get the error, "
A Database Error Occurred

Unable to connect to your database server using the provided settings.
".

These are the settings that I have in databases.php:

$db['default']['hostname'] = "localhost";
$db['default']['username'] = "root";
$db['default']['password'] = "root";
$db['default']['database'] = "mydatabase";
$db['default']['dbdriver'] = "mysql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";


I went to phpMyAdmin in wamp and added the mydatabase mysql database and tried to add a password, but after that happened. It said a password was not set for mydatabase.

Can anyone tell me how to set this up in wamp correctly?
#2

[eluser]Dam1an[/eluser]
Try connecting without the password then
There is no password by default with XAMPP either, and it works fine without it
#3

[eluser]neodregan[/eluser]
Now I get this error:

An Error Was Encountered

Unable to load the requested file: helloworld.php
#4

[eluser]Thorpe Obazee[/eluser]
You need to create the helloworld.php. Particularly, which devshed tutorial are you talking about?
#5

[eluser]neodregan[/eluser]
I'm on this part. http://www.devshed.com/c/a/PHP/Introduct...amework/3/

I put the helloworld.php under the controllers folder with this code.

Code:
<?php

class HelloWorld extends Controller{

function HelloWorld(){

// load controller parent

parent::Controller();

}

function index(){

$data['title']='My first application created with Code Igniter';

$data['message']='Hello world!';

// load 'helloworld' view

$this->load->view('helloworld',$data);

}

}

?>


And under the views folder, I put this in the index.html file:

Code:
<html>
<head>
    <title><?php echo $title;?></title>
</head>
<body>

<h1>&lt;?php echo $message?&gt;</h1>

&lt;/body&gt;
&lt;/html&gt;


Still no go.
#6

[eluser]Thorpe Obazee[/eluser]
you'll need to have a helloworld.php file in the views folder. Copy that content in a helloworld.php file.
#7

[eluser]neodregan[/eluser]
I did what you said, now I receive this!

Fatal error: Cannot redeclare class HelloWorld in C:\wamp\www\ci\system\application\views\helloworld.php on line 25
#8

[eluser]Thorpe Obazee[/eluser]
[quote author="neodregan" date="1245758841"]I did what you said, now I receive this!

Fatal error: Cannot redeclare class HelloWorld in C:\wamp\www\ci\system\application\views\helloworld.php on line 25[/quote]


Code:
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;&lt;?php echo $title;?&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

<h1>&lt;?php echo $message?&gt;</h1>

&lt;/body&gt;
&lt;/html&gt;

Copy only this
#9

[eluser]Dam1an[/eluser]
I'm guessing you misunderstood what bargainph said, you should rename the view to helloword.php, not copy the helloworld.php controller

Edit: Darn it, beat by Bargainph
#10

[eluser]Thorpe Obazee[/eluser]
[quote author="Dam1an" date="1245761647"]I'm guessing you misunderstood what bargainph said, you should rename the view to helloword.php, not copy the helloworld.php controller

Edit: Darn it, beat by Bargainph[/quote]

Tongue




Theme © iAndrew 2016 - Forum software by © MyBB