Insert htm/javascriptl code into table

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ThaJock
Forum Newbie
Posts: 11
Joined: Tue Nov 04, 2008 10:15 pm

Insert htm/javascriptl code into table

Post by ThaJock »

I am having trouble inserting a block of html/javascript code into a table. In the following code the $artice variable contains the html/javascript code. The all the post variables are sent from an html form. Here is the query:

<?php
include("connect.php");
$title = $_POST['title'];
$language = $_POST['language'];
$description = mysql_real_escape_string($_POST['description']);
$article =mysql_real_escape_string($_POST['article']);

mysql_query("INSERT INTO tutorials
(title,language,description,article)
VALUES
('$title','$language','$description','$article')") or die('false');

echo 'true';
?>

The data is inserted into the table. However in the article field the string is cut off at

Here is the value of the $article variable:

<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
CODEBASE="http://active.macromedia.com/flash/cabs ... n=3,0,0,11"

WIDTH="220" HEIGHT="110" NAME="sw" ID="sw">
<PARAM NAME="Movie" VALUE="flash_movie.spl">
<PARAM NAME="quality" VALUE="high">
<PARAM NAME="Loop" VALUE="true">
<PARAM NAME="play" VALUE="true">

<!-- begin the JavaScript -->
<SCRIPT LANGUAGE="JavaScript">
<!-hiding contents from old browsers

//If this browser understands the mimeTypes property and recognizes the MIME Type //"application/x-shockwave-flash"...
if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]){

//...write out the following <EMBED> tag into the document.
document.write('<EMBED SRC="flash_movie.spl" WIDTH="220" HEIGHT="110" LOOP="true" QUALITY="high">');
}

//Otherwise,...
else {

//...write out the following <IMG> tag into the document. The image need
//not be the same size as the Flash Player movie, but it may help you lay out the
//page if you can predict the size of the object reliably.
document.write('<IMG SRC="welcome.gif" WIDTH="220" HEIGHT="110" ALT="Non-Shockwave Welcome">');
}

//Done hiding from old browsers. -->
</SCRIPT>

<!-- Close the OBJECT tag. -->
</OBJECT>


It inserts everything up to '&&' and doesn't insert the rest of $article. If anyone knows a solution to inserting html code into a table your help would be greatly appreciated.
ThaJock
Forum Newbie
Posts: 11
Joined: Tue Nov 04, 2008 10:15 pm

Re: Insert htm/javascriptl code into table

Post by ThaJock »

I figured it out. The problem is not in my query but in my form. I used the xmlHTTPRequest method to send the post variables overt to php. I failed to use escape(article) in before sending it.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Insert htm/javascriptl code into table

Post by requinix »

You also failed to escape $title and $language before putting them into the query.
Post Reply