Jwest100 Posted December 14, 2016 Share Posted December 14, 2016 (edited) 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 December 14, 2016 by Jwest100 Quote Link to comment https://forums.phpfreaks.com/topic/302743-please-help-newbie-with-php/ Share on other sites More sharing options...
Barand Posted December 14, 2016 Share Posted December 14, 2016 can anyone tell me if there is any problem with the way I have written these statements? Yes, there is. Quote Link to comment https://forums.phpfreaks.com/topic/302743-please-help-newbie-with-php/#findComment-1540344 Share on other sites More sharing options...
Jwest100 Posted December 14, 2016 Author Share Posted December 14, 2016 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. Quote Link to comment https://forums.phpfreaks.com/topic/302743-please-help-newbie-with-php/#findComment-1540345 Share on other sites More sharing options...
Barand Posted December 14, 2016 Share Posted December 14, 2016 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? Quote Link to comment https://forums.phpfreaks.com/topic/302743-please-help-newbie-with-php/#findComment-1540348 Share on other sites More sharing options...
benanamen Posted December 14, 2016 Share Posted December 14, 2016 (edited) The code will be controlling the HTML display in a page. No it won't. To answer your question, yes, there is a problem with the way you wrote it. Edited December 14, 2016 by benanamen Quote Link to comment https://forums.phpfreaks.com/topic/302743-please-help-newbie-with-php/#findComment-1540349 Share on other sites More sharing options...
maxxd Posted December 14, 2016 Share Posted December 14, 2016 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. Quote Link to comment https://forums.phpfreaks.com/topic/302743-please-help-newbie-with-php/#findComment-1540350 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.