Skip to main content
Inspiring
January 25, 2007
Question

PHP Question - Links Breaking Code

  • January 25, 2007
  • 1 reply
  • 217 views
Hello-
I am helping a client update a site that was written in PHP. I am not very proficient in this language and have run into a problem creating a mailto link. Whenever I add the link, it breaks the page and nothing displays. I take it out and the page appears again. Any help would be appreciated.

Here is the page code with the mailto included:
This topic has been closed for replies.

1 reply

Inspiring
January 26, 2007
Obviously youre using custom code to create the page, ie the createPage()
function, and im not sure what that does, however from the looks of things I
think its the " marks in the a href are causing the problem, as its looks
like createPage expects a list of parameters, and its seeing the " mark as a
new parameter.

Replace " with ' , it won't make any difference to the way the link works,
but it should stop the string from being broken in the parameter list ie:

<?php
include_once(dirname(__FILE__). '/inc/sitecommon.php');
$html = createPage("Contacts","<div
class='bgWords_home'></div>","","<p>1.888.4.STROKE (478.7653)</p><p>National
Center<br>7272 Greenville Avenue<br>Dallas, Texas 75231-4596</p><p><a
href='mailto:info@sharegivers.org'>info@sharegivers.org</a></p>");
print $html;
?>

Give it a try and see if it works

An Alternative is to escape the quotes eg using \" for the link ie

<?php
include_once(dirname(__FILE__). '/inc/sitecommon.php');
$html = createPage("Contacts","<div
class='bgWords_home'></div>","","<p>1.888.4.STROKE (478.7653)</p><p>National
Center<br>7272 Greenville Avenue<br>Dallas, Texas 75231-4596</p><p><a
href=\"mailto:info@sharegivers.org\">info@sharegivers.org</a></p>");
print $html;
?>

Either should work, but I find ' is easier to read than \", but both do the
same thing


--
Gareth
http://www.phploginsuite.co.uk/
PHP Login Suite V2 - 34 Server Behaviors to build a complete Login system.