• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
can anyone help me ? I m not able to connect database.

#1
[eluser]bhagatwala[/eluser]
--> I am using wampserver
--> I have saved file in controllers folder.
--> I am able to connect MySQL but not getting connected with Database.
--> Message that i am grtting is "databse not found"
code that i have written is
________________________________________________________________________________________
<html>
<head>
</head>
<body>
<?php
$username = "";
$password = "";
$hostname = "localhost";

$con_str = mysql_connect($hostname, $username, $password)
or die("MySQL not connected");
echo "MySQL Connected<br>";
$con_db = mysql_select_db("demo",$con_str) or die (" Database not found");
?&gt;
&lt;/body&gt;
&lt;/html&gt;
__________________________________________________________________________________________

I have set the config.php file database.php file also

#2
[eluser]NateL[/eluser]
Check out this helpful tutorial:
http://www.php-mysql-tutorial.com/wikis/...abase.aspx

Also, you are aware that you are asking about procedural programming on a Framework forum.. ? You shouldn't have do do what you're doing with CodeIgniter.

#3
[eluser]NateL[/eluser]
Also, make sure you created the table named "demo" (without quotes)

#4
[eluser]the_namdeeW[/eluser]
I would recommend using the built in connection. The whole reason behind using frameworks is to make your life easier.
Just go to /application/config/database.php
This defaults to work with MySQL and just fill in the requirements. Then in your controller just add the following line.
$this->load->database('default');
Good luck!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.