Page is a not externally linkable
- Code, Content, and Presentation
-- Databases
---- Requesting help with inserting and reading TEXT data type in MySQL


R8kit - 10:17 pm on Oct 25, 2011 (gmt 0)


Hello everyone,

I am new to MySQL and I am trying to insert the data type TEXT into the database but it isn't working out for me.

I created an SQL file with the following code:


CREATE DATABASE books;

USE books;

CREATE TABLE authors (
id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR (255),
info TEXT
);

INSERT INTO authors (name, info) values('Vivek', '
asdfkljasdkl;fjasd
fasdl;kfjaskl;dfjasd
fasdkl;fjasd;lkfjasdf
asdl;fkajsd;lfkjasd;fsd
fkl;asdjfaskl;djfsd
sdakl;jasdl;kfjasdkl;fjasd
asdkl;fjasdl;fkjasl;kfj
');


I created an PHP page with the following code:

<?php
mysql_connect("localhost","root","passwd");

mysql_select_db("books");

$result=mysql_query("SELECT * FROM authors");

$row=mysql_fetch_array($result);

while ($row=mysql_fetch_array($result)) {
echo 'Name: '.$row{'name'}.'<br />';
echo 'Info: '.$row{'info'}.'<br />';
}
?>


Can anyone help me insert and read the TEXT data type the proper way?

Thanks in advance.


Thread source:: http://www.webmasterworld.com/databases_sql_mysql/4379360.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com