bemax Posted August 22, 2008 Share Posted August 22, 2008 I have an login system. Now I want the user to have the possibility to format the text before sending to database as he want. Something like what I have here where I sending this message. Example: Something like what I have here where I sending this message How can I do it in php? Link to comment https://forums.phpfreaks.com/topic/120822-posibility-to-the-user-to-format-text-before-sending-it-to-database/ Share on other sites More sharing options...
Vivid Lust Posted August 22, 2008 Share Posted August 22, 2008 Just style it in HTML ... Link to comment https://forums.phpfreaks.com/topic/120822-posibility-to-the-user-to-format-text-before-sending-it-to-database/#findComment-622802 Share on other sites More sharing options...
bemax Posted August 30, 2008 Author Share Posted August 30, 2008 Thanks for your reply! It was very helpfull but i have an other question. I doing a pagination and I getting an error message witch is : Query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '8, 4' at line 1 I cant realy find where is the mistake, could you please help me with this? Here is the code: <?php /* ////////////////////////////////////////// ////1) MySQL Database Connection /////////// ////////////////////////////////////////// */ $host = "localhost"; $user = "francine"; //$db_name= "yourdatabasename"; $db_name= "francine"; $pass= "123"; $conn = mysql_connect($host, $user, $pass) or die(mysql_error()); mysql_select_db($db_name, $conn) or die(mysql_error()); ?> <?php /* ////////////////////////////////////////////////// ////2) Get page number, if any ///////////////////////////////////////// ////// Prevent Injection Attack ///////// ////// Set $pageno variable ///////////// ///////////////////////////////////////// */ if(isset($_GET['pageno'])) { if(!is_numeric($_GET['pageno'])) { echo 'Error.'; exit(); } $pageno = $_GET['pageno']; } else { $pageno=1; } ?> <!-- ////////////////////////////////////////////////////////////////// //3) Calculate how many rows or records in total the query will output ///////////////////////////////////////////////////////////////// --> <?php $queryCount = 'SELECT count(*) FROM proverbes'; $resultCount = mysql_query($queryCount); $fetch_row = mysql_fetch_row($resultCount); $numrows = $fetch_row[0]; // if there is no results if($numrows == 0) { echo 'Sorry, we have no products yet.'; exit(); }?> <!-- /////////////////////////////////////////////////////////////// ///4) Calculate number of pages //////////////////////////////////////////////////////////////// --> <?php $perPage = 4; $lastpage = ceil($numrows/$perPage); $pageno = (int)$pageno; if($pageno<1) { $pageno=1; } elseif($pageno>$lastpage) { $pageno=$lastpage; } ?> <!-- //////////////////////////////////////////////////////////////// ///5) Generate page links //////////////////////////////////////////////////////////////// --> <?php // ----- PAGE LINKS ----- if($pageno==1) { $pages .= 'FIRST | PREVIOUS '; } else { $pages .= "<a href='{$_SERVER['PHP_SELF']}?pageno=1'>FIRST</a> | "; $prevpage=$pageno-1; $pages .= " <a href='{$_SERVER['PHP_SELF']}?pageno=$prevpage'>PREVIOUS</a> "; } $pages .= ' ( Page '.$pageno.' of '.$lastpage.' ) '; if($pageno==$lastpage) { $pages .= ' NEXT | LAST '; } else { $nextpage = $pageno+1; $pages .= " <a href='".$_SERVER['PHP_SELF']."?pageno=$nextpage'>NEXT</a> | "; $pages .= " <a href='".$_SERVER['PHP_SELF']."?pageno=$lastpage'>LAST</a>"; } ?> <!-- ///////////////////////////////////////////////////////////////// /////6) Calculate LIMIT clause for the MySQL query //////////////////////////////////////////////////////////////// --> <?php //$limit=' LIMIT '.($pageno-1)*$perPage.', '.$perPage; $limit=($pageno-1)*$perPage.', '.$perPage; ?> <!-- ////////////////////////////////////////////////////////////////// ////7) Run the query, echo the results and echo the page links ///////////////////////////////////////////////////////////////// --> <?php $query = $query.$limit; $result = mysql_query($query); if(!$result) { echo 'Query failed: '.mysql_error(); } else { while($row = mysql_fetch_array($result , MYSQL_NUM)) { echo $row['id'].' '.$row['theme'].' '.$row['proverbe'].' '.$row['explication'].' '.$row['nom'].'<br />'; //echo $row[0]; } } echo '<div style="width:100%; text-align: center; font-size: smaller; color: #999;">'.$pages.'</div>' ; echo ' Total number of products: '.$numrows; ?> Link to comment https://forums.phpfreaks.com/topic/120822-posibility-to-the-user-to-format-text-before-sending-it-to-database/#findComment-629957 Share on other sites More sharing options...
Ken2k7 Posted August 30, 2008 Share Posted August 30, 2008 You don't need to open and close a PHP tag after every block of code. And please your code. Link to comment https://forums.phpfreaks.com/topic/120822-posibility-to-the-user-to-format-text-before-sending-it-to-database/#findComment-629960 Share on other sites More sharing options...
Barand Posted August 30, 2008 Share Posted August 30, 2008 After this $query = $query.$limit; put echo $query; and post the output. We're not psychic. Link to comment https://forums.phpfreaks.com/topic/120822-posibility-to-the-user-to-format-text-before-sending-it-to-database/#findComment-630026 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.