Skip to content Skip to sidebar Skip to footer

Php Function Ignoring An If Statement

Due to one agent wanting his website url on the functionality that I worked on a month ago I ended up having to make some minor changes. I have two function PHP pages that run a ve

Solution 1:

"<a target='blank' href=" .$Website . ">"

This is your problem: You do not have quotes around your url. It outputs like this:

<ahref=http://whatever.com/path>Company</a>

You need to add quotes like this:

"<a target='blank' href='" .$Website . "'>"

The url looks like this!

<atarget='blank'href=http://www.samfiorentino.com/>Sam Fiorentino & Associates</a>

It needs quotes. The ending / in the URL is ending the <a>.


The reason why the first one works but the second one doesn't:

innerHTML lets the browser interpret the html. $(...) is interpreted by jQuery, which does some fancy things for browser compatibility, but sometimes has drawbacks. Some browsers attempt to fix bad markup, and sometimes the browser does a bad job of it. jQuery makes them all mostly act the same.

See this jsfiddle for comparison: http://jsfiddle.net/Rk7SQ/

<p>Browser rendering:</p><p><atarget='blank'href=http://www.samfiorentino.com/>Sam Fiorentino & Associates</a></p><p>jQuery rendering:</p><pid="jqrender"></p>

$(function() {
    $('#jqrender').html("<atarget='blank'href=http://www.samfiorentino.com/>Sam Fiorentino & Associates</a>");
});

You can see that they are different.

Post a Comment for "Php Function Ignoring An If Statement"