SunQuest
           Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers 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, 06:05 AM
Red93CobraR Red93CobraR is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 1 Red93CobraR User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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:
Original - php Code
  1.  
  2.  
  3. <?php
  4.  
  5. mysql_connect (localhost, carlberg_admin, admin);
  6.      
  7. mysql_select_db (carlberg_cms)
  8.  
  9. if (isset($_POST['submit'])) {
  10.     mysql_query ('INSERT INTO test (Content) VALUES ("'.addslashes($_POST['text1']).'")');
  11.     }
  12.    
  13.     include ('includes/admin_header.htm');
  14.  
  15.     ?>
  16.  
  17. <table width="500">
  18.     <tr>
  19.         <td height="100">
  20.     </tr>
  21.     <tr>
  22.         <td>
  23.  
  24. <form action="<?php $_SERVER['PHP_SELF'] ?>" method="POST" name="RichTexteditor" id="RichTexteditor" onSubmit="submitForm(); return true;">
  25. <iframe id="testFrame" style="position: absolute; visibility: hidden; width: 0px; height: 0px;"></iframe>
  26. <script language="JavaScript" type="text/javascript" src="browserdetect.js"></script>
  27. <script language="JavaScript" type="text/javascript" src="richtext.js"></script>
  28. <script language="JavaScript" type="text/javascript">
  29. <!--
  30. function submitForm() {
  31.      try {
  32.           text1.innerHTML = '<input type="hidden" name="text1" value="' + document.getElementById('edit').contentWindow.docu  ment.body.innerHTML + '">';
  33.      }
  34.      catch (e) {
  35.           text1.innerHTML = '<input type="hidden" name="text1" value="' + document.getElementById('edit').value + '">';
  36.      }
  37. return true;
  38. }
  39.  
  40. Start();
  41. //-->
  42. </script>
  43. <noscript><p><b>Javascript must be enabled to use this form.</b></p></noscript>
  44.  
  45. <p>Click submit to show the value of the text box.</p>
  46. <p><input type="submit" name="submit" value="Submit"></p>
  47. <span id="text1">&nbsp;</span>
  48. </form>
  49.         </td>
  50.     </tr>
  51. </table>
  52. <?php
  53.  
  54. include("includes/admin_footer.htm");
  55.  
  56. ?>
  57.  


Any help would be GREATLY appreciated!

--Adam

Reply With Quote
  #2  
Old October 24th, 2003, 06:38 AM
CodeKadiya CodeKadiya is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Colombo,Sri Lanka
Posts: 2,313 CodeKadiya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
Send a message via Yahoo to CodeKadiya
RE: PHP/JavaScript WYSIWYG/MySQL Problem....

Use '' before your double quotations.
Code:
<a href="test.htm">Click here</a>


or just use single quotes.
Code:
<a href='test.htm'>Click here</a>

Reply With Quote
  #3  
Old October 24th, 2003, 05:36 PM
brut brut is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 367 brut User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: PHP/JavaScript WYSIWYG/MySQL Problem....

Here are a couple of built in functions:
mysql_escape_string()
addslashes()

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > 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 6 hosted by Hostway