August 31, 201016 yr Hey, just came across a strange thing happening to a piece of PHP I have. The code works as it should in IE, Firefox, chrome and safari. But it doesn't work in Opera? Anyone got any ideas why this would occur? Here's the code: <?php if($_GET['act'] == "generate_quotes") { $con = mysql_connect("*", "*", "*"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("quote", $con); $result = mysql_query( ' SELECT * FROM `quote` ORDER BY RAND() LIMIT 0,1 ' ); while($row = mysql_fetch_array($result)) { echo '<span class="pink">' . $row['q_quote'] . "</span>"; } echo "</table>"; mysql_close($con); } else { echo "<img src=\"img/vpbgt.png\">"; } ?> And the link: <a href="index.php?act=generate_quotes">Generate</a> It simply calls the function and dynamically changes the quote on screen. Quite simple, but I'm finding it strange that it's only opera it's not working in... Any ideas?
August 31, 201016 yr Got a visible link so we can see the full page? At a guess though, it could be some wierd HTML related issue because it looks like the PHP code you have does something like: if (something) { // close table tag } else { // don't close table tag, but output an unclosed img tag (<img src="" /> is how it should be really) } So could be that's what is throwing the spanner in the works as occasionally, or even always, you'll have broken HTML. W3 HTML validator will help you find all the issues.
August 31, 201016 yr Author Got a visible link so we can see the full page? At a guess though, it could be some wierd HTML related issue because it looks like the PHP code you have does something like: if (something) { // close table tag } else { // don't close table tag, but output an unclosed img tag (<img src="" /> is how it should be really) } So could be that's what is throwing the spanner in the works as occasionally, or even always, you'll have broken HTML. W3 HTML validator will help you find all the issues. Thankyou, I've checked the validator and it's shown a few errors like you said. Thanks for the advice
September 18, 201016 yr Hi! It seems like you are adding SPAN tags into a TABLE, when ideally they should be within a TR. Don't take my word for it - it's the World-wide Web Consortium that makes up the rules so the W3 validator will point it out to you too. Browsers behave differently when you have broken markup, so you would want to stay as close to the standards as you can.
Create an account or sign in to comment