Issue with MySQL [duplicate] - php

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to prevent SQL injection?
With my script when I copy a topic from Gmail and past it on my script to add it as a topic suddenly I face this problem.
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'no matter where the" at line 2
This problem happens just when I copy from Gmail although I past it on notepad then I copy it to my script
This is my code to add a topic:
<?php
#session_start();
if (!$_SESSION['username']){
echo "<meta http-equiv='refresh' content='0; url=../login.php'/>";
exit();
}
?>
<?php include "../config.php";?>
<html>
<head>
<meta charset="utf-8"/>
<link rel="stylesheet" type="text/css" href="admin.css" media="screen"/>
</head>
<body>
<!-- TinyMCE -->
<script type="text/javascript" src="../editor/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
// General options
mode : "textareas",
theme : "advanced",
plugins : "autolink,lists,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,wordcount,advlist,autosave",
// Theme options
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
theme_advanced_buttons2 : "bullist,numlist,|,link,unlink,anchor,cleanup,insertdate,inserttime,preview,|,forecolor,backcolor,hr,|,fullscreen,,ltr,rtl",
theme_advanced_buttons3 : "media,removeformat,cleanup",
theme_advanced_buttons4 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "right",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
// Example content CSS (should be your site CSS)
content_css : "css/content.css",
// Drop lists for link/image/media/template dialogs
template_external_list_url : "lists/template_list.js",
external_link_list_url : "lists/link_list.js",
external_image_list_url : "lists/image_list.js",
media_external_list_url : "lists/media_list.js",
// Style formats
style_formats : [
{title : 'Bold text', inline : 'b'},
{title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},
{title : 'Red header', block : 'h1', styles : {color : '#ff0000'}},
{title : 'Example 1', inline : 'span', classes : 'example1'},
{title : 'Example 2', inline : 'span', classes : 'example2'},
{title : 'Table styles'},
{title : 'Table row 1', selector : 'tr', classes : 'tablerow1'}
],
// Replace values for the template plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
}
});
</script>
<!-- /TinyMCE -->
<?php
#=======================================insert news==========================================
if ($_POST['submit']){
$topic_title =$_POST['topic_title'];
$topic =$_POST['topic'];
$id_topic =$_POST['topic_sec'];
$image1 =$_POST['image1'];
$image2 =$_POST['image2'];
$today =gmdate("d,m,Y");
$date =$_POST['date'];
$status =$_POST['status'];
$insert=mysql_query("insert into topics values('','$topic_title','$image1','$image2',
'$id_topic','$topic','$today','','$status')")or die (mysql_error());
}
if ($insert){echo "<script>alert(\"topic has been added\");</script>
<meta http-equiv='refresh' content='0; url=topics.php'/>
";}
?>
<div id='right'>add a new topic</div>
<form action='' method='post' dir='rtl'>
<table width='100%' cellpadding='5' cellspacing='10' dir='rtl'>
<tr>
<td>topic title</td>
<td><input type='text' name='topic_title' id='topic_title'/></td>
</tr>
<tr>
<td>upper image</td>
<td><input type='text' name='image1' size='70%'/></td>
</tr>
<td>left image</td>
<td><input type='text' name='image2' size='70%'/></td>
</tr>
<tr>
<td>topic section</td>
<td>
<select name='topic_sec'>
<?php
$select=mysql_query("select * from sections")or die (mysql_error());
while ($row=mysql_fetch_object($select)){
echo "<option value='$row->id_sec'>$row->sec_name</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td>topic</td>
<td >
<textarea cols='100' rows='25' name='topic' ></textarea>
</td>
</tr>
<tr>
<td>state</td>
<td>
<select name='status'>
<option value='1'>active</option>
<option value='2'>unactive</option>
</select>
</td>
</tr>
<tr>
<td colspan='2' ><input type='submit' id='subbot' name='submit' value='add'/></td>
</tr>
</table>
<input type='hidden' name='date' value='<?=$today;?>'/>
</form>
<br/>
</body>
</html>

You could use mysql_real_escape_string() to sanitize your variables before inserting them into the database - that should take care of any issues with single quotes, etc.
Incidentally, you should be doing some sanitizing of your POST variables (at the very least mysql_real_escape_string()) before inserting them into your database to avoid SQL Injection attacks.

Related

linking url in an article from php dashboard does not work

I have a dashboard designed in php for the client from where he is able to add new stories/articles on the main site using the tiny mce editor, just similar to a joomla article. The problem is that when a url is linked then it appends to the main site for some reason. e.g
http://example.com/"http://careers.virginmedia.com//"
I have tried every format for the url, but doesn't work. Please can someone help me with this.
The following code adds the content
function addSponsoredAd()
{
if(isset($_POST['submit']))
{
$db = new Connection(DB_HOST, DB_USER, DB_PASS, DB_NAME);
$userID = $_SESSION['user']['userID'];
$ID = getNextID('sponsoredAds');
$imgTmp = $_FILES['image']['tmp_name'];
$image = basename(strtolower(str_replace(' ', '-', $_FILES['image']['name'])));
$info = pathinfo($_FILES['image']['name']);
$filename = $image;
$imageFolder = '../mediaLibrary/sponsoredAds/';
$imageDestination = $imageFolder.$filename;
move_uploaded_file($imgTmp, $imageDestination);
$title = $_POST['title'];
$description = $_POST['description'];
$position = $_POST['position'];
$status = $_POST['status'];
$content = $_POST['content'];
$parameters = array(
'table' => 'sponsoredAds',
'fieldsAndValues' => array(
'userID' => $userID,
'title' => $title,
'description' => $description,
'status' => $status,
'position' => $position,
'content'=> $content,
'dateAdded' => datetime()
)
);
$db->insert($parameters);
if($imgTmp != '')
{
$parameters = array(
'table' => 'sponsoredAds',
'fieldsAndValues' => array(
'logo' => $imageDestination
),
'conditions' => 'WHERE ID = "'.$ID.'"'
);
$db->update($parameters);
}
setMessage('Added a new sponsored ad: '.$title, 1);
header('Location: '.BASE_URL.'dashboard/sponsoredAds');
}
}
The code below displays it
function getSponsoredListings()
{
$db = new Connection(DB_HOST, DB_USER, DB_PASS, DB_NAME);
$result = $db->query('
SELECT *
FROM sponsoredAds
ORDER BY position
');
$items='';
while($row = mysql_fetch_assoc($result))
{
$items .= '
<div id="search-results">
<div class="search-result '.$class.'" id="searchResult'.$row['ID'].'">
<a href="sponsored-posts/'.$row['ID'].'">
<div class="img-container">
<img src="'.BASE_URL.str_replace('../', '', $row['logo']).'" alt="'.$row['title'].'" />
</div><!-- End img container -->
<h3>'.$row['title'].'</h3>
<p>'.$row['content'].'</p>
<div class="cont">'.$row['description']
.'</div><!-- End cont -->
</a>
</div><!-- End search result -->
</div><!-- End search results -->
';
$count++;
}
return $items;
}
The tinymce page code:
<head>
<title>Dashboard</title>
<link rel="stylesheet" href="<?php echo BASE_URL; ?>_style/main.css" />
<link rel="stylesheet" href="<?php echo BASE_URL; ?>_style/dashboard.css" />
<link href="<?php echo BASE_URL; ?>favicon.ico" type="image/x-icon" rel="shortcut icon" />
<!--<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>-->
<script src="//code.jquery.com/jquery-latest.min.js"></script>
<script src="<?php echo BASE_URL; ?>_scripts/functions.js"></script>
<script src="<?php echo BASE_URL; ?>dashboard/_scripts/functions.js"></script>
<script src="<?php echo BASE_URL; ?>_scripts/notify.1.0.js"></script>
<script src="<?php echo BASE_URL; ?>_scripts/tinymce/jscripts/tiny_mce/jquery.tinymce.js"></script>
<script src="<?php echo BASE_URL; ?>_scripts/jquery.validate.min.js"></script>
<script src="//tinymce.cachefly.net/4.0/tinymce.min.js"></script>
<script src="<?php echo BASE_URL; ?>_scripts/jquery.cookie.js"></script>
<script src="http://cdn.jquerytools.org/1.2.7/all/jquery.tools.min.js"></script>
<script type="text/javascript">
tinymce.init({
selector:'textarea',
plugins: [
"advlist autolink lists link image charmap print preview anchor",
"searchreplace visualblocks code fullscreen",
"insertdatetime media table contextmenu paste"
],
toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
});
var BASE_URL = '<?php echo BASE_URL; ?>';
$(document).ready(function() {
$('textarea.tinymce').tinymce({
// Location of TinyMCE script
script_url : '<?php echo BASE_URL; ?>_scripts/tinymce/jscripts/tiny_mce/tiny_mce.js',
mode : 'textareas',
plugins : 'jbimages,paste,fullscreen,media,table',
paste_auto_cleanup_on_paste : true,
theme : 'advanced',
theme_advanced_buttons1 : 'bold,italic,underline,|,bullist,numlist,|,link,unlink,image,jbimages,|,formatselect,removeformat,code, fullscreen, media,|,tablecontrols',
theme_advanced_buttons3_add : "tablecontrols",
table_styles : "Header 1=header1;Header 2=header2;Header 3=header3",
table_cell_styles : "Header 1=header1;Header 2=header2;Header 3=header3;Table Cell=tableCel1",
table_row_styles : "Header 1=header1;Header 2=header2;Header 3=header3;Table Row=tableRow1",
table_cell_limit : 100,
table_row_limit : 5,
table_col_limit : 5,
theme_advanced_buttons2 : '',
theme_advanced_buttons3 : '',
theme_advanced_buttons4 : '',
theme_advanced_toolbar_location : 'top',
theme_advanced_toolbar_align : 'left',
theme_advanced_resizing : true,
theme_advanced_blockformats : 'Paragraph=p,Heading=h4,Leading=h3',
relative_urls : false,
valid_elements : '*[*]',
valid_styles : {'span' : 'text-decoration', 'img' : 'vertical-align,border,margin-top,margin-bottom,margin-left,margin-right,float'},
width: '100%',
height: '400',
extended_valid_elements: "embed[width|height|name|flashvars|src|bgcolor|align|play|loop|quality|allowscriptaccess|type|pluginspage]",
media_strict: false
});
$('#name').keyup(function(){
$('#permalink').val($('#name').val().replace(/[^a-zA-Z 0-9-]+/g, '').toLowerCase().replace(/\s/g, '-').replace('--', '-'));
});
});
</script>
<h1>Add a New Sponsored Ad</h1>
<form action="<?php addSponsoredAd(); ?>" method="post" enctype="multipart/form-data">
<label for="image">Logo</label>
<input type="file" name="image" id="image" />
<label for="title">Title</label>
<input type="text" name="title" id="title" />
<label for="description">Description</label>
<textarea name="description" id="description"><?php echo $info['description']; ?></textarea>
<label for="content">Content</label>
<textarea class="tinymce" name="content" id="content"><?php echo $info['content']; ?></textarea>
<!-- <label for="position">Position</label>
<input type="text" name="position" id="position" /> -->
<label for="status"><input type="checkbox" name="status" id="status" value="1" /> Active?</label>
<input type="submit" name="submit" id="submit" value="Add Sponsored Ad" />
</form>
You are using TinyMCE with the relative_urls = false option. From looking at the TinyMCE docs on URL conversion I think you should instead drop that option and add convert_urls: false.

Create a search box that returns JSON results on same page

I have a JSON file that I have parsed using PHP. I take the JSON data and output it into a table. Below is a screenshot of what the output looks like:
What I'm trying to accomplish is for a user to enter the room number, press "SEARCH" and then have the data in the table auto scroll to whatever room number the user entered.
Here is what the JSON data looks like:
"apiVersion" : "0.1",
"data" : {
"roomCount" : 105,
"rooms" : [
{
"room_number" : "104",
"services" : [
{
"adult" : {
"enabled" : false
},
"room_charges" : {
"enabled" : true
}
}
],
"status" : "UNOCCUPIED"
},
{
"room_number" : "105",
"services" : [
{
"adult" : {
"enabled" : true
},
"room_charges" : {
"enabled" : false
}
}
],
"status" : "OCCUPIED"
And here is my code, that parses the JSON file, and outputs it into a table.
<?php
$response = file_get_contents("response.json");
$data = json_decode($response, true);
?>
<head>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<div>
<form id="response_form" action="#" method="POST" name="mainform"><br>
<label for="text"> Enter Room Number</label><br>
<input type="text" name="response_search" id="text" rows="1" cols="47"> </textarea><br>
<input type="submit" value="Search">
</form>
</div>
<div id="response_data">
<table>
<thead>
<tr>
<th width="188px">Room Number: </th>
<th width="193px">Adult:</th>
<th width="193px">Room Charges: </th>
<th width="212px">Status: </th>
</tr>
</thead>
<tbody>
<?php foreach($data['data']['rooms'] as $info): ?>
<tr id="scroll_through">
<td><?php echo $info['room_number']; ?></td>
<?php $services = reset($info['services']); ?>
<td><?php echo ($services['adult']['enabled'] == 1) ? 'ENABLED' : 'DISABLED'; ?></td>
<td><?php echo ($services['room_charges']['enabled'] == 1) ? 'ENABLED' : 'DISABLED'; ?></td>
<td><?php echo $info['status']; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
You'll notice in my code above that I have a form where I'd like to make this happen. The steps that I have taken are as follows:
I have tried changing the action of the form, to <action='<?=$_SERVER['PHP_SELF']?> and then writing an if statement that attempts to match the text from the form to $info['room_number'];but that didn't work at all... To be honest, I'm not even sure if I am doing it correctly. Any help would be appreciated.
You don't need to send the form to the server.
Just make the id of each room row in the table unique (for example #room_104, #room_105) and handle the form submit with javascript (jQuery in the example):
$('#response_form').submit(function() {
window.location.hash = 'room_'+$('#text').val();
return false;
});
You might do something like this:
In your output add a class per row E.G
class="room<?= $info['room_number']; ?>
then use jquery like this:
//button clicked
$("#searchBtn").click(function(event){
roomNo = "room" + event.target.id;
$('html, body').animate({
scrollTop: $('#' + roomNo).offset().top - 200
}, 800, function(){
//This will flash the row
$('#' + roomNo).fadeTo('slow', 0.5).fadeTo('slow', 1.0).fadeTo('slow', 0.5).fadeTo('slow', 1.0);
});
});
I have not tested this but use something similar on a site

Error occurred upon executing query [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I was trying to update my website content by a pop up window. I made the content appear according to the ID but when I try to submit it an error appears on the pop up
An error occurred upon executing query.
Please notify the web developer about this error.
NOTE: You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near 'WHERE textID=16' at line 1
and I can't seem to find the bug. Can you see it?
Here's my complete code:
<!-- PHP -->
<?
include('global.php');
if(isset($_REQUEST['textID']))
$textID = $_REQUEST['textID'];
if(isset($_REQUEST['textContent']))
$textContent = $_REQUEST['textContent'];
if($_POST){
$query = "UPDATE text_tb SET ";
$query = $query."textContent='".$textContent."', ";
$query = $query."WHERE textID=".$textID."";
//echo $query;
ExecuteQuery($query);
echo "<script type=\"text/javascript\">
<!--
window.close();
//-->
</script>";
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Full featured example</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- TinyMCE -->
<script type="text/javascript" src="../jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
// General options
mode : "textareas",
theme : "advanced",
plugins : "autolink,lists,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,wordcount,advlist,autosave,visualblocks",
// Theme options
theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,fontselect,fontsizeselect",
theme_advanced_buttons2 : "bullist,numlist,|,undo,redo,|,link,unlink,|,forecolor",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : false,
// Example content CSS (should be your site CSS)
content_css : "css/content.css",
// Drop lists for link/image/media/template dialogs
template_external_list_url : "lists/template_list.js",
external_link_list_url : "lists/link_list.js",
external_image_list_url : "lists/image_list.js",
media_external_list_url : "lists/media_list.js",
// Style formats
style_formats : [
{title : 'Bold text', inline : 'b'},
{title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},
{title : 'Red header', block : 'h1', styles : {color : '#ff0000'}},
{title : 'Example 1', inline : 'span', classes : 'example1'},
{title : 'Example 2', inline : 'span', classes : 'example2'},
{title : 'Table styles'},
{title : 'Table row 1', selector : 'tr', classes : 'tablerow1'}
],
});
</script>
<!-- /TinyMCE -->
</head>
<body role="application">
<form method="post" action="<?php $_PHP_SELF ?>">
<div>
<!-- Gets replaced with TinyMCE, remember HTML in a textarea should be encoded -->
<div>
<textarea id="textContent" name="textContent" rows="15" cols="80" style="width: 80%">
<?
$result = mysql_query("SELECT * FROM text_tb WHERE textID ='".$textID."'");
while($row = mysql_fetch_array($result)){
echo $row['textContent'];
}
?>
</textarea>
</div>
<!-- Some integration calls
[Show]
[Hide]-->
<br />
<input type="submit" name="save" value="Submit" />
<input type="reset" name="reset" value="Reset" />
</div>
</form>
<!--<script type="text/javascript">
if (document.location.protocol == 'file:') {
alert("The examples might not work properly on the local file system due to security settings in your browser. Please use a real webserver.");
}
</script>-->
</body>
</html>
The problem is the comma at the end of the set. Change this line:
$query = $query."textContent='".$textContent."', ";
to:
$query = $query."textContent='".$textContent."' ";

Resize Tiny MCE

I'm creating a custom content management system with a rich text editor. I'm using tiny MCE but I'm failing to fit the text area in my content div. I have a <div></div> that is 680px. I want Tiny MCE to fit into the <div></div> properly. However it keeps on overflowing. How can I set the textarea to fit on a width of 680px? Thaks. A sample of my code is down below
<?php
require 'janta_class.php';
$jantaObj = new janta_class();
if (!isset($_GET['pgid']) || empty($_GET['pgid'])) {
$page_id = 1;
} else {
$page_id = $_GET['pgid'];
}
if (isset($page_id) && !empty($page_id)) {
$allowedTags = '<p><strong><em><u><h1><h2><h3><h4><h5><h6><img>';
$allowedTags.='<li><ol><ul><span><div><br><ins><del>';
//you might want to escape some literals here
$page_data = $jantaObj->get_page($page_id);
$page_content = $page_data['page_content'];
$page_title = $page_data['page_title'];
$page_content = strip_tags(stripslashes($page_content), $allowedTags);
}
?>
<!-- TinyMCE -->
<script type="text/javascript" src="./editor/jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
theme : "advanced",
mode: "exact",
elements : "rteditor",
plugins : "autolink,lists,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,wordcount,advlist,autosave,visualblocks",
// 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,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,restoredraft,visualblocks",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
// Example content CSS (should be your site CSS)
content_css : "css/content.css",
// Drop lists for link/image/media/template dialogs
template_external_list_url : "lists/template_list.js",
external_link_list_url : "lists/link_list.js",
external_image_list_url : "lists/image_list.js",
media_external_list_url : "lists/media_list.js",
// Style formats
style_formats : [
{title : 'Bold text', inline : 'b'},
{title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},
{title : 'Red header', block : 'h1', styles : {color : '#ff0000'}},
{title : 'Example 1', inline : 'span', classes : 'example1'},
{title : 'Example 2', inline : 'span', classes : 'example2'},
{title : 'Table styles'},
{title : 'Table row 1', selector : 'tr', classes : 'tablerow1'}
],
// Replace values for the template plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
},
height:"350px",
width:"600px"
});
</script>
<?php //echo $sHeader; ?>
<form method="post" action="">
<textarea id="rteditor" name="rteditor" rows="15" cols="80"><?php echo $page_content; ?></textarea>
<br />
<input type="submit" name="save" value="Submit" />
<input type="reset" name="reset" value="Reset" />
</form>
Do not use width with double quotes nor single quotes.
I have got the solution.
Put it like:
width: 300,
and it should work for you. I have tested it with my code.
Solution is to set the width in the tinymce initfunction. Be aware that you place integers there and don't use 'px':
width:"680"

How to use TinyMCE textarea editor as a class?

I have some TinyMCE textarea editor for my PHP programs like this one:
<!-- TinyMCE -->
<script type="text/javascript" src="../jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
// General options
mode : "textareas",
theme : "advanced",
skin : "o2k7",
plugins : >"autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,i>nsertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscree>n,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups,autosave",
// Theme options
theme_advanced_buttons1 : >"save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justif>yright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
theme_advanced_buttons2 : >"cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,bl>ockquote,|,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,advh>r,|,print,|,ltr,rtl,|,fullscreen",
theme_advanced_buttons4 : >"insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,at>tribs,|,visualchars,nonbreaking,template,pagebreak,restoredraft",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
// Example word content CSS (should be your site CSS) this one removes >paragraph margins
content_css : "css/word.css",
// Drop lists for link/image/media/template dialogs
template_external_list_url : "lists/template_list.js",
external_link_list_url : "lists/link_list.js",
external_image_list_url : "lists/image_list.js",
media_external_list_url : "lists/media_list.js",
// Replace values for the template plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
}
});
</script>
<!-- /TinyMCE -->
Now I'd like to use all code above as a class, something like this:
<textarea id="test" name="test" class="tinymce"></textarea>
How and where should I create class="tinymce"?
I would like to use this class in many textareas at different php/html programs.
Here's an example of applying TinyMCE to specific classes:
<script type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "simple",
editor_selector : "mceEditor",
editor_deselector : "mceNoEditor"
});
</script>
<form method="post" action="somepage">
<textarea id="content1" name="content1" class="mceEditor" cols="85" rows="10">This will be a editor, since it has a selector class.</textarea>
<textarea id="content2" name="content2" class="mceEditor" cols="85" rows="10">This will be a editor, since it has a selector class.</textarea>
<textarea id="content3" name="content3" class="mceNoEditor" cols="85" rows="10">This is not a editor since it has a deselector class.</textarea>
</form>
Full example: http://www.tinymce.com/tryit/selector_deselector.php
here you can find complete reference for TinyMce.
http://tinymce.moxiecode.com/js/tinymce/docs/api/index.html#class_tinymce.html
Good luck.

Categories