Jump to content


Photo

*SOLVED* str_replace problem


  • Please log in to reply
2 replies to this topic

#1 Joost

Joost
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 17 April 2006 - 08:11 AM

When i add str_replace it will stop working and i get this error:
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/content/R/u/n/Runetower/html/result.php on line 34

<?php
  $title = $_POST["title"];
  $metades= $_POST["metades"];
  $metakey= $_POST["metakey"];
  $maincontent= $_POST["maincontent"];
  $head= $_POST["head"];
  $guidecat=  $_POST["guidecat"];
  $guidecatb= $_POST["guidecatb"];
  $guidename= $_POST["guidename"];
  $creditswriter= $_POST["creditswriter"];
  $creditspictures= $_POST["creditspictures"];
  $creditseditor= $_POST["creditseditor"];
  $creditscoder= $_POST["creditscoder"];
  $creditsothername= $_POST["creditsothername"];
  $creditsother= $_POST["creditsother"];
  $start= $_POST["start"];
  $requireditems= $_POST["requireditems"];
  $requiredquests= $_POST["requiredquests"];
  $requiredskills= $_POST["requiredskills"];
  $requiredmonsters= $_POST["requiredmonsters"];
  $requiredothername= $_POST["requiredothername"];
  $requiredother= $_POST["requiredother"];

  $find[] = '\"'; 
  $replace[] = ''';
  $title = str_replace($find, $replace, $title);
?>

$title="<?php echo $title; ?>"; //the title of the page (use the guide name)
$metades="<?php echo $metades; ?>"; //a description
$metakey="<?php echo $metakey; ?>"; //some keywords related to

the guide (seperate by ,)
$maincontent="<?php echo $maincontent; ?>"; //*the main page content or the main part of the guide (make sure it has no " in it replace it with '*//
$head="<?php echo $head; ?>"; //Something on the top of the page that needs to be added?
//only for guides
$guidecat="<?php echo $guidecat; ?>"; //* 0=not a guide 1=needs requirements 2=no requirements *//
$guidecatb="<?php echo $guidecatb; ?>"; //* 0=not a guide 1=quest guide 2=skill guide 3=city guide 4=other guide *//
$guidename="<?php echo $guidename; ?>"; //name of the guide
$creditswriter="<?php echo $creditswriter; ?>"; //who wrote the guide?
$creditspictures="<?php echo $creditspictures; ?>"; //who made the pictures?
$creditseditor="<?php echo $creditseditor; ?>"; //who edited the guide?
$creditscoder="<?php echo $creditscoder; ?>"; //who coded the guide?
//If their need to be credits for something else add here
$creditsothername="<?php echo $creditsothername; ?>"; //What sort of thing is required else?
$creditsother="<?php echo $creditsother; ?>"; //Here the content...
//only for quest guides
$start="<?php echo $start; ?>"; //where to start?
$requireditems="<?php echo $requireditems; ?>"; //items you need to have
$requiredquests="<?php echo $requiredquests; ?>"; //quests you need to have done
$requiredskills="<?php echo $requiredskills; ?>"; //skill level requirements
$requiredmonsters="<?php echo $requiredmonsters; ?>"; //monsters that you need to kill during the quest
//If their is something else required add here (if none don't pute something their)
$requiredothername="<?php echo $requiredothername; ?>"; //What sort of thing is required else?
$requiredother="<?php echo $requiredother; ?>"; //Here the content...
<textarea cols=70 rows=6>
</textarea>


#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 17 April 2006 - 08:27 AM

change
$replace[] = ''';
to
$replace[] = '\'';

It was because you was not escaping your single quote and so PHP though you finished when you had typed the secound ' and when it came to the third ' it cuased the error. The middel ' needed to be escaped (\').

#3 Joost

Joost
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 17 April 2006 - 08:51 AM

Thx this works great ;)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users