• 如何将符号保存到php数据库当中并且打印出来!


    需要保存到数据库就要用到addslashes这个函数!同时还是要建一张数据库表在这里也没有写太多,看看吧!

    通过FROM表单提交,

    具体代码如下所示:

    1:

     1     <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
     2 </head>
     3 <body>
     4 <form action="getValue.php" method="post">
     5     标题: <input type="text" name="title"/> <br/>
     6     <?php
     7     include("fckeditor/fckeditor.php") ;
     8      $oBasePath = $_SERVER['PHP_SELF'];
     9     $oBasePath = dirname($oBasePath)."/fckeditor/";
    10     $oFCKeditor = new FCKeditor('FCKeditor1') ;
    11     $oFCKeditor->BasePath    = $oBasePath;
    12     $oFCKeditor->Height = "500px";
    13 //    $oFCKeditor->ToolbarSet = "Basic";
    14     $oFCKeditor->Create() ;
    15     ?>
    16     <input type="submit"  name="submit" value="提交"/>
    17 </form>
    18 </body>
    19 </html>

    2:

     1 <html>
     2 <head>
     3     <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
     4 </head>
     5 <body>
     6 <?php
     7 if(isset($_POST['FCKeditor1'])){
     8     $titles= $_POST['title'];
     9     $fuggh = $_POST["FCKeditor1"];
    10     $fuggh = addslashes($fuggh);//addslashes函数将引号也保存到数据库当中打印出来;
    11     $conn = mysql_connect("localhost","root","") or die("数据库连接失败".mysql_error());
    12     mysql_select_db("test");
    13     mysql_query("set names 'utf8'");
    14     $sql ="INSERT INTO `test`.`more` (`id`, `title`,`condent`)VALUES (NULL, '$titles','$fuggh')";
    15     mysql_query($sql);
    16     $id = mysql_insert_id();
    17 //    echo $id;
    18     $sql = "select * from more where id = $id";
    19     $r = mysql_query($sql);
    20     $row = mysql_fetch_row($r);
    21 }
    22 
    23 ?>
    24 <p>标题:<?php echo $row[1] ?></p>
    25 <p>内容:<?php echo $row[2] ?></p>
    26 </body>
    27 </html>
  • 相关阅读:
    希尔排序例子
    C
    重构最大堆的例子
    基于堆的优先队列和用优先队列排序的例子
    堆排序例子
    分治法示例
    三路划分的快速排序算法
    二叉搜索例子
    标准快速排序
    【转载】JAVA5新特性
  • 原文地址:https://www.cnblogs.com/ws3366/p/3741346.html
Copyright © 2020-2023  润新知