Home >Backend Development >PHP Tutorial >插入数据库错误的问题?问题出在哪里?

插入数据库错误的问题?问题出在哪里?

WBOY
WBOYOriginal
2016-06-23 14:21:22974browse

数据库 exception

刚开始写留言板,通过mysqlconnect类的insert方法讲留言信息插入数据库
错误信息如下:
Fatal error: Uncaught exception 'Exception' with message ' SQL insert into message(name,addtime,content,reply) values('test14','2013-09-07 01:59:02','and0s8jsfn89233j2r87hyfw','')' in D:\AppServ\www\forum\util\MySqlConnect.class.php

下面是insert方法代码:
public function insert($table_name, $data_array){		$field_array = array();		$value_array = array();		foreach($data_array as $k => $v){			$field_array[] = $k;			if(gettype($v) != "integer"){				$value_array[] = "'".$v."'";			}else{				$value_array[] = $v;			}		}		$sql = "insert into ".$table_name."(".implode(",",$field_array).") values(".implode(",",$value_array).")";		//echo $sql;		//exit();		$boolean = $this->execute($sql);		$this->insertId = mysql_insert_id($this->connection);		return $boolean;	}


$vname = $_POST["name"];	$vcontent = $_POST["content"];	$vaddtime = date("Y-m-d h:i:s");	$vreply = "";	$arr = array("name"=>$vname,"addtime"=>$vaddtime,"content"=>$vcontent,"reply"=>$vreply);	$message = new message;	$done = $message->insert("message", $arr);

回复讨论(解决方案)

不好意思,SQL语句输入的差数有问题.已解决,版主帮忙把帖删了,谢谢!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn