Forum Moderators: coopster
I'm trying to add a row to a MySQL table via a PHP script. The problem is that one field, of type TEXT, contains HTML source code. Here's the HTML code:
<FRAMESET rows="20%, 80%"><FRAME frameborder=1 noresize scrolling=no src="bannerPane.php"> and so on.
When I try to do something like:
$try = "<FRAMESET rows=\"20%, 80%\"><FRAME frameborder=1 noresize scrolling=no src=\"bannerPane.php\">"
echo $try;
Noting is displayed... I think the problem is the '<' and '>'.
So my first problem is to save this HTML code in a PHP variable. How can I do it? And secondly, once it's in a PHP variable, should I do something like addslashes($try) before executing the query?
THanks a lot for the help... I'm really about to die!
just adding '\' before the '"' is not sufficient
I think you are OK, except that you forgot to terminate your variable assignment with a semicolon. Put a semicolon (;) after the final quotation mark in the
$tryvariable assignment operation.
And yes, addslashes to the variable prior to using it in an SQL statement.
I'm sorry but it doesn't work either... code below:
<HTML>
<HEAD>
<TITLE>Let's see</TITLE>
</HEAD>
<BODY >
<H1 ALIGN="CENTER">Beginning...</H1>
<?
$try = "<FRAMESET rows=\"20%, 80%\"><FRAME frameborder=1 noresize scrolling=no src=\"bannerPane.php\">";
echo $try;
?>
<BR><b>End</b><BR>
</BODY>
</HTML>
into a variable (i.e, $try)
but this doesn't work:
<?
$try = "<FRAMESET rows=\"20%, 80%\"><FRAME frameborder=1 noresize scrolling=no src=\"bannerPane.php\">";
echo $try;
?>
nothing is displayed...
Ok, I'll tell what I found just in case someone wants to know what happened:
Let's take the following code:
<BODY>
Hola...
<?
$try = "<h1>hello</h1>";
echo $try;
?>
<BR>adios & Bye
</BODY>
The variable $try when echoes sends its content to the HTML browser and this one, "processes" the content. So when he finds a "<h1>hello</h1>", none of the <h1> and </h1> is displayed but interpreted as HTML tags and so Hello is displayed in the h1 format!
If we change this <h1>hello</h1> by the <FRAMSET... that I posted before, same happens but obviously this FRAMESET TAG was meaningless inside the BODY tag.
Thanks a lot ... it really helped me to tell my problem.
I wish y'all have a nice day!