1049:Unknown database 'address_book'
Posted by: airwolf09 (167.138.234.---)
Date: March 08, 2010 06:43PM

I get an error message in my localhost. I use WAMP.

1049:Unknown database 'address_book'

I think MySQL is not set up right.

<HTML>


<HEAD>
<Title>Data</TITLE>
</HEAD>



<BODY>

<?php

$qry = 'SELECT * FROM info Order BY Id ASC';
$conn=mysql_connect("$location","$username","$pass word"winking smiley; //connect to sql server
$sql = mysql_query($qry,$conn) or die(mysql_errno().':'.mysql_error());
// the above will tell you what, if any, is the mysql error //

while ($rows = mysql_fetch_array($sql)) {

$Id = $rows -> Id;
$FirstName = $rows -> FirstName;
$LastName = $rows -> LastName;
$Email = $rows -> Email;

echo 'First Name: ' . $FirstName . '<br /> Last Name: ' . $LastName . '<br /> Email: ' . $Email . '<br />';
}
?>

</BODY>

</HTML>

I went looking on MySQl via PHPAdmin and got this:

Server: localhost
$cfg['Servers'][$i]['pmadb'] ... not OK [ Documentation ]
$cfg['Servers'][$i]['relation'] ... not OK [ Documentation ]
General relation features: Disabled

$cfg['Servers'][$i]['table_info'] ... not OK [ Documentation ]
Display Features: Disabled

$cfg['Servers'][$i]['table_coords'] ... not OK [ Documentation ]
$cfg['Servers'][$i]['pdf_pages'] ... not OK [ Documentation ]
Creation of PDFs: Disabled

$cfg['Servers'][$i]['column_info'] ... not OK [ Documentation ]
Displaying Column Comments: Disabled
Bookmarked SQL query: Disabled
Browser transformation: Disabled

$cfg['Servers'][$i]['history'] ... not OK [ Documentation ]
SQL history: Disabled

$cfg['Servers'][$i]['designer_coords'] ... not OK [ Documentation ]
Designer: Disabled

Do you see anything wrong in the set up of MySQL? and How do I fix It? An yes I do have a DB name 'address_book'

Airwolf09

Options: ReplyQuote
Re: 1049:Unknown database 'address_book'
Posted by: c2dan (---.15-1.cable.virginmedia.com)
Date: March 08, 2010 07:46PM

Wamp is running fine. Its your script that is the problem.

After this line in your code
$conn=mysql_connect("$location","$username","$pass word"; //connect to sql server
You need to call mysql_select_db to connect your database. eg
mysql_select_db('YOUR_DATABASE_NAME_HERE', $conn);

This forum is for issues with WAMP only, not coding issues.

Options: ReplyQuote
Re: 1049:Unknown database 'address_book'
Posted by: airwolf09 (---.hsd1.fl.comcast.net)
Date: March 09, 2010 12:59AM

OK I got this new code and still doing the same :

<HTML>


<HEAD>
<Title>Data</TITLE>
</HEAD>



<BODY>

<?php
$location="localhost"; //Hostname of MYSQL server
$username="root"; //Username for MYSQL
$password=" "; //password for MYSQL user
$database="Address_Book"; //Database name

$conn=mysql_connect("$location","$username","$password"winking smiley; //connect to sql server

mysql_select_db($database,$conn)or die(mysql_errno().':'.mysql_error());//select database
$res=mysql_query("select * from info"winking smiley; //select table
while($row=mysql_fetch_array($res)) { //fetch each row
echo $row["FirstName"]." ".$row["LastName"];//print field
}
?>

</BODY>

</HTML>

Still getting 1049:Unknown database 'address_book'

Airwolf09

Options: ReplyQuote
Re: 1049:Unknown database 'address_book'
Posted by: airwolf09 (---.hsd1.fl.comcast.net)
Date: March 09, 2010 01:12AM

Wow....I went to check the name of my database and it was 'address_ book' instead of 'address_book' There was an empty space in between the _ and b for book.... Simple mistake created me such a headache...Thanks for all the help!

Airwolf09

Options: ReplyQuote


Sorry, only registered users may post in this forum.