sparky Posted February 6, 2014 Share Posted February 6, 2014 (edited) I have an issue as to where I am trying to save long amounts of data into a database, and nothing that I try seems to work.... The field $detail when I have more than a coupld lines of data just does not write the data... Note code below: Viewing the $SQL Data all shows correct... Just does not write it to the Database. I have tried changing to blob and other selections in the MYSQL, but not seeing what I am doing wrong. thanks in advance for any advice. John Database: ---------------------- -- phpMyAdmin SQL Dump-- version 3.5.0-- http://www.phpmyadmin.net---- Host: localhost-- Generation Time: Feb 06, 2014 at 09:30 AM-- Server version: 5.5.23-- PHP Version: 5.3.13SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";SET time_zone = "+00:00";/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;/*!40101 SET NAMES utf8 */;---- Database: `elsa`---- ------------------------------------------------------------ Table structure for table `timeline2`--CREATE TABLE IF NOT EXISTS `timeline` ( `id` int(11) NOT NULL AUTO_INCREMENT, `mo` text, `mon` text, `da` text, `yr` text, `hdr` text, `detail` longtext, PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Elsa Time Line' AUTO_INCREMENT=4 ;/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; ---------------------- Insert Code: ---------------------- <?php// open the connection$conn = mysql_connect("localhost", "xxxx", "xxxx");// pick the database to usemysql_select_db("elsa",$conn);// create the SQL statement$mo=$_POST[mo];$mon=$_POST[mon];$da=$_POST[da];$yr=$_POST[yr];$hdr=$_POST[hdr];$detail=$_POST[detail];$sql = "INSERT INTO timeline2(mo, mon, da, yr, hdr, detail) values ('$mo', '$mon', '$da', '$yr', '$hdr', '$detail')";echo $sql;echo "<BR>";// execute the SQL statementif (mysql_query($sql, $conn)) { echo "Record Updated!";} else { echo "Something went Wrong";}?> ---------------------- Example data that does not work. ---------------------- <P ALIGN=CENTER> Elsa's Journey to her new home in Memphis</P> <CENTER> <P ALIGN=CENTER> <iframe title="YouTube video player" class="youtube-player" type="text/html" width="640" height="510" src="http://www.youtube.com/embed/EJufDyBse8s" frameborder="0" allowFullScreen></iframe></P> </CENTER> <P ALIGN=CENTER> <!-- $MVD$:spaceretainer() --> </P> <P ALIGN=CENTER> Elsa at Home</P> <P ALIGN=CENTER> <A HREF="assets/140131/index.htm"><IMG SRC="assets/140131/elsa-013114-01_std.jpg" WIDTH="536" HEIGHT="800" VSPACE="0" HSPACE="0" BORDER="0"><BR>Click on IMAGE</A></P> <P ALIGN=CENTER> <!-- $MVD$:spaceretainer() --> </P> <P ALIGN=CENTER> Elsa VS the Video Camera.</P> <CENTER> <P ALIGN=CENTER> <iframe title="YouTube video player" class="youtube-player" type="text/html" width="640" height="510" src="http://www.youtube.com/embed/DTWntrEVuUs" frameborder="0" allowFullScreen></iframe></P> </CENTER> <P ALIGN=CENTER> A Very long Day for just a little Kitty...</P> <P ALIGN=CENTER> <IMG SRC="assets/140131/Sleeping.jpg" WIDTH="640" HEIGHT="480" VSPACE="0" HSPACE="0" BORDER="0"></P> <P ALIGN=CENTER> She was laying under her cat tree... When I turned off the lights (from remote) she got up and went to her cat bed and fell asleep.</P> Edited February 6, 2014 by sparky Quote Link to comment https://forums.phpfreaks.com/topic/285991-phpmysql-does-not-save-long-data/ Share on other sites More sharing options...
mac_gyver Posted February 6, 2014 Share Posted February 6, 2014 i'll assume you are getting your "Something went Wrong" message? you are not escaping your string data before putting it into the query statement, so all the characters like - ', ", \t, \r, \n that are in the data are breaking the sql syntax. you need to use mysql_real_escape_string() on all string data being put into a query statement that can contain any characters that have meaning in the sql query or you need to use prepared query statements. you also need to switch to the mysqli or pdo database library functions. the msyql functions are depreciated in php5.5 and you don't want to have to rewrite your code later when the mysql functions are removed. Quote Link to comment https://forums.phpfreaks.com/topic/285991-phpmysql-does-not-save-long-data/#findComment-1467951 Share on other sites More sharing options...
sparky Posted February 21, 2014 Author Share Posted February 21, 2014 Quote Link to comment https://forums.phpfreaks.com/topic/285991-phpmysql-does-not-save-long-data/#findComment-1469788 Share on other sites More sharing options...
mac_gyver Posted February 21, 2014 Share Posted February 21, 2014 posting your 1500+ line php.ini is pointless because a) no one's going to look at the mess it made of the post, and b) php might not even be using that php.ini file. what sort of errors or symptoms are you getting the lead you to believe mysqli isn't working? Quote Link to comment https://forums.phpfreaks.com/topic/285991-phpmysql-does-not-save-long-data/#findComment-1469896 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.