2010-08-06 5 views
0

데이터베이스에 1000 자 이상을 저장하고 싶습니다. MySQL 데이터베이스를 사용합니다.값이 데이터베이스에 삽입되지 않았습니다.

50-100자를 삽입하면 코드가 성공적으로 실행됩니다. 하지만 1000자를 삽입하면 삽입되지 않습니다. 또한 오류를주지 않습니다.

phpMyAdmin에서 비슷한 삽입 쿼리를 사용하면 쿼리가 성공적으로 실행됩니다. 이 먼저 두 개의 필드가 VARCHAR & 마지막 필드가 LONGTEXT입니다있는 쿼리입니다 :

INSERT INTO news (headline,date,discription) 
VALUES ("hi","date","A crumbling pitch and some resurgent Indian bowling have set up a gripping deciding Test with the series lead threatening to slip out of the hosts' grasp. India had snuck ahead at the end of the third day, but were dominant by lunch on the fourth as Pragyan Ojha and Amit Mishra ran through the Sri Lankan batting. Thilan Samaraweera, the centurion from the first innings, held firm and is key to Sri Lanka's fortunes as they try to build a lead that is competitive enough to give their spinners a chance. ") 

이 실행 성공적으로 phpMyAdmin을

하지만 PHP에서 그것을 실행하려고하면, 다음은 실행할 수 없습니다에 .

mysql_real_escape_string($_POST['discription']) 

이 수 :

$insert = "INSERT INTO news (headline,date,discription) 
VALUES ('".$_POST['headline']."','".$_POST['date5']."','".$_POST['discription']."')"; 
$add_news = mysql_query($insert); 

&이 코드는 태그를 사용하여 문자열 변수 전에

<textarea rows="2" cols="2" style="overflow: scroll; height: 90px; width: 635px;" name="discription"></textarea> 

답변

2

사용 mysql_real_escape_string 기능은 예입니다 : 여기

은 PHP 코드입니다 텍스트에는 esc이어야하는 작은 따옴표가 포함되어있을 가능성이 큽니다. 아프다. -

는 mysql_real_escape_string는

귀하의 코드는 다음과 같아야합니다 SQL 문에 사용 에 대한 문자열 특수 문자를 이스케이프 :

$headline = mysql_real_escape_string($_POST['headline']); 
$description= mysql_real_escape_string($_POST['discription']); 
$date= mysql_real_escape_string($_POST['date5']); 

$insert = "INSERT INTO news (headline,date,discription) VALUES ('".$headline."','".$date."','".$description."')"; 
$add_news = mysql_query($insert) or die(mysql_error()); 

참고 끝에 or die(mysql_error()의 또한 그 , 쿼리 자체에 오류가 있으면 알려줍니다.

+0

헤이 감사의 작업 는 Pratikg88 @ 당신 –

+0

대단히 감사합니다 : 당신은 어떻게 든 오류를 잡기 있는지 나는 당신의 쿼리 (스리랑카) 단어를 보았 기 때문에 – Sarfraz

+0

또한 만들 ... 환영합니다, 당신은하지 않았다 경우 그것이 확실히 오류를 줄 것이 탈출. – Centurion

관련 문제