Jump to content

*SOLVED* str_replace problem


Joost

Recommended Posts

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

[code]<?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>
[/code]
Link to comment
Share on other sites

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

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 (\').
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.