Hey guys modxnooby here agian..
My modx system is just soo touchy. Any way I am creating a snippet to pull in a search from the page before and make it search the database this is what it looks like:
<?php
$sql=processSearch();
printResults($sql);
function processSearch() {
$searchField=$_POST["search"];
$sql="SELECT `name`, `video`, `image`
FROM videos
WHERE
name LIKE '%$searchField%'";
return $sql;
}
function printResults($sql) {
$username="username";
$password="password";
$host="localhost";
$dbname="database";
$conn = mysql_connect($host, $username,$password);
mysql_select_db($dbname);
$result=mysql_query($sql,$conn);
while ($row = mysql_fetch_assoc($result)) {
print "<div class='tablecell'><a rel='prettyPhoto' href='" . $row["video"] . "' title='" . $row["name"] . "' alt='" . $row["name"] . "'><img src='[[++image-path]]" . $row["image"] . "'></a></div>";
}
}
?>
Now when i put a search in the search bar and click submit I get this Error:
Fatal error: Call to undefined function processSearch() in public_html/core/cache/includes/elements/modsnippet/158.include.cache.php on line 7
Now I went to the path it said to look in and this code was added to my snippet (without my knowing)
function elements_modsnippet_158($scriptProperties= array()) {
global $modx;
if (is_array($scriptProperties)) {
extract($scriptProperties, EXTR_SKIP);
}
This is some how making my script not function because when I tested this script without modx it worked. So I tried taking this code off my snippet then I saved it and retried my search. The search worked!

But then I did another search to make sure it worked and none of the search results showed up.

So I am thinking that this code is needed for modx snippets. But it still is messing with my code.
Can someone tell me what is wrong with my code?