SunQuest
 
           MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old October 24th, 2003, 02:05 AM
Red93CobraR Red93CobraR is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 2 Red93CobraR User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation PHP/JavaScript WYSIWYG/MySQL Problem......

Okay, I have a problem. I am using a JavaScript based WYSIWYG Editor for a CMS. The Javascript is dynamically creating the HTML which is then being passed to a PHP sql_query and into the DB.

Unfortunately, the quotes generated in the HTML (ie: <a href="test.html">TEST</a>) are ending the SQL query so I only get the following code in the table:

<a href=

Here is the code I'm using currently, with the "addslashes" function which isn't working:

PHP Code:
<?php
  
mysql_connect 
(localhostcarlberg_adminadmin);
      
mysql_select_db (carlberg_cms);  

if (isset(
$_POST['submit'])) {
    
mysql_query ('INSERT INTO test (Content) VALUES ("'.addslashes($_POST['text1']).'")');
    }
   
    include (
'includes/admin_header.htm');
 
    
?> 

<table width="500">
    <tr>
        <td height="100">
    </tr>
    <tr>
        <td>

<form action="<?php $_SERVER['PHP_SELF'?>" method="POST" name="RichTexteditor" id="RichTexteditor" onSubmit="submitForm(); return true;">
<iframe id="testFrame" style="position: absolute; visibility: hidden; width: 0px; height: 0px;"></iframe>
<script language="JavaScript" type="text/javascript" src="browserdetect.js"></script>
<script language="JavaScript" type="text/javascript" src="richtext.js"></script>
<script language="JavaScript" type="text/javascript">
<!--
function submitForm() {
     try {
          text1.innerHTML = '<input type="hidden" name="text1" value="' + document.getElementById('edit').contentWindow.docu  ment.body.innerHTML + '">';
     }
     catch (e) {
          text1.innerHTML = '<input type="hidden" name="text1" value="' + document.getElementById('edit').value + '">';
     }
return true;
}

Start();
//-->
</script>
<noscript><p><b>Javascript must be enabled to use this form.</b></p></noscript>

<p>Click submit to show the value of the text box.</p>
<p><input type="submit" name="submit" value="Submit"></p>
<span id="text1">&nbsp;</span>
</form>
        </td>
    </tr>
</table>
<?php

include("includes/admin_footer.htm");

?>


Any help would be GREATLY appreciated!

--Adam

Reply With Quote
  #2  
Old October 24th, 2003, 10:06 AM
sunphp sunphp is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Florida
Posts: 3 sunphp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Adam,

I'd handle it like this...

$text1 = $_POST['text1'];

mysql_query ("INSERT INTO test (Content) VALUES ('$text1')");

sunphp

Reply With Quote
  #3  
Old October 24th, 2003, 10:10 AM
Red93CobraR Red93CobraR is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 2 Red93CobraR User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Well it turns out that the code itself was the problem, so I had to re-script things and got it to work with this:

PHP Code:
<?php
      
    mysql_connect 
(localhostcarlberg_adminadmin);
          
    
mysql_select_db (carlberg_cms);  

    if (isset(
$_POST['submit'])) {
         
mysql_query ("INSERT INTO about (Title, FullBody) VALUES ('".$_POST['title']."', '".$_POST['msgbody']."')");
        
//echo ($_POST['msgbody']);
  
  
}

       
        include (
'tmp/PageHeader.html');
     
        
?> 

<form name="RichTextEditor" action="<?php $_SERVER['PHP_SELF'?>" method="post" onsubmit="return submitForm();">
<!-- PHP code: -->
<table width="500" cellpadding="3" border="0" cellspacing="0">
    <tr>
        <td colspan="2" height="75">&nbsp;</td>
    </tr>
    <tr>
        <td width="50">Title:</td>
        <td><input type="text" name="title" size="30" class="formfield"></td>
    </tr>
</table>
<BR><BR><BR>
<?
//the following line demonstrates removing carriage returns in preloaded content
//$sContent = str_replace(chr(13), "", "here's the ". chr(13) ."preloaded <b>content</b>");
?>
<?php 
include ('includes/rte.php'); LoadRTE("msgbody"$sContent""""true); ?>
<!-- END PHP -->
<script language="JavaScript" type="text/javascript">
<!--
function submitForm() {
    //call updateMessage to 
    updateRTE();
    
    //change the following line to true to submit form
    return true;
}
//-->
</script>
<noscript><p><b>Javascript must be enabled to use this form.</b></p></noscript>
<p><input type="submit" name="submit" value="Submit" class="formbutton"></p>
</form>
</body>
</html>
<?php
include('tmp/PageFooter.html'); ?>


--Adam

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > PHP/JavaScript WYSIWYG/MySQL Problem......


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway