Joomla! Discussion Forums



It is currently Wed Nov 25, 2009 4:09 pm (All times are UTC )

 




Post new topic Reply to topic  [ 2 posts ] 
Author Message
Posted: Thu Jul 02, 2009 3:24 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Thu Mar 19, 2009 1:48 pm
Posts: 29
I am trying to insert a custom PHP script via a Jumi component. I have written many similar PHP scripts before, but I can't seem to get my query (which works fine - tested on the server via MyPHPadmin) to run - I always receive the message, "No database selected."

Here is what is on the server, viewed through MyPHPadmin:

The database containing all of the Joomla tables is called mysite_joom
The table (in that same Joomla database) with the data I want to display is called librarybooks

MySQL connect works fine.

Here's my code:
<?
$db=mysql_connect ("localhost", "myusername",
"mypassword") or die('Cannot connect to the database because: ' . mysql_error());
mysql_select_db ("mysite_joom",$db);

$query= ('SELECT * FROM `librarybooks` WHERE `col3`="botany" ORDER BY `col2` ASC');
$result = mysql_query($query) or die(mysql_error());
?>

The result of this is "No database selected" I am sure this is something ridiculously simple, but I can't see it.


Top
  E-mail  
 
Posted: Thu Jul 02, 2009 7:03 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Thu Mar 19, 2009 1:48 pm
Posts: 29
Misleading error message from Joomla. Database is selected correctly.

I ran an error check from outside Joomla and the error that came back was "Access denied...") A further check of this server shows that the proper syntax to CONNECT should be:

$db=mysql_connect ("localhost:/tmp/mysql5.sock", "myusername",
"mypassword")

Works fine, now. I dunno why Joomla output "No database selected," though.


Top
  E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

Quick reply

 



Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group