We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14404
    • 84 Posts
    Hello guys,

    I have a working Geotarget script. Now the question is, how do i integrate this into modx?

    I tried making a snippet with the code:
    <?php
    include_once('geo_targeting_test.php');
    ?>


    Which results in:
    « MODx Parse Error »
    MODx encountered the following error while attempting to parse the requested resource:
    « PHP Parse Error »
     
    PHP error debug
      Error: 	mysql_real_escape_string(): 6 is not a valid MySQL-Link resource	 
      Error type/ Nr.: 	Warning - 2	 
      File: 	/manter/web/www.manter.com/manager/includes/extenders/dbapi.mysql.class.inc.php	 
      Line: 	121	 
      Line 121 source: 	$s = mysql_real_escape_string($s, $this->conn); 	 
     
    Parser timing
      MySQL: 	0.0012 s	(10 Requests)
      PHP: 	0.0586 s	 
      Total: 	0.0598 s	 
    
    Warning: mysql_real_escape_string(): 6 is not a valid MySQL-Link resource in /manter/web/www.manter.com/manager/includes/extenders/dbapi.mysql.class.inc.php on line 121
    
    Warning: mysql_real_escape_string(): 6 is not a valid MySQL-Link resource in /manter/web/www.manter.com/manager/includes/extenders/dbapi.mysql.class.inc.php on line 121


    How can i solve this? What do i need to do to make this work?

    I’m using Modx 1.02 btw..

    Code of geo_targeting_test.php is:
    <?php
    
    // load the SimpleGeoTarget library
    require_once 'include/simple_geo_target.inc.php';
    
    // display geo-targeted welcome message
    if (SimpleGeoTarget::isRegion("US"))
    { 
    echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"globalus.css\" />"; 
    }
    else 
    {
      echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"normal.css\" />";
    }
    
    ?>
    

      • 14404
      • 84 Posts
      Nevermind. I had to make an other mysql connection with:

      //connect to seperate mysql db
      $modx->db->connect(’123.45.6.7’, ’mydb’, ’user’, ’password’, true);
      $res = $modx->db->select(’*’, ’this_table’);
      while($tmp = $modx->db->getRow($res, ’assoc’))
      {
      //do somethign with the data
      }
      //disconnect
      $modx->db->disconnect()

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