1,105,585 Community Members

Text rstops query working

Member Avatar
GlenRogers
Posting Whiz
329 posts since Jan 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi, I have this query to add data to mysql

$query = "INSERT INTO products VALUES('', '$acode', '$aname', '$acontent', '$aprice', '$remote_file', '$cat')";

My table is
id int(20) primary ai
code varchar(200)
product_name varch(200)
description varchar(600)
price decimal(10, 2)
imagepath varchar(200)
product_id int(10)

I have an html textarea to enter data for the description field. When the text in the textarea is, say, 250characterslong, everything is fine-the query works and all data is added to mysql. But when the text is say 500 long the the query does not work and nothing is added.

Can anyone help?

Thanks for looking

Glen...

Member Avatar
diafol
Where are my eyes?
12,983 posts since Oct 2006
Reputation Points: 1,821 [?]
Q&As Helped to Solve: 1,848 [?]
Skill Endorsements: 92 [?]
Moderator
Featured
Sponsor
 
0
 

varchar can only go to 255, depending on the version of MySQL. Try setting datatype to text, to see if it helps.

http://dev.mysql.com/doc/refman/5.0/en/char.html

Also, set the first field to NULL not ''.

Member Avatar
GlenRogers
Posting Whiz
329 posts since Jan 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Thats still not working. It adds nothing. But if the text description is short the it adds to the database ok.

Any ideas?

Member Avatar
diafol
Where are my eyes?
12,983 posts since Oct 2006
Reputation Points: 1,821 [?]
Q&As Helped to Solve: 1,848 [?]
Skill Endorsements: 92 [?]
Moderator
Featured
Sponsor
 
0
 

OK, could it be due to unescaped characters? You're using mysql_real_escape_string() right?

Member Avatar
GlenRogers
Posting Whiz
329 posts since Jan 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

mysql_real_escape_string()

I wasnt using this, but using it now has sorted the problem!

Thank you!

Glen..

Question Answered as of 1 Year Ago by diafol
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article