PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

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:
  #1  
Old November 2nd, 2002, 09:09 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
help with a news posting script

ok..here's the script i'm using..

php Code:
Original - php Code
  1. <?PHP
  2. /////////////////////////////////////////////////////////////
  3. // ... rNews made by RyZeR ...
  4. // ... xcelsius@hotmail.com for bugs and/or questions ...
  5. // ... PLZ LEAVE THE COPYRIGHT ALONE ...
  6. ///////////////////////////////////////////////////////////
  7. //##################################################  #######
  8. // #######
  9. // INCLUDE
  10. // #######
  11. require("config.php");
  12. include_once ("functions.php");
  13.  
  14.  
  15. // #####
  16. // LOGIN
  17. // #####
  18. if ($password != $passx){
  19.     include("login.php");
  20. }else{
  21.  
  22.  
  23.  
  24. // #############
  25. // CONNECT TO DB
  26. // #############
  27. $link = mysql_connect($db_hostname, $db_username, $db_password) or die("Could not connect");
  28. mysql_select_db($db_dbname) or die("Could not select database");
  29.  
  30.  
  31. // #######################################
  32. if ($id == "add"){
  33.     if ($action == "do"){
  34.             // Check Fields
  35.             if (!($ntext && $nsubject && $nemail && $nuser)){
  36.                 echo "Please go back and fill all fields...";
  37.             exit;
  38.             }
  39.            
  40.            
  41.             // Convert Vars
  42.             $ntext = ereg_replace("\'", "'", $ntext);
  43.           $ntext = ereg_replace('\"', '"', $ntext);
  44.             $ntext = nl2br($ntext);
  45.            
  46.             $ntext = strip_tags($ntext, '<br><font><img><object><marquee><hr><sub><tt><sup><s><b><i><u><li><ul><a><blockquote><span><hr><pre>');
  47.            
  48.             $ntext = InsertBBCode($ntext);
  49.                        
  50.             $ndatum = date("m/d/y");
  51.  
  52.            
  53.             // Query: Get last ID...
  54.             $query = "SELECT * FROM news ORDER BY id DESC";
  55.       $result = mysql_query($query);
  56.             $record = mysql_fetch_object($result);
  57.             $lid = "$record->id";
  58.            
  59.             // Query: Put in DataBase
  60.             $nid = $lid + 1;
  61.             $query = "INSERT INTO news (id, subject, user, email, text, datum) VALUES ('$nid', '$nsubject', '$nuser', '$nemail', '$ntext', '$ndatum');";
  62.         if (!(mysql_query($query))){
  63.             echo "<br>Error Adding: ".mysql_error();
  64.             }else{
  65.             ?>
  66.             <script language="JavaScript" type="text/JavaScript">
  67. function MM_goToURL() {
  68.   var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  69.   for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
  70. }
  71. </script>
  72. <body onLoad="MM_goToURL('parent','admin.php');return document.MM_returnValue">
  73. <?PHP
  74.             }
  75.            
  76.     }else{
  77. ?>


When I try to post news with the word "you're" or anything really with a ' in it, it gives me this error..

Error Adding: You have an error in your SQL syntax near 're', '11/02/02')' at line 1

Not sure how to fix this. Any help would be great.

Reply With Quote
  #2  
Old November 3rd, 2002, 02:21 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: help with a news posting script

After :

$ntext = InsertBBCode($ntext);

add:

$ntext = addslashes($ntext);


then wherever that data is pulled out of the database for display, you will need to run it through strip_slashes()


Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > help with a news posting script


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