• 0
Sign in to follow this  
Followers 0

Custom PHP search code

Question

Posted · Report post

I am trying to enter some custom search php code on a page and post the results of the search on the same page. How can I go about doing so? I have the code and have added it the contentbox. It keeps going to an index.php page.

Share this post


Link to post
Share on other sites

13 answers to this question

  • 0

Posted · Report post

Please post your site's url and the PHP code you are trying to implement so we can troubleshoot.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

http://healthcareledger.com/wordpress/?page_id=373 Code

Search

Search for: in First Name Results"; //If they did not enter a search term we give them an error if ($find == "") { echo "You forgot to enter a search "dbaddress","dbname ","password") or die('Could not connect to MySQL: ' .mysql_error()); mysql_select_db ("hea1201310200352") or die('Could not connect to MySQL: ' .mysql_error()); $find = strtoupper($find); $find = strip_tags($find); $find = trim($find); $data = mysql_query("SELECT * FROM wp_physicians WHERE upper(fName) like"% $find%""); while ($result = mysql_fetch_array($data)) { echo " "; echo $result['fName']; echo " "; echo $result['LName']; echo " "; echo " "; } $anymatches=mysql_num_rows($data); if ($anymatches == 0) { echo "Sorry, but we can not find an entry to match your query "; } //And we remind them what they searched for echo "Searched For: " .$find; } ?>

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

When I search for something, I get this error: [code]Fatal error: Call to a member function find() on a non-object in /home/content/40/6669540/html/wordpress/wp-content/plugins/exec-php/includes/runtime.php(42) : eval()'d code on line 941[/code] There is some kind of error occurring in one of the files for Exec PHP plugin you're using to input your PHP. What happens if you placed the code for the search results on a different page?

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

The same error shows up. Let me ask you this and this might help resolve the issue. I uploaded the exec-php plugin to include custom php code in the html tab. Since I am unable to use the code in the html tab of the page and view the result, I used the code in the contentbox of the mete settings of the page. Is there a way to view the code that was originally pasted in the html tab of the page?

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

[quote]Is there a way to view the code that was originally pasted in the html tab of the page? [/quote] What do you mean by "originally pasted in the HTML tab"? Did you paste the code there in a page before?

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

I dont know what your trying to achieve with that code, but its possibly THE most insecure code I've ever seen.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Simon, Being a newbie to coding I appreciate your encouragement. Thank you.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Are you going to continue using the code?

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Well what exactly are you trying to search for? Posts? Pages? The wordpress search can be modified using filters.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

This is what I am trying to do: 1. create some custom code to search against a table in the database 2. Display the search results either on the same page or a new page Is there a tutorial on how to include custom code in the pagelines templates?

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Well you could create a custom section, and include your code there, but strongly suggest you have a look at the wordpress codex on correct use of the $wpdb class, which will sanitize any queries going to the database.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

I will. As mentioned to you I am a newbie. Is there a tutorial or document around creating custom sections?

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Here is a blank section. http://pastie.org/3505827

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0