Skip to content
General Revolution Evolution Add-ons International
Login | Register | MODX.com
MODX Open Source Content Management System, Framework, Platform and More.
Find a Partner | Hosts + SaaS | Jobs | Donate
  • RegisterSign Up with the MODX Community
  • LoginUse Your MODX.com Account
  • MODX Community Forums
  • General
  • General Support
  •  
  • [solved] Retrieving info from a different DB...#

  • 34162
    0

    Zombie Reply #1, 6 years, 2 months ago

    Reply
    • Link to this post#1
    Hi, I'm having a problem with a snippet. I wrote up some code to extract some posts from my forum to display them on my homepage. It worked without MODx, but I put that same code as a snippet and now I'm getting parsing errors.

    I believe it's because I'm selecting a different DB than what modx was installed to, and I was wondering what I should to to do about resolving this issue. Thanks alot!


  • 33337
    3,899
    - MODX Special Forces
    Share and explore websites made in MODx by Zaigham's Web | Tweet @zaigham | Resource Center


    MODx Current | MODx on Git! | BUGS! | RTFM (Read the Fully awesome Manuals)

    Zaigham (aka zi) Reply #2, 6 years, 2 months ago

    Reply
    • Link to this post#2
    Can you please provide details of error ?

    thanks.

    zi


  • 34162
    0

    Zombie Reply #3, 6 years, 2 months ago

    Reply
    • Link to this post#3
    Sure.

    PHP error debug
    Error: mysql_result(): supplied argument is not a valid MySQL result resource
    Error type/ Nr.: Warning - 2
    File: /www/z/zeroinfinity2/htdocs/manager/includes/document.parser.class.inc.php(667) : eval()'d code
    Line: 131


    Like I said though.. the script connects to a different database.. Maybe that's it?


  • 33337
    3,899
    - MODX Special Forces
    Share and explore websites made in MODx by Zaigham's Web | Tweet @zaigham | Resource Center


    MODx Current | MODx on Git! | BUGS! | RTFM (Read the Fully awesome Manuals)

    Zaigham (aka zi) Reply #4, 6 years, 2 months ago

    Reply
    • Link to this post#4
    Something in your code is a problem, how about sharing a code ?
    regards,

    zi


  • 28042
    14,561
    How MODx Evo WorksLog in to an Evo Manager username guest, password guestuser.

    sottwell Reply #5, 6 years, 2 months ago

    Reply
    • Link to this post#5
    There are some functions in the parser class for accessing an external database. You'll need to scan through the parser class file to find them, though. They aren't part of the MODx DBAPI.


  • 22303
    9,586
    - MODX Chief Architect

    Jason Coward | MODX Chief Architect

    jasoncoward.com | @drumshaman

    opengeek Reply #6, 6 years, 2 months ago

    Reply
    • Link to this post#6
    Actually, to use the DBAPI to connect to a different DB, all you do is this:

    $mydb= new DBAPI();
    $mydb->connect($host='mysql.mydomain.tld',$dbase='mydbname', $uid='mydbuser',$pwd='mydbpwd');
    


    NOTE: The $param='value' syntax was just an example so I could describe the variables being passed, you only have to include a var or the value directly.


  • 28042
    14,561
    How MODx Evo WorksLog in to an Evo Manager username guest, password guestuser.

    sottwell Reply #7, 6 years, 2 months ago

    Reply
    • Link to this post#7
    Thanks, Jason. That is much better! This fairly obvious advantage of a class structure went right past me.


  • 34162
    0

    Zombie Reply #8, 6 years, 2 months ago

    Reply
    • Link to this post#8
    Okay, I'll try that and tell you how it goes. Thanks for your quick replies so far!

    EDIT: I got it working! Thanks alot everyone! (It was the connection to the database... plus the way I was handling the date and time.)


  • 33337
    3,899
    - MODX Special Forces
    Share and explore websites made in MODx by Zaigham's Web | Tweet @zaigham | Resource Center


    MODx Current | MODx on Git! | BUGS! | RTFM (Read the Fully awesome Manuals)

    Zaigham (aka zi) Reply #9, 6 years, 2 months ago

    Reply
    • Link to this post#9
    hi Zacarias !

    We are glad to know that your problem is solved.

    regards,

    zi





Actions

Login to Post

Other Support Options

To file a bug or make a feature request visit our issue tracker, or you can also purchase commercial support.

Love MODX?

If you build sites for a living with MODX or just love using it, why not give back?

Information

Posted in this thread:
opengeek, sottwell, zaigham, zombiemx

 
Back to Top

MODX Global HQ

1333 N Stemmons Fwy, Ste 110
Dallas, TX 75207
United States

+1 (469) 777-MODX (6639)

The MODX Company

  • Contact
  • Media Center
  • Work at MODX
  • Wall of Fame
  • The MODX Blog

Sponsors

SoftLayer Firehost: Secure Cloud Hosting

Stay Connected

Read our previous email newsletters.

Twitter Facebook Google+ LinkedIn github Feeds

Privacy Policy | Terms of Service | Pixels by AKTA Web Studio© 2005-2012 MODX. All rights reserved. Trademark Policy