Re: insert error for mysql

From: Date: Thu, 22 Sep 2005 19:38:01 +0000
Subject: Re: insert error for mysql
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-40345@lists.php.net to get a copy of this message
What is causing this is a single quote in the string you're trying to insert. You should use: $yourString = mysql_real_escape_string ( $yourString ); before you try to insert it. Also it looks like you have named your table 'view' and I suggest you don't do this, in the new version of mySQL 'view' will be a reserved word (and views will be supported). This is not causing your problem but you do want to choose another name for your table. Good Luck, Frank On Sep 19, 2005, at 11:25 AM, php-db-digest-help@lists.php.net wrote:
From: Yui Hiroaki <yui@mariana.u-aizu.ac.jp> Date: September 19, 2005 11:25:35 AM PDT To: php-db@lists.php.net Subject: insert error for mysql Reply-To: micah@raincross-tech.com hi! I have an error message to try to insert character into table. But I have an error messages like below. When I try to insert $strbuf, I got error. Could not perform INSERT to table 1064: 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 's used in the retail, banking, and insurance industries, among I publish SQL; mysql> create table view(b_col_id mediumint(255) NOT NULL AUTO_INCREMENT, b_col longblob NOT NULL,file_name varchar(255) NOT NULL,file_size varchar(255) NOT NULL,file_type varchar(255) NOT NULL,file_date time,vtext longtext,PRIMARY KEY(b_col_id))TYPE=MyISAM; mysql> alter tablev view add fulltext (vtext); The code---------------------------------------------- $handle = popen("/usr/bin/pdftotext \"$original_tmp\" - -layout 2>&1", 'r'); $strbuf = fread($handle, 2048000); echo $strbuf; pclose($handle); $sql_insert = "INSERT INTO view(b_col,file_name,file_size,file_type,file_date,vtext) VALUES ('$binaryContent','$original_name','$original_size','$original_type',CURTIME(),'$strbuf')"; mysql_query($sql_insert) or DIE ("Could not perform INSERT to table ".mysql_errno().": ".mysql_error()); mysql_close($db); Please do help me! Yui


« previous php.db (#40345) next »