Page 1 of 1

Insert htm/javascriptl code into table

Posted: Thu Oct 08, 2009 5:02 pm
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.

Re: Insert htm/javascriptl code into table

Posted: Thu Oct 08, 2009 5:29 pm
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.

Re: Insert htm/javascriptl code into table

Posted: Thu Oct 08, 2009 5:30 pm
by requinix
You also failed to escape $title and $language before putting them into the query.