I can not add news with my news scrip

Discussion in 'PHP' started by alllyc, Apr 13, 2010.

  1. #1
    Hello everybody,

    I have simple news script and I have some sort of weird problems ever. When I type the news on the text area, the script works and add the news. But if I copy the news from another web source, even from a simple text file, it doesn't add the news, even though it says it added the news successfully. I changed my text editor, and same problem continued. What could be wrong with my codes. Below is my my index panel code and add_news.php codes. Thanks a lot for your help...


    <?php 
    ob_start();
    session_start();
    if ($_SESSION['admin']=="evet")
    {
    include("../ayar.php");}
    else
    {
    header("Location: giris.php");
    exit; 
    }
    
    
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Panel</title>
    <!-- CSS -->
    <link href="style/css/transdmin.css" rel="stylesheet" type="text/css" media="screen" />
    
    
    <!--[if IE 6]><link rel="stylesheet" type="text/css" media="screen" href="style/css/ie6.css" />
    <![endif]-->
    <!--[if IE 7]><link rel="stylesheet" type="text/css" media="screen" href="style/css/ie7.css" />
    <![endif]-->
    
    <!-- JavaScripts-->
    
    <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 : "safari,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",
    
    		// 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",
    		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",
    
    		// Replace values for the template plugin
    		template_replace_values : {
    			username : "Some User",
    			staffid : "991234"
    		}
    	});
    </script>
    <script type="text/javascript" src="style/js/jquery.js"></script>
    <script type="text/javascript" src="style/js/jNice.js"></script>
    
    
    <style type="text/css">
    <!--
    .style1 {
    	font-size: 18px;
    	font-weight: bold;
    }
    -->
    </style>
    </head>
    
    <body>
    	<div id="wrapper">
        	<!-- h1 tag stays for the logo, you can use the a tag for linking the index page -->
        	<h1><a href="#"><span>Domain Sitesi</span></a></h1>
            
            <!-- You can name the links with lowercase, they will be transformed to uppercase by CSS, we prefered to name them with uppercase to have the same effect with disabled stylesheet -->
            <ul id="mainNav">
            <li>	<a href="#" >Yönetim&nbsp;Paneline&nbsp;Hoşgeldiniz</a> </p>
            
            	<li class="logout"><a href="cikis.php">Çıkış Yap</a></li>
    </ul>
            <!-- // #end mainNav -->
            
            <div id="containerHolder">
    			<div id="container">
            		<div id="sidebar">
                    	<ul class="sideNav">
                        	<li><a href="index.php" class="active">Anasayfa</a></li>
                        	<li></li>
                       	  <li><a href="tumhaberler.php">Tüm haberler</a></li>
                          <li><a href="#">YORUM SİL</a></li>
                        <li><a href="#"><form action="yorumsil.php" method="post"><input type="text" name="yorumid" /></a></li>
                        <li><a href="#"><input type="submit" value="sil" /></a></li></form>
                        </ul>
                        <!-- // .sideNav -->
                    </div>    
                    <!-- // #sidebar -->
                    
                    <!-- h2 stays for breadcrumbs -->
                    <div id="main">
                    	<form action="haberekleok.php" class="jNice" method="post">
    					<h3>Son eklenen 5 haber</h3>
                        	<table cellpadding="0" cellspacing="0">
    				
                                </tr> 
                          <?php
    				
                                 $sqllist="select * from demirtepe order by id desc limit 5";
         mysql_query("SET NAMES 'UTF8'");
    	 $execute=mysql_query($sqllist);
    	 while ($list =@ mysql_fetch_array($execute))
    	 {
    	 
    	 echo "					<tr>
                                    <td><strong>$list[baslik]</strong> </td>
                                    <td class='action'><a href='haberduzelt.php?id=$list[id]' class='view'>Düzelt</a><a href='habersil.php?id=$list[id]' class='delete'>Sil</a></td>
                                </tr>    ";}
                                ?>
                                
                                                       
                            </table>
    					<h3>Haber Ekle</h3>
                        	<fieldset>
                           	<p>
                            	  <label>Başlık ::</label>
                       	    <input type="text" name="baslik" class="text-long" />
                           	</p>
                            	<p>
                            	  <label>Resim adresi:</label>
                            	  <input type="text" name="resim" class="text-medium" />
                            	</p>
                                	<p>
                            	  <label>Ekleyen:</label>
                            	  <input type="text" name="ekleyen" class="text-long" />
                            	</p>
                       	  <p>
                       	    <label>Özel mi ?</label>
                            <select name="ozelmi">
                                	<option selected="selected" value="0">DeÄŸil</option>
                                    <option  value="1">Özel</option>
                        </select>
                          
                          <p>
                           <label>Kategori:</label>
                            <select name="kategorisi">
                                	<option selected="selected" value="demirtepe">Demirtepe</option>
                                    <option  value="gelibolu">Gelibolu</option>
                                    <option  value="tarim">Tarım</option>
                        </select>
                          </p>
                         
                                <p>
                       	    <label><strong>Özet :</strong></label>
    
    
                              <input name="ozet" type="text" id="ozet" value="<?php echo "$list[ozet]";?>" size="100%" maxlength="685"/>
                          </p>
                            	  <label>Haber :&nbsp; <input type="button" onclick="javascript:window.open('resimekle.php')" value="Resim Ekle" />
                                  
                                  
                                  </label>
    
                               
                                  <input type="submit" value="Haberi ekle" />
                  
                     
                
                    </div>
                    <!-- // #main -->
                    
                    <div class="clear"></div>
                
                <!-- // #container --><!-- // #containerHolder -->
              
    
     <textarea id="haber" style="width:100%; " name="haber">
    	
    	                          </textarea>        
                          
                              
                                  </form>
        </div>
        <!-- // #wrapper -->   
    </body>
    </html>
    
    Code (markup):
    <?php 
    ob_start();
    session_start();
    if ($_SESSION['admin']=="evet")
    {
    include("../ayar.php");}
    else
    {
    header("Location: giris.php");
    exit; 
    }
    
    
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <?php 
    $tarrih=date("d F Y");
    $tarih = array('January' => 'Ocak','February' => 'Şubat','March' => 'Mart','April' => 'Nisan','May' => 'Mayıs','June' => 'Haziran','July' => 'Temmuz','August' => 'Agustos','September' => 'Eylül', 'October' => 'Ekim','November' => 'Kasım','December' => 'Aralık',); 
    $bariss=strtr($tarrih, $tarih);  
    
         	     mysql_query("SET NAMES 'UTF8'");
    mysql_query("insert into demirtepe (id,baslik,haber,resim,ekleyen,durum,ozet,kategori,tarih) values ('','$_POST[baslik]','$_POST[haber]','$_POST[resim]','$_POST[ekleyen]','$_POST[ozelmi]','$_POST[ozet]','$_POST[kategorisi]','$bariss')");
    
    	 echo "<br />
    <a href='index.php'>news successfully added.</a>";
    
    ?>
    <body>
    </body>
    </html>
    Code (markup):
     
    alllyc, Apr 13, 2010 IP
  2. guardian999

    guardian999 Well-Known Member

    Messages:
    376
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #2
    
    $result = mysql_query("insert into demirtepe (id,baslik,haber,resim,ekleyen,durum,ozet,kategori,tarih) values ('','$_POST[baslik]','$_POST[haber]','$_POST[resim]','$_POST[ekleyen]','$_POST[ozelmi]','$_POST[ozet]','$_POST[kategorisi]','$bariss')");
    if($result){
    	 echo "<br />
    <a href='index.php'>news successfully added.</a>";
    }
    
    PHP:
    and check all $_POST with
    
    if(empty($_POST[key])){
         echo "Hey, it's empty. You need to fill up";
    }
    
    PHP:
     
    guardian999, Apr 13, 2010 IP
  3. alllyc

    alllyc Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for your reply. Where do I need to put the code you provided? I don't know any php.
     
    alllyc, Apr 13, 2010 IP