recently after testing my sql query script I came across a problem. The greater than sign in my if statement ended the php and then output the rest of the code as html.
Here is my code. (It's in "poll.html", an html file with php code in it)
<div class="pollcont">
<?php
$pollrow = mysql_query("SELECT * FROM `Activepoll` ORDER BY `id` DESC LIMIT 1");
$rows = mysql_num_rows($pollrow);
if($rows > 0){ Do this stuff }; ?> </div>
Instead of finishing the if statement, 0){ Do this stuff }; ?
> is output into the browser.
Why is this happening and how can I change this so the script will work?
PHP - Greater than or equal to: >= Greater than or equal to operator is a logical operator that is used to compare two numbers.
Write a PHP function to test whether a number is greater than 30, 20 or 10 using ternary operator. <?php function trinary_Test ($n) { $r = $n > 30 ? "greater than 30" : ($n > 20 ? "greater than 20" : ($n >10 ? "greater than 10" : "Input a number atleast greater than 10!")); echo $n."
return may be preferable to exit in certain situations, especially when dealing with the PHP binary and the shell. I have a script which is the recipient of a mail alias, i.e. mail sent to that alias is piped to the script instead of being delivered to a mailbox.
The PHP comparison operators are used to compare two values (number or string): Returns an integer less than, equal to, or greater than zero, depending on if $x is less than, equal to, or greater than $y. Introduced in PHP 7. The PHP increment operators are used to increment a variable's value.
Your file must have the extension ".php".
What your seeing is your browser treating the PHP open tag "<" to the greater than sign ">" as an HTML element and simply hiding that source code. Its not processing anything while its an html file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With