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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.