5 Replies - 5420 Views - Last Post: 24 January 2012 - 11:08 AM Rate Topic: -----

#1 epidemik  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 49
  • Joined: 14-June 08

When I insert an object tag into the database it turns to an invalid..

Posted 23 January 2012 - 02:14 PM

When I insert an object tag into the database it turns to an invalidtag, I am confused on why it does this. everything else works fine when i just use text, but when i use html to post an youtube video it says invalidtag. This happens when I use a regular textarea box or the WYSIWYG text editor also. Can anyone point me in the right direction to figure out a solution.

Thanks for any help that can be provided.
Is This A Good Question/Topic? 0
  • +

Replies To: When I insert an object tag into the database it turns to an invalid..

#2 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 1947
  • View blog
  • Posts: 3,488
  • Joined: 13-January 08

Re: When I insert an object tag into the database it turns to an invalid..

Posted 23 January 2012 - 02:20 PM

epidemik, do us a favor and post the form and the form processing code (along with the SQL that does the database insert statement) and the exact error message you're getting.

Without a code example or two it's near impossible to tell what you might be doing wrong.
Was This Post Helpful? 0
  • +
  • -

#3 epidemik  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 49
  • Joined: 14-June 08

Re: When I insert an object tag into the database it turns to an invalid..

Posted 23 January 2012 - 03:45 PM

View PostCraig328, on 23 January 2012 - 02:20 PM, said:

epidemik, do us a favor and post the form and the form processing code (along with the SQL that does the database insert statement) and the exact error message you're getting.

Without a code example or two it's near impossible to tell what you might be doing wrong.


The thing is there is no error code. Everything inserts.

this is the output in the database:


<InvalidTag width="560" height="315"><param name="movie" value="http://www.youtube.com/v/T6j4f8cHBIM?version=3&amp;hl=en_US"><param name="allowFullScreen" value="true"><param name="allowscriptaccess" value="always"><InvalidTag src="http://www.youtube.com/v/T6j4f8cHBIM?version=3&amp;hl=en_US" type="application/x-shockwave-flash" width="560" height="315" allowscriptaccess="always" allowfullscreen="true"></object>




here is the code:

the form:


<script language="Javascript" type="text/javascript" src="wysiwyg.js">
</script>

<cfif session.logged_in eq 0>
	<cflocation url="../index.cfm" addtoken="no">
</cfif>

<cfquery datasource="#dsn#" name="user">
SELECT *
FROM user
WHERE userID = #session.user_id#
</cfquery>


<cfif session.user_level neq 'admin'>
	<cflocation url="../index.cfm" addtoken="no">
</cfif>

<cfoutput>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Post</title>
</head>

<body>
<form method="post" enctype="multipart/form-data" action="post_process.cfm">
<table>
	<tr><td width="167">Title</td><td width="336"><input type="text" name="title" /></td></tr>
    <tr><td>type</td><td>
    <select name="type">
    	<option value="featured">Featured</option>
        <option value="blog">Blog</option>
        <option value="featured">Featured</option>
    </select>
    </td></tr>
    <tr><td>Please upload an image: </td><td><input type="file" name="UploadFile"></td></tr>
    <tr><td colspan="2">Post:<br />
<textarea id="textarea1" name="post" style="height: 170px; width: 500px;">

</textarea>
<script language="javascript1.2">
  generate_wysiwyg('textarea1');
</script>
    
    <tr><td></td>
    <tr><td colspan="2">Summary:<br />
    <textarea id="textarea2" name="summary" style="height: 170px; width: 500px;">

</textarea>
<script language="javascript1.2">
  generate_wysiwyg('textarea2');
</script>
    
    </td></tr>
    <tr><td>
    <input type="hidden" value="#user.username#" name="poster" />
	<input type="hidden" value="#session.user_id#" name="posterID" />
    </td><td align="right"><input type="submit" value="POST" /></td></tr>
</table>


</form>
</body>
</html>
</cfoutput>







the process:


<cfset UploadFolder="#ExpandPath( '..\images\blogimages\' )#">

<cfoutput>  
<cfif DirectoryExists(UploadFolder)>  
  <cfif IsDefined("Form.UploadFile") AND Form.UploadFile NEQ "">  
    
             <cffile   
                 action="upload"   
                 filefield="UploadFile"   
                 destination="#UploadFolder#"   
                 nameconflict="overwrite"  
                 accept="image/*"  
                 >  
                 File uploaded successfully!  
                 <br />  
                 Uploaded file: #cffile.ClientFile#  


<cfparam default="null" name="tags">

<cfquery datasource="#dsn#">
INSERT INTO blog (title, post, type, poster, posterID, image, summary, comCount, tags, video)
VALUES ('#title#', '#post#', '#type#', '#poster#', #posterID#, '#cffile.ClientFile#', '#summary#', 0, '#tags#', '#video#') 
</cfquery>



Your Post Has been successful
       
      
      
     <cfelse>  
         Select a file first!          
     </cfif>  
<cfelse>  
  Upload Directory not exists      
</cfif>  
</cfoutput> 

 
      <!---
<cflocation url="../album_edit.cfm?aid=#album_id#">
--->



Was This Post Helpful? 0
  • +
  • -

#4 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 1947
  • View blog
  • Posts: 3,488
  • Joined: 13-January 08

Re: When I insert an object tag into the database it turns to an invalid..

Posted 24 January 2012 - 07:28 AM

Okay...so let me understand for a moment what it is you're trying to do. You have a textarea form field and you're putting something into that that the database spits back out with an invalidtag, right? The field is labelled "Summary" so what kind of input do you expect users to drop in there?

Can you post the content of what you're putting into the textarea field (looks like a link to a YouTube video to me) that causes the database to choke like that? Also, what database product/version are you using?

Without seeing it, I'm wondering if perhaps you should consider a different way of approaching the problem. Rather than let the user provide the entire object tag and attributes, why not simply have them provide the YouTube link to the video. Like, for instance, the video you used for an example is this link here: http://www.youtube.com/v/T6j4f8cHBIM. Thing with YouTube is that all you really need is that last part of that URL string. The "T6j4f8cHBIM" part. That's the video ID and you can call any video on YouTube by dropping the video ID onto the end of the URL like on that link.

You could do a quick string ReplaceNoCase of the blog.summary whenever you retrieve it replacing any instance of "http://www.youtube.com/v/xxxxxx" with the object tag and using that URL and it makes your app a little cleaner and easier to manage. That and, if for whatever reason, the OBJECT tag gets an upgrade in the future, you don't have to go back through your database and replace all instances of that tag with whatever the new form is.

This post has been edited by Craig328: 24 January 2012 - 07:42 AM

Was This Post Helpful? 0
  • +
  • -

#5 epidemik  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 49
  • Joined: 14-June 08

Re: When I insert an object tag into the database it turns to an invalid..

Posted 24 January 2012 - 10:03 AM

View PostCraig328, on 24 January 2012 - 07:28 AM, said:

Okay...so let me understand for a moment what it is you're trying to do. You have a textarea form field and you're putting something into that that the database spits back out with an invalidtag, right? The field is labelled "Summary" so what kind of input do you expect users to drop in there?

Can you post the content of what you're putting into the textarea field (looks like a link to a YouTube video to me) that causes the database to choke like that? Also, what database product/version are you using?

Without seeing it, I'm wondering if perhaps you should consider a different way of approaching the problem. Rather than let the user provide the entire object tag and attributes, why not simply have them provide the YouTube link to the video. Like, for instance, the video you used for an example is this link here: http://www.youtube.com/v/T6j4f8cHBIM. Thing with YouTube is that all you really need is that last part of that URL string. The "T6j4f8cHBIM" part. That's the video ID and you can call any video on YouTube by dropping the video ID onto the end of the URL like on that link.

You could do a quick string ReplaceNoCase of the blog.summary whenever you retrieve it replacing any instance of "http://www.youtube.com/v/xxxxxx" with the object tag and using that URL and it makes your app a little cleaner and easier to manage. That and, if for whatever reason, the OBJECT tag gets an upgrade in the future, you don't have to go back through your database and replace all instances of that tag with whatever the new form is.


I did think of just using the url but then I thought I am not only posting youtube videos, it works when i use the iframe code generated by youtube. Just have to check the other video media player embed codes.

The type of database is the latest MYSQL database.
Was This Post Helpful? 0
  • +
  • -

#6 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 1947
  • View blog
  • Posts: 3,488
  • Joined: 13-January 08

Re: When I insert an object tag into the database it turns to an invalid..

Posted 24 January 2012 - 11:08 AM

True enough but still...if you do pre-processing before you output it, you can detect Youtube via the URL and other sites as well and then conditionally build out the object tag with the appropriate link info.

I'd look more into that than trying to swallow the entire object tag and attributes whole.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1