/    Sign up×
Community /Pin to ProfileBookmark

Containing double-quotes in var

I need to have double-quotes in my variable start and inside the variable to parse other variables:

[code=php]
$news = ”
<table border=”0″ cellpadding=”0″ cellspacing=”0″ width=”100%” height=”89″ class=”newscontent”>
<tr>
<td width=”40″ class=”newstitle” height=”12″>
<p><img border=”0″ width=”40″ height=”40″ src=”<?php echo $dir,$img;?>”></p>
</td>
<td width=”731″ class=”newstitle” height=”12″><font face=”arial” size=”4″>&nbsp;<?php echo “$title</font>”;?></td>
<td width=”40″ class=”newstitle” height=”12″>
<p><img border=”0″ src=”<?php echo `$dir,$img`;?>” width=”40″ height=”40″></p>
</td>
</tr>
<tr>
<td width=”799″ class height=”57″ colspan=”3″><font face=”Arial” size=”1″><?php echo “&nbsp;
Posted on $date by $user”;?></font>
<dl>
<dd>
<p><font face=”Arial”><?php echo $text;?></font></dd>
</dl>
</td>
</tr>
<tr>
<td width=”799″ class height=”25″ colspan=”3″>
<p align=”center”><a href=”#top”><font color=”#FFFFFF” face=”Arial”>Back
to Top</font></a></td>
</tr>
</table>
[/code]

I know you cant have it like that, but it wont work with single-quotes. How can I change this, the HTML doesnt work properly if you change it there.

Then I need to have the variables written out so I can add them to the file I need to.

Please help ? ?

to post a comment
PHP

9 Comments(s)

Copy linkTweet thisAlerts:
@Bootsman123Dec 21.2003 — Use " instead of ".
Copy linkTweet thisAlerts:
@aoeguyauthorDec 21.2003 — On the start of the $news variable or inside it?
Copy linkTweet thisAlerts:
@PittimannDec 21.2003 — Hi!

You will have to use them inside ($news="...."...."...."?

Cheers - Pit)
Copy linkTweet thisAlerts:
@Bootsman123Dec 21.2003 — [i]Originally posted by aoeguy [/i]

[B]On the start of the $news variable or inside it? [/B][/QUOTE]


Inside $news.
Copy linkTweet thisAlerts:
@aoeguyauthorDec 21.2003 — Sure hope it will work ?

Thanks guys, if I have problems splitting the head section from the body in the destination page, I will be stuck ?
Copy linkTweet thisAlerts:
@aoeguyauthorDec 22.2003 — ?

When I write the variable to the file I get no text or anything! It just adds the exact code not parsed ?

Here is my code now:

[code=php]
if ($_GET['mode'] == "view"){
#Check article
?>
<head>
<title>News Admin</title>
<LINK REL="StyleSheet" HREF="../aompage.css" TYPE="text/css">
</head>
<body background="../aom/bg/greek.jpg" topmargin="0" leftmargin="0" text="#FFFFFF">
<?php
$text = $_POST["text"];
$date = $_POST["date"];
$title = $_POST["title"];
$dir = $_POST["dir"];
$img = $_POST["img"];
$news = "
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="89" class="newscontent">
<tr>
<td width="40" class="newstitle" height="12">
<p><img border="0" width="40" height="40" src="$dir$img"></p>
</td>
<td width="731" class="newstitle" height="12"><font face="arial" size="4">&nbsp;$title</font></td>
<td width="40" class="newstitle" height="12">
<p><img border="0" src="$dir$img" width="40" height="40"></p>
</td>
</tr>
<tr>
<td width="799" class height="57" colspan="3"><font face="Arial" size="1">
&nbsp;
Posted on $date by $user</font>
<dl>
<dd>
<p><font face="Arial">$text</font></dd>
</dl>
</td>
</tr>
<tr>
<td width="799" class height="25" colspan="3">
<p align="center"><a href="#top"><font color="#FFFFFF" face="Arial">Back
to Top</font></a></td>
</tr>
</table>
<p>&nbsp;</p>";

echo "$news";
echo "<a href="add.php?mode=add">Add it</a>";
}
if ($_GET["mode"] == "add"){
#Add to news.php
echo ('Adding item to news.php...<br>Processing...');
$file = fopen ("../news.php",a);
fwrite($file, "$news");
rewind($file);
}
?>
<!-- EOF -->
[/code]


I also tried the [b]fwrite($file, "$news");[/b] as [b]fwrite($file, $news);[/b]

I could give you the whole file if you want, it has nearly the whole script in.

It shows (in news.php) just the table with no images and when I view source code its the exact doe thats here in the variable ?
Copy linkTweet thisAlerts:
@Bootsman123Dec 22.2003 — Are you sure the variable is passed.

if ($_GET["mode"] == "add"){

#Add to news.php

echo ('Adding item to news.php...<br>Processing...');

$file = fopen ("../news.php",a);

fwrite($file, "$news");

rewind($file);

}

Echo $news within this function.
Copy linkTweet thisAlerts:
@PittimannDec 22.2003 — Hi!

First of all: on the very top you are lacking the opening '<?php'.

The problem is not the mode=add, but the mode=view! This variable is not in the $_GET['']. The filling of the $news variable is depending on the condition:

if ($_GET['mode'] == "view"){

do stuff...

}

Due to the fact, that this is not available, all the code before the line

if ($_GET["mode"] == "add"){

will not be executed.

My assumption is, that the form submitting the data has a method="post" instead of "get"...

Cheers - Pit
Copy linkTweet thisAlerts:
@aoeguyauthorDec 25.2003 — I had to fix it by just making it do that automatically when the page loads. That isnt the whole code there. It has got the php code tags in. I have a problem with the writing to the file:

I use list and explode then write the variables to the file I want to, but it removes the header from the file. If you need the file I can send it to you right away.
×

Success!

Help @aoeguy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...