Jump to content

What is wrong with this code line?


bchandel

Recommended Posts

Taken out of context of where that is being used it is hard to tell (please post the whole php statement that code is part of), but I'll guess your overall string is using double-quotes to delimit it and the part you actually posted contains some un-escaped double-quotes so the overall syntax of the string was broken when the double-quotes were encountered.

Here is the complete code. Wants to make E-mail and Web clickable hyperlinks. Thank you!

 

<html>

<body>

<?php

$db_connect = mysql_connect("xxxx.com", "xxxx_user", "password");

mysql_select_db("xxxxx_database");

$query="SELECT * FROM Directory";

$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();

 

print "<h1><center>Chandel's Directory</center></h1><br>";

$i=0;

while ($i < $num) {

 

$Name=mysql_result($result,$i,"Name");

$LastName=mysql_result($result,$i,"LastName");

$FirstName=mysql_result($result,$i,"FirstName");

$Phone=mysql_result($result,$i,"Phone");

$Mobile=mysql_result($result,$i,"Mobile");

$Email=mysql_result($result,$i,"Email");

$Web=mysql_result($result,$i,"Web");

$State=mysql_result($result,$i,"State");

$Country=mysql_result($result,$i,"Country");

echo "<b>$Name</b><br>FirstName: $FirstName<br>

Home Phone: $Phone<br>

Mobile: $Mobile<br>

 

Email:<a href="mailto {['$Email']}"<Email></a><br>

 

Web Site: $Web<br>

State: $State<br>

Country:$Country<br><hr><br>";

 

$i++;

}

 

?>

</body>

</head>

I think this is your solution:

 

Email:<a href=\"mailto {['$Email']}\"><$Email></a><br>

 

 

 

You have to use backslashes inside the href, (or you can also use a single quote mark -> ' ), or else you will close the "echo".

 

Note: The backslash is being removed, but you must use a backslash before both Quotation marks -> "

 

By the way, please use code tags, since it will make it much easier to read, thanks =)

 

Best wishes

//AngelicS

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.