i am trying to recall data from my a database which someone else has set up. the site is a contnet management system and it uses innovaStudio which is a wysiwyg to do all the editing for the text on the website. the editor side of it works where it will load the text into the text area and the changes can be made to. from here there is then a save function which submits the body text from the form.

the save function looks like this

function save()
	{
	document.forms.form1.elements.inpContent.value = oEdit1.getHTMLBody();
	document.forms.form1.submit()
	}

the code which i think is not working is the saving the data back to the database as when i try to recall the information on a different page i get no connection errors but i do not get anything displaying.

the code he has used for the saving of the data back to the database is

if(isset($_POST["inpContent"])) 
	{
	
	$sContent=stripslashes($_POST['inpContent']); // remove slashes (/)	
	$sContent=ereg_replace("'","''",$sContent); // fix SQL
		
	$sql="UPDATE cms_core SET editorial='$sContent' WHERE id=$id";
	$query = mysql_query($sql);
	}

he has put code in for loading the text into the editor which looks like this

if(!$_GET["id"]){ $id = 1; }
$sql = "SELECT * FROM cms_core WHERE id=$id";
$query = mysql_query($sql);
$result = mysql_fetch_array($query);
$sContent = $result['editorial'];

it uses some code to load temporarily hold the data before loading it into the editor and the code for this is

<pre id="idTemporary" name="idTemporary" style="display:none">
<?  echo htmlentities($sContent); ?>
</pre>

the code i have used to display the data is

<?php

	// get the data from the database
					if(!$_GET["id"]){ $id = 1; }
					$sql = "SELECT * FROM cms_core WHERE id=$id";
					$query = mysql_query($sql);
					$result = mysql_fetch_array($query);					

					?>

i have now got the first page accessing the database and trying to display the data but nothing was showing up. so i told the server to display a message if the database was empty and guess what it told me. that the database was empty.

so the problem now is saving the data to the database. it does not sound that hard to do but the fact that a wysiwyg editor is being used the code from that is throwing me off.

the code that is used to save the data to the database is this

// save content to db
         if(isset($_POST["inpContent"])) 
	{
	
	$sContent=stripslashes($_POST['inpContent']); // remove slashes (/)	
	$sContent=ereg_replace("'","''",$sContent); // fix SQL
		
	$sql="UPDATE cms_core SET editorial='$sContent' WHERE id=$id";
	$query = mysql_query($sql);
	}

the variables used in this code come from the wysiwyg editor and the code that uses looks like this

<form id="form1" name="form1" method="post" action="index.php?id=<?php echo $id; ?>">
	
			<!-- Embed RTE -->
			<script>
				var oEdit1 = new InnovaEditor("oEdit1");
		
				oEdit1.btnStyles = true;
				oEdit1.css = "../includes/styles.css";
		
				<!-- Set which buttons are active -->
				oEdit1.features = ["Undo","Redo","Save","XHTMLSource","|","Table","Hyperlink","Numbering","Bullets","|","StyleAndFormatting","Styles","ListFormatting","|","Bold","Italic","Underline"];
		
				oEdit1.btnSave= true; // Enable save button
				oEdit1.onSave = new Function("save()"); // Specify a function to call
		
				oEdit1.width = "500px"; // Set editor width
				oEdit1.height = "350px"; // Set editor height
		
				oEdit1.RENDER(document.getElementById("idTemporary").innerHTML);
			</script>
	
			<input type="hidden" name="inpContent" id="inpContent">
	
		</form>

this code loads the data into the editor and the save button should save the code but i dont think the save button is linked to the database the code for the save button looks like this

<script>
function save()
	{
	document.forms.form1.elements.inpContent.value = oEdit1.getHTMLBody();
	document.forms.form1.submit()
	}
</script>

if anyone could please help it would be very helpful once this site has been fixed i can then start building my own and will not have to work through someone else's work any more.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.