Writing Mysql and Php code in wordpress Posts - php

I am wordpress and i am writing php or mysql code in a post but finally when i hit publish it gives an Server Error : 500 , i also trying putting my code under [code] [/code] tags nothing happened but when i remove my codes and hit publish then it's working
Any idea guys
Waiting for help

PHP code in the post? Can you use page instead of post? If yes, you could assing custom template for the page and execute code in it(I mean template). If no, try this http://wordpress.org/extend/plugins/exec-php/

Related

how to put php code in a wordpress page

I have created custom page in wordpress and in the page I have a form where users can upload a banner, and input some text.
The code is working perfectly on a local server. The problem is when I transfer to the live page, it is displayed as text instead of working normally.
I have tried to search for the page in cPanel but have later realized the pages are not stored as normal pages but stored in a database.
Please help me how to make my form work.
You can't put a php code (this is a code not a content) as a post content from the admin panel. A php file must be created (or using the functions.php) to serve that page and put the code there.
Find and open the functions.php file. It is located under the wp-content/themes/yourthemename/ folder.
At the end of the file (but before the ?> symbols if exist) add this code
function custom_function_for_your_page() {
// put your php code here
}
add_shortcode( 'custom_functionality', 'custom_function_for_your_page' );
Now as you guess, you can put the php code right below this line // put your php code here.
This is a shortcode. Now you can put that shortcode into the page content.
Open that page from the admin panel, where you've tried to put the php code. Instead of that code put this [custom_functionality].
Good luck :) Tell me if it doesn't work, we'll try more.
Looks like you may need a plugin, here is one such plugin I know about:
https://wordpress.org/plugins/insert-php/

Load multiple content in same page

i have check about this question. But still stuck, I am using wordpress and want to insert it in some page or post.
So i have searched and see this code http://jsfiddle.net/akhurshid/NuwE6/ but when i transfer to html or insert in http://liveweave.com/8PQ77Q and nothing happen?
Any idea?
Thanks for your help
You probably don't have jQuery included in your page. For instance, on LiveWeave, you need to add jQuery as a library to see your code working. Just check you have jQuery loaded on your Wordpress website.

Facebook Plugins wont work with ajax

I have a blog page that uses ajax to call different article from PHP files once the relevant link is clicked. The problem is that when the PHP loads the Facebook plug-ins don't work. If I open the PHP files using the URL directly in the address bar on the browser then they work fine. I am including links to my page so that you can see it in action. If you replace blog.html with blog1.php you will see what I mean. I would really appreciate any help. Thanks. http://www.tagwebsites.com.au/blog.html
I managed to sort this out with the help of Facebook. The issue was as simple as adding the BFML tag to the html tag at the top of each page. It works great now. Thank you to everyone that sent messages through. I really appreciate your help.

Crawl Website using PHP

I've tried a bunch of techniques to crawl this url (see below), and for some reason the title comes back incorrect. If I look at the source of the page with firebug I can see the correct title tag, however, if I view the page source it's different.
Using several php techniques I get the same result. Digg is able to crawl the page and parse the correct title.
Here's the link: http://lifehacker.com/#!5772420/how-to-make-ios-more-like-android
The correct title is "How to Make Your iPhone (or Other iOS Device) More Like Android"
The parsed title is "Lifehacker, tips and downloads for getting things done"
Is this normal? How are they doing this? Is there a way to get the correct title?
That's because when you request it using PHP (without any JS support) you're getting the main page of lifehacker - which is lifehacker.com.
Lifehacker switched their CMS recently so that all requests go to an initial page and then everything after the hashbang is read by a JS script in the main page to figure out which page needs to be served. You need to modify your program to take this into account
EDIT
Have a gander at these links
http://code.google.com/web/ajaxcrawling/docs/getting-started.html
http://www.tbray.org/ongoing/When/201x/2011/02/09/Hash-Blecch
Found the answer:
http://lifehacker.com/#!5772420/how-to-make-ios-more-like-android
becomes:
http://lifehacker.com/?_escaped_fragment_=5772420/how-to-make-ios-more-like-android

WordPress - PHP Code Box

I am very new to WordPress, so I would appreciate some help.
I am using WordPress as a CMS, and I am trying to make the thing work so that when I select a page to edit, there is a special box where I can input PHP code that will execute on my page.
I have found the PHP exec plugin, which works perfectly, but I would like to keep the code out of my main text editor, out of the way of my client's careless fingers.
Any suggestions would be very, very appreciated. Thanks!
You could create a template for each one, and include your PHP there.
Simply select the template from the page edit page.
But if you are only including a little PHP per page, you could get the slug via WordPress in your page template and act on it accordingly.
You can also add an extra meta box on the post editor page, only visible to you, with a textarea where you can add the code. You would save it as a meta field of the post. Your template can check for the existence of this field, and execute it if found.
PHP Exec is the best plugin I have found, and I looked long and hard for that one. The problem with doing it as you suggest is that if the PHP code displays an item on the page, it still has to be formatted within the page as well. It is a simple logistical problem, but somewhat of a complex coding problem. I haven't been able to get around to working on creating a better plugin for it.

Categories