Jump to content

Syntax error around href


wright67uk

Recommended Posts

Im looking to change my page ever so slightly to fit in with my .htaccess file.  However I have a syntax issue.

Can anybody explain how to fix the below syntax and what i have done wrong so that I can learn from it.

 


<?php
$query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Cars and Travel' AND confirmed ='Yes' ORDER BY name");
echo mysql_error();
while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0];
$i = -1;
foreach($nt as $value)
{$i++;
$FileName = str_replace(' ','_',$nt[$i]);
$FileUsed = str_replace('_',' ',$nt[$i]);
echo "<a href="str_replace(' ','_',$nt[$i])">" . ucwords(strtolower (($nt[$i]))) . "</a>" . "<br/>";
/*THE SYNTAX ERROR Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' IS IN THE ABOVE LINE*/
$FileHandle = fopen($FileName, 'w') or die("cant open file");
$pageContents = file_get_contents("header.php");
fwrite($FileHandle,"$pageContents");}
fclose($FileHandle);
?>

 

This is how it was before;

 

<?php

$nt = array();

$query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Legal' AND confirmed ='Yes' ORDER BY name");

echo mysql_error();

while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0];

$i = -1;

foreach($nt as $value)

{$i++;

$FileName = str_replace(' ','_',$nt[$i]) . ".php";

$FileUsed = str_replace('_',' ',$nt[$i]);

echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?subtype=$FileUsed'>"  . ucwords(strtolower (($nt[$i]))) . "</a>" . "<br/>";

$FileHandle = fopen($FileName, 'w') or die("cant open file");

$pageContents = file_get_contents("header.php");

fwrite($FileHandle,"$pageContents");}

fclose($FileHandle);

?>

 

The reason ive altered the top script is that i want my links to be like

 

mysite.com/solicitor

 

opposed to

 

mysite.com/solicitor.php?subtype=solicitor

 

The error is on line 47 which I have labelled in comments

 

PS.  I know my php is a bit of a wreck but when I get this syntax issue fixed Ill be working on it.

Link to comment
https://forums.phpfreaks.com/topic/245532-syntax-error-around-href/
Share on other sites

I have changed it to

 "<a href='" . str_replace(' ','_',$nt[$i]) . " '>"  . ucwords(strtolower (($nt[$i]))) . "</a>" . "<br/>";

opposed to;

 "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?subtype=$FileUsed'>"  . ucwords(strtolower (($nt[$i]))) . "</a>" . "<br/>";

but now the syntax error is saying Parse error: syntax error, unexpected T_VARIABLE in Line 46, there was nothing wrong with line 46 before I edited this line.

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.