Jump to content

Please help newbie with php...


Jwest100

Recommended Posts

Hi,

Without trying to analyze what I'm doing or why, and to keep the question as simple as possible, can anyone tell me if there is any problem with the way I have written these statements?

 

The code will be controlling the HTML display in a page.

 

some HTML content...

 

<?php

if(!get_post_meta(get_the_ID()),'buy_status', true);

echo "<h5 style="text-align: center;display: block;">";

echo "Sorry, this piece is sold.";

else

echo "<h5 style="text-align: center;display: none;">";

endif;

?>

</h5>

 

More HTML content...

Edited by Jwest100
Link to comment
Share on other sites

Brilliant answer! You win a cigar Barand! The help is much appreciated and explicitly reminds me how arrogant and absurdly self-righteous coders are. Apparently unable to intuitively interpret a question in any other way than literal. Congrats! You are a huge contributor to everyone you meet I bet.

 

It would be best to not answer my friend if that is all you can contribute.

Link to comment
Share on other sites

I answered the question that you asked. We were told not to analyze what you were doing, therefore cannot say more. To do so would be to make assumptions about your intentions.

 

You need to ask better questions.

 

What is it that makes you believe there is a problem? What symptoms are you getting? What is happening or not happening?

Link to comment
Share on other sites

Actually, it's safe to say there are several problems with the way this is written. There are problems with the PHP (malformed conditional, malformed conditional block, nested double quotes in output), the WordPress specific code (malformed get_post_meta() call), the actual output (inline styling), and the basic tenets of modern programming (duplicate code). If you turn on error reporting (either PHP's error reporting or set WordPress's WP_DEBUG constant to true), you should see several rather helpful error messages.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.