just did the upgrade to 1.0.2 from 0.9.6.3 last night. Everything’s great except a couple small php/mysql scripts that I was previously using with no problems. On the upgraded site, they’re just outputting mostly raw php code on the affected pages. The mysql table that I’m trying to access is within the same database as the rest of the modx tables. I’m including all the php/mysql code in a snippet--including the mysql connect code and the php echo code.
Before I go to the trouble of posting code here, did something change regarding how php/mysql is handled in 1.0.2? I looked through the wiki, the forums, and any other info. I could find but couldn’t really even find any references to using php/mysql code outside what’s already included in modx.
details of my hosting environment:
Apache 2.2.11
MySQL 5.1.30
PHP 5.2.9
Some of the core API functions were streamlined(deprecated).
You may have fallen victim to one of them.
I’ve had a couple of instances with my custom code.
thanks for your reply. Can you point to any support pages/forum threads/wiki pages that might help me work through my issue? I can usually figure things out if there’s some sort of guide or at least a set of specs to go by....
Or if you have any tips from your own experience, I’d appreciate those as well. Thanks!
There’s a partial list of deprecated functions for Revolution here:
http://www.bobsguides.com/revolution-objects.html. I don’t know of a list for Evolution but this will give you likely candidates.
Thanks, Bob.
The issue with this particular php/mysql is that is really is not interacting at all with any modx data. It’s some plain vanilla php code that is pulling some data from a table in the mysql database which is not one of the standard modx tables. It’s a totally separate table (within the modx database) that contains info. that does not need to interact in any way with modx. When I created it, putting the database table with the modx database was the only way I could connect and retrieve data from within a snippet. Believe me, I tried using includes/other snippets that called in data from a totally different database on the same server, but that didn’t work. This was the only method that worked for this feature.
So, I guess my question deals less with modx functions and more with how custom php/mysql works when used within a snippet within modx.
The only things I can think of that might be causing trouble are $modx->getFullTableName() or maybe one of the MODx DB API functions if you’re using them.
Feel free to post a problem snippet’s code here and any error messages you’re seeing (check the error logs as well).
Maybe one thing to try is replacing the echo in your php code with $output, then return $output at the end of the snippet:
<?php
/* your snippet
*/
// start output
$output ='';
// for echo spots in your snippet
// replace this:
//echo '<p>Content here...</p>';
// with this:
$output .='<p>Content here...</p>';
// if you are including a file, use $output.=''; instead of echo there too
return $output;
?>
You might also likely benefit by using the $modx->db->select() as opposed to connecting again to the same database.
http://wiki.modxcms.com/index.php/Access_another_database_from_MODx
Can’t recall what caused my issues but it was definitely core DB/API functions I’d hooked into, not standard PHP stuff.
thanks all, problem is now fixed. There were simply a bunch of php code blocks within the snippet; consolidating them all into a single php block solved the issue. I will definitely look into the other items mentioned here as a way of cleaning up my php/mysql.