We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8254
    • 15 Posts
    Hi Trying to load my site section and keep getting this error

    « MODx Parse Error »
    MODx encountered the following error while attempting to parse the requested resource:
    « PHP Parse Error »
     
    PHP error debug
      Error: 	mysql_query() [function.mysql-query]: Access denied for user 'apache'@'localhost' (using password: NO)	 
      Error type/ Nr.: 	Warning - 2	 
      File: 	/var/www/vhosts/discovervancouver.com/httpdocs/olympics-2010/manager/includes/document.parser.class.inc.php	 
      Line: 	1295	 
      Line 1295 source: 	$ds= @mysql_query($sql); 	 
     
    Parser timing
      MySQL: 	0.0143 s	(7 Requests)
      PHP: 	0.0701 s	 
      Total: 	0.0844 s	 
    Error while inserting event log into database
      • 25663 MODX Staff
      • 12,272 Posts
      Your apache user doesn’t have access to the database.
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 8254
        • 15 Posts
        I don’t get it user apache, what is that all about? It is set up the same way everything else is and sometimes it comes up whe I click on the external link but then if I click on it again it bombs out. I have 2 modx directories setup and this is the one giving me issue. Database setting are correct, it connects.
          • 22303 MODX Staff
          • 10,725 Posts
          Did you add a snippet that does something with a database connection?
            • 8254
            • 15 Posts
            Nope it’s out of the box install. The only thing I did was copy the other installs database and used that one for this install because I need the same skin. Every time a page is loaded this odd ball parser error seems to happen.
              • 7455
              • 2,204 Posts
              and in that skin did you call snippets not included in the standart install?
              did you change paths in de database? to the new domain paths?
              did you clear the cache?
                follow me on twitter: @dimmy01
                • 8254
                • 15 Posts
                yes calling this snippet [[header]], and this is what it contained, I took this out and it started to work normal but how do I get the external call to work, it’s to bring in a global menu that I need from a database outside of modx?

                // Connecting, selecting database
                $my_database = "content_global";
                $mysql_host = "xxxxxx";
                $mysql_user = "xxxxxx";
                $mysql_password = "xxxxxxxx";
                $link = mysql_connect($mysql_host, $mysql_user, $mysql_password)
                or die(’Could not connect: ’ . mysql_error());
                //echo ’Connected successfully’;
                mysql_select_db($my_database) or die(’Could not select database’);
                // Performing SQL query
                $query = "SELECT title, ExternalLink FROM al_pages where Visible = ’1’ AND status = ’1’ order by SortOrder asc, Title asc, PageID desc";
                $result = mysql_query($query) or die(’Query failed: ’ . mysql_error());
                // Printing results in HTML
                while ($line = mysql_fetch_array($result, MYSQL_NUM)) {
                echo "<li><a href=\"" . $line[1] . "\" class=\"" . str_replace (" ", "", strtolower($line[0])) ."\"><span>".$line[0]."</span></a></li>";
                }
                // Free resultset
                mysql_free_result($result);
                // Closing connection
                mysql_close($link);

                  • 22303 MODX Staff
                  • 10,725 Posts
                  That will not work as it hijacks the current database connection and then closes it, leaving MODx with nothing. You need to create a new connection to work with in your call to mysql_connect (see the PHP documentation for that function), use a new instance of the DBAPI to connect with, etc.
                    • 8254
                    • 15 Posts
                    Do you mean this?

                    http://wiki.modxcms.com/index.php/API:DBAPI:connect
                      • 8254
                      • 15 Posts
                      Quote from: dvancouver at Jan 23, 2008, 01:31 PM

                      Do you mean this?

                      http://wiki.modxcms.com/index.php/API:DBAPI:connect

                      I am sorry to bump this but I am a real n00b and don’t understand how to call this through the API. This is what I have but it does not work. Thanks!

                      //connect to seperate mysql db
                      $modx->db->connect(’ip.number’, ’database_name’, ’username’, ’password’, true);
                      $res = $modx->db->select(’title, ExternalLink’, ’al_pages’);
                      while($tmp = $modx->db->getRow($res, ’assoc’))
                      {
                      //do somethign with the data
                      }
                      //disconnect
                      $modx->db->disconnect();

                      //reconnect to modx db
                      $modx->db->connect();

                      Also not sure where to put the WHERE clause (where Visible = ’1’ AND status = ’1’ order by SortOrder asc, Title asc, PageID desc)