Jump to content


Photo

No Database Selected


  • Please log in to reply
4 replies to this topic

#1 blira

blira
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 20 June 2006 - 12:02 AM

Hi all... first post.

I have a site (PHP/MySQL) and receive the "No Database Selected". The /Connections/connect.php file includes the following code:

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_cirpeduc = "localhost"; $database_cirpeduc = "ciruja_cirpeduc"; $username_cirpeduc = "ciruja_root"; $password_cirpeduc = "root"; $cirpeduc = mysql_pconnect($hostname_cirpeduc, $username_cirpeduc, $password_cirpeduc) or trigger_error(mysql_error(),E_USER_ERROR); ?>

As far as I understand there must be no blank lines after the "?>" (this file has no such blank lines). Every value is correct (such as localhost, curuja_cirpeduc, and so forth).

Any ideas?

TIA
Bernardo, from Chile.

#2 High_-_Tek

High_-_Tek
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 20 June 2006 - 12:25 AM

mysql_select_db('database')



#3 blira

blira
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 20 June 2006 - 12:38 AM

Here is a file that requires the connection file described above.

<?php require_once('Connections/connect.php'); ?>

<?php
$currentPage = $_SERVER["PHP_SELF"];

$maxRows_noticias = 10;
$pageNum_noticias = 0;
if (isset($_GET['pageNum_noticias'])) {
$pageNum_noticias = $_GET['pageNum_noticias'];
}
$startRow_noticias = $pageNum_noticias * $maxRows_noticias;

mysql_select_db($database_cirpeduc, $cirpeduc);
$query_noticias = "SELECT * FROM noticia ORDER BY fecha DESC";
$query_limit_noticias = sprintf("%s LIMIT %d, %d", $query_noticias, $startRow_noticias, $maxRows_noticias);
$noticias = mysql_query($query_limit_noticias, $cirpeduc) or die(mysql_error());
$row_noticias = mysql_fetch_assoc($noticias);

{etc}

This is the php file that shows the "No Database Selected" message.

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 20 June 2006 - 10:18 AM

Change this:
mysql_select_db($database_cirpeduc, $cirpeduc);

to:
mysql_select_db($database_cirpeduc, $cirpeduc) or die("Unable to select database: " . mysql_error());

#5 blira

blira
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 20 June 2006 - 02:07 PM

Thanks, wildteen88, your help showed me the problem.

My DBA didn't grant me permission to the database... now it's working fine.

Thanks again!!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users