SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Aug 2012
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb Tinymce textarea Php Mysql Help

    Looking for help currently using Tinymce for textarea Description section.
    I'm trying to add image & hyperlink like in the picture image I included It lets me add image and hyperlink I can see it in the area but when I go to publish it I get an Error message.
    I think I have some code blocking some html. Because I can use some html to add bold,italic and it allows me to publish. But I just can't add html code for link or images.
    I really need help in trying to figure this out.


    I think the problem might be with some code i'm using in my m_editmedia.php file below.

    PHP Code:
    <p>EDIT <?=strtoupper($_GET["mediatype"])?> DETAILS</p>
    <?
        $conn
    =mysql_connect($dbhost$dbuser$dbpass);
        
    mysql_select_db($dbname) or die ('Could not connect: ' mysql_error());
        
    // print "Connected to MySQL"; 
        
        
    $query="SELECT * FROM t_media WHERE m_id=".$_GET["mediaid"]." LIMIT 1";
        
    //echo $query;
        
    $qresult mysql_query($query);
        
        while (
    $line mysql_fetch_assoc($qresult)){
    ?>    
        

        <form id="frmEditMedia" name="frmEditMedia" method="post" action="index.php?action=doeditmedia">
    <table width="500" border="0" cellspacing="1" cellpadding="1">
      <tr>
        <td width="200" align="right" valign="bottom">&nbsp;</td>
        <td align="left" valign="bottom">&nbsp;</td>
      </tr>
      <tr>
        <td align="right" valign="middle">Type: </td>
        <td align="left" valign="bottom" style="color:#FF0000">
            <input name="radMediaType" type="radio" value="video" <?=(($_GET["mediatype"]=="video")?"checked=\"checked\"":"")?> />
             Video
            <input name="radMediaType" type="radio" value="picture" <?=(($_GET["mediatype"]=="picture")?"checked=\"checked\"":"")?> />
            Picture
            </td>
      </tr>
      <tr>
        <td align="right" valign="middle">Title:</td>
        <td align="left" valign="bottom">
          <input name="txtMediaTitle" type="text" id="txtMediaTitle" value="<?=$line["m_title"]?>" size="40" maxlength="128" />
        </td>
      </tr>
      <tr>
        <td align="right" valign="middle">URL:</td>
        <td align="left" valign="bottom">
          <input name="txtMediaUrl" type="text" id="txtMediaUrl" value="<?=$line["m_url"]?>" size="40" maxlength="128" />
        </td>
      </tr>
      <tr>
        <td align="right" valign="middle">Description:</td>
        <td align="left" valign="bottom">
         <script type="text/javascript" src="/admin/js/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
    <script type="text/javascript">
    tinyMCE.init({
            // General options
            mode : "textareas",
            theme : "advanced",
            plugins : "autolink,lists,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

            // Theme options
            theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
            theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
            theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
            theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",
            theme_advanced_toolbar_location : "top",
            theme_advanced_toolbar_align : "left",
            theme_advanced_statusbar_location : "bottom",
            theme_advanced_resizing : true,

            // Skin options
            skin : "o2k7",
            skin_variant : "silver",

            // Example content CSS (should be your site CSS)
            content_css : "css/example.css",

            // Drop lists for link/image/media/template dialogs
            template_external_list_url : "/admin/js/template_list.js",
            external_link_list_url : "/admin/js/link_list.js",
            external_image_list_url : "/admin/js/image_list.js",
            media_external_list_url : "/admin/js/media_list.js",

            // Replace values for the template plugin
            template_replace_values : {
                    username : "Some User",
                    staffid : "991234"
            }
    });
    </script>
      <textarea name="txtMediaDescription" cols="64" rows="10" id="txtMediaDescription"><?=$line["m_description"]?></textarea>
        </td>
      </tr>
      <tr>
        <td align="right" valign="middle">Tags (separated by ","):</td>
        <td align="left" valign="bottom">
          <input name="txtMediaTags" type="text" id="txtMediaTags" value="<?=$line["m_tags"]?>" size="82" maxlength="128" />
        </td>
      </tr>
      <tr>
        <td align="right" valign="bottom">&nbsp;</td>
        <td align="left" valign="bottom">&nbsp;</td>
      </tr>
        <td align="right" valign="bottom">&nbsp;</td>
        <td align="left" valign="bottom"><input type="submit" value="Make changes" /></td>
      </tr>
    </table>
    <input type="hidden" name="hidMediaID" value="<?=$_GET["mediaid"]?>" />
    <input type="hidden" name="hidMediaType" value="<?=$_GET["mediatype"]?>" />
    </form>
        
    <?    
        
    }
        
    mysql_close($conn);
    ?>
    m_addmedia.php page:
    PHP Code:
    <p>ADD MEDIA</p>
    <
    form enctype="multipart/form-data" id="frmAddMedia" name="frmAddMedia" method="post" action="index.php?action=doaddmedia">
    <
    table width="600" border="0" cellspacing="1" cellpadding="1">
      <
    tr>
        <
    td width="200" align="right" valign="bottom">&nbsp;</td>
        <
    td align="left" valign="bottom">&nbsp;</td>
      </
    tr>
      <
    tr>
        <
    td align="right" valign="middle">Type: </td>
        <
    td align="left" valign="bottom" style="color:#FF0000">
          <
    input name="radMediaType" type="radio" value="video" />Video
          
    <input name="radMediaType" type="radio" value="picture" />Picture
                
    </td>
      </
    tr>
      <
    tr>
        <
    td align="right" valign="middle">Title:</td>
        <
    td align="left" valign="bottom">
          <
    input name="txtMediaTitle" type="text" id="txtMediaTitle" value="Replace This Title" size="40" maxlength="128" />
        </
    td>
      </
    tr>
      <
    tr>
        <
    td align="right" valign="middle">URL (use <b>a</b>-<b>z</b> and <b>_</b>):</td>
        <
    td align="left" valign="bottom">
          <
    input name="txtMediaUrl" type="text" id="txtMediaUrl" value="this-will-be-medias-url" size="40" maxlength="128" />
        </
    td>
      </
    tr>
      <
    tr>
        <
    td align="right" valign="middle">Description:</td>
        <
    td align="left" valign="bottom">
          <
    textarea name="txtMediaDescription" cols="58" rows="11" id="txtMediaDescription">Replace this description.</textarea>
        </
    td>
      </
    tr>
      <
    tr>
        <
    td colspan="2" align="center" valign="top">
          <
    table width="100%" border="0" cellspacing="2" cellpadding="1">
            <
    tr>
              <
    td colspan="2" align="center" valign="top" bgcolor="#FF6633">UPLOAD</td>
            </
    tr>
            <
    tr>
              <
    td width="200" align="right" valign="top" nowrap="nowrap" bgcolor="#FFCC66">Upload this file (max 10 MB):</td>
              <
    td align="left" valign="top" nowrap="nowrap" bgcolor="#FFCC66">
                <!-- 
    MAX_FILE_SIZE must precede the file input field -->
                <
    input type="hidden" name="MAX_FILE_SIZE" value="10485760" />
                <!-- 
    Name of input element determines name in $_FILES array -->
                <
    input name="userfile" type="file" />
              </
    td>
            </
    tr>
          </
    table>
        </
    td>
        </
    tr>
      <
    tr>
        <
    td colspan="2" align="center" valign="top" bgcolor="#CCCCFF">OR</td>
      </
    tr>
      <
    tr>
        <
    td colspan="2" align="center" valign="top">
          <
    table width="100%" border="0" cellspacing="2" cellpadding="1">
            <
    tr>
              <
    td colspan="2" align="center" valign="top" bgcolor="#FF6633">EMBEDDING CODE </td>
            </
    tr>
            <
    tr>
              <
    td width="200" align="right" valign="top" nowrap="nowrap" bgcolor="#FFCC66">Embedding code:</td>
              <
    td align="left" valign="top" nowrap="nowrap" bgcolor="#FFCC66">
                <
    textarea name="textEmbeddingCode" cols="48" rows="10" id="textEmbeddingCode"></textarea>
              </
    td>
            </
    tr>
          </
    table>
        </
    td>
      </
    tr>
      <
    tr>
        <
    td align="right" valign="middle">Thumbnail (105x105px): </td>
        <
    td align="left" valign="bottom"><!-- MAX_FILE_SIZE must precede the file input field -->
        <
    input name="thumbfile" type="file" /></td>
      </
    tr>
      <
    tr>
        <
    td align="right" valign="middle">Tags (separated by ","):</td>
        <
    td align="left" valign="bottom">
          <
    input name="txtMediaTags" type="text" id="txtMediaTags" value="replace,these,tags" size="78" maxlength="128" />
        </
    td>
      </
    tr>
      <
    tr>
        <
    td align="right" valign="bottom">&nbsp;</td>
        <
    td align="left" valign="bottom">&nbsp;</td>
      </
    tr>
        <
    td align="right" valign="bottom">&nbsp;</td>
        <
    td align="left" valign="bottom"><input type="submit" value="Add media" /></td>
      </
    tr>
    </
    table>
    </
    form
    m_doaddmedia.php
    PHP Code:
    <p>ADD MEDIA</p>
    <?
    $uploaddir 
    '../m_'.$_POST["radMediaType"].'s/';
    $uploadfile $uploaddir basename($_FILES['userfile']['name']);

    if (
    $_POST["textEmbeddingCode"]=="") {
        if (
    move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
                echo 
    "..Media file was successfully uploaded.<br>";
                
    chmod($uploadfile0755);
        } else {
             echo 
    "Possible file upload attack!\n";
             break;
        }
    }

    $uploaddir '../m_'.$_POST["radMediaType"].'s/thumbs/';
    $uploadfile $uploaddir basename($_FILES['thumbfile']['name']);

    if (
    move_uploaded_file($_FILES['thumbfile']['tmp_name'], $uploadfile)) {
            echo 
    "..Thumbnail file was successfully uploaded.<br>";
            
    chmod($uploadfile0755);    
            
    $thumbFilename=basename($_FILES['thumbfile']['name']);    
        } else {
                if (
    $_POST['radMediaType']=="picture") {
                    
    $thumbFilename=basename($_FILES['userfile']['name']);
                    
    $file='../m_'.$_POST["radMediaType"].'s/'.$thumbFilename;
                    
    $newfile='../m_'.$_POST["radMediaType"].'s/thumbs/'.$thumbFilename;
                    if (!
    copy($file$newfile)) {
                         echo 
    "failed to copy $thumbFilename...\n";
                    }
                        else echo 
    "Using media file as thumbnail.<br>";
                 } else {
                    echo 
    "Using default media thumbnail.<br>";
                    
    $thumbFilename=$_POST["radMediaType"]."-default-thumb.gif";
                 }
        }        
            
    $conn=mysql_connect($dbhost$dbuser$dbpass);
    mysql_select_db($dbname) or die ("Unable to connect to MySQL");
    // print "Connected to MySQL"; 

    $qquery="INSERT INTO t_media (
            m_type,
            m_title,
            m_url,
            m_description,
            m_file,
            m_embedcode,
            m_thumbnail,
            m_userid,
            m_submdate,
            m_rating,
            m_nrratings,
            m_nrcomments,
            m_nrviews,
            m_submapproved,
            m_tags
    ) VALUES (
            '"
    .$_POST['radMediaType']."',
            '"
    .$_POST['txtMediaTitle']."',
            '"
    .parseUrl($_POST['txtMediaUrl'])."',
            '"
    .$_POST['txtMediaDescription']."',
            '"
    .basename($_FILES['userfile']['name'])."',
            '"
    .$_POST['textEmbeddingCode']."',
            '"
    .$thumbFilename."',
            1,
            NOW(),
            0,
            0,
            0,
            1,
            'Y',
            '"
    .$_POST['txtMediaTags']."')";

    //echo $qquery."<br>";
    $qresult mysql_query($qquery);
    echo (
    "..Item inserted into the database.<BR>");

    $query "SELECT LAST_INSERT_ID()";
    $result mysql_query($query);
    if (
    $result) {
        
    $nrows mysql_num_rows($result);
        
    $row mysql_fetch_row($result);
        
    $lastID $row[0];
        
        
    ?><p><a href="/<?=$_POST['radMediaType']?>s/<?=strtolower(str_replace(" ","-",$_POST['txtMediaUrl']))?>" target="_blank">Click here to go to the item webpage now</a> (new window)<br />
    or <a href="index.php?action=addmedia">add another media file.</a></p><? //index.php?mediatype=picture&mediaid=1

        
    mysql_close($conn);
        
        include(
    "rss_allmedia.php");
        
    } else {
       echo 
    "Possible file upload attack!\n";
         break;
    }
    ?>
    I can provide more details if needed. I Hope someone could guide me in the right direction to fix this problem.
    Thanks

  2. #2
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,706
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not sure why you posted this in the mysql area. Where is your database question in this?

  3. #3
    SitePoint Member
    Join Date
    Aug 2012
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can a mod/admin move this thread to the correct section? thanks

  4. #4
    SitePoint Member
    Join Date
    Aug 2012
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mod please close this thread thanks.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •