Reposting here - Cannot connect to other MySQL dbs

13 years 1 month ago - 13 years 1 month ago #157618 by djc
Since I upgraded to CB 1.4 I cannot execute a mysql_select_db() statement to select any database other than the database for the Joomla site.

This call does not return an error, it does not return at all and I am left with a blank screen

Code as simple as shown below will fail for any existing database unless 'xyz' is the Joomla database

<?
$con = mysql_connect("localhost",$username,$password);
$select = mysql_select_db('xyz',$con);
mysql_close($con);
?>

It doesn't even error, just hangs with a white screen....take out the mysql_select_db call and the page is displayed (but doesn't work because can't retrieve any data for the db).

When I restored the site from a backup I took just before the upgrade, everything started working again under 1.2.3

Any thoughts?

Thanks,
Dom

Please Log in to join the conversation.

13 years 1 month ago #157690 by krileon
1.2.3 to 1.4 is a big jump, but CB has nothing to do with your query. You're using direct PHP methods and zero API, not even Joomlas. Please review existing plugins on how to use CBs database API or at very least review existing Joomla extensions/files on how to use Joomla API to perform a query. You can review an example of how to make external database queries with CB API within professional subscriber incubator project CB Queries (plugin.cbqueries.php).


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

13 years 1 month ago #157715 by djc
Thanks for the reply...but I was not clear....I am not talking about using the CB database. This is a MySQL database that is unrelated to Joomla or CB. It is one that I maintain to keep track of other data necessary for the whole site to work properly.

I do use the CB API when I need to work with the CB data, but this is outside CB.

The interesting thing is that the mysql_select_db never returns so I cannot even process an error code.

In principal I agree with you that this should have no effect as I am using direct PHP methods, but as far as I can tell, the only change to the site is the change of CB version.

Regards,
Dom

Please Log in to join the conversation.

13 years 1 month ago - 13 years 1 month ago #157725 by krileon
Is your query being executed from within CB or Joomla or from a 3rd party source? CB or Joomla have nothing to do with 3rd party queries. There's likely an error in your query. Sense you did not provide the full query I can't comment on if it's structured correctly or not. If executed from within CB or Joomla you should be using API (you can call external database with API).


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

13 years 1 month ago #157741 by djc
Again, thanks for your reply....the query is being executed from within an article in order to get the proper information to display on the page.

I guess I wasn't clear....this site has been up an running for many months....the select_db call stopped working when I upgraded. No coding changes were made.

I will think about where else it could be happening and report back.

I appreciate your input!
Dom

Please Log in to join the conversation.

13 years 1 month ago #157968 by djc
OK...I just did it again to be sure that nothing else could have changed....I took the completely working site running with CB 1.2.3 and installed 1.4.

Again, as soon as the install competed, my article with embedded PHP code including a mysql_select_db() call would no display.

I have tested that simply commenting out that line and the page displays (but without all the data it needs). Additionally, I made a page consisting of simply the code from my original post (with the proper information in the arguments) and the page will not display. Comment out the select_db call and all works.

The call to the function never returns so no error code is generated.

While I agree that it does not make sense for it to be CB related, at the same time it is the only that does make sense as it is the only change.

Thanks for all the support!
Dom

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.231 seconds

Facebook Twitter LinkedIn