我试图在mysql数据库中插入值,似乎我已经陷入了这个
Connected successfully Facebook-Cool-Profile-Pics-Boys-40.jpg
C:\xampp\tmp\php36C9.tmp
image/jpeg
41015
uploads/e98d521ff1c6360fd142d716926f92ce.jpg
Warning: mysql_query() expects parameter 1 to be string, resource given in C:\xampp\htdocs\system\add.php on line 42
INSERT INTO admin(user_id,lname,fname,mname,address,contact,email_add,username,password,conf_pass,image) VALUES('1','Obemio', 'Gerald', 'G', 'USA', 09098228648, 'geraldobemio@yahoo.com', 'admin', 'pass', 'pass', 'uploads/e98d521ff1c6360fd142d716926f92ce.jpg' )Cannot be Added!
下面是代码:
$query = "INSERT INTO admin(user_id,lname,fname,mname,address,contact,email_add,username,password,conf_pass,image)
VALUES('$acctid','$lname', '$fname', '$mname', '$address', $contact, '$email', '$user', '$pass', '$confpass', '$path' )";
$result = mysql_query($conn,$query);
echo"$query";
答案 0 :(得分:0)
确保只将图像存储到数据库中,您需要将该字段声明为BLOB,BLOB类型,允许您存储二进制数据 - 图像,wav文件,视频等。开发人员经常提出的问题是将图像存储在数据库。
CREATE TABLE IF NOT EXISTS admin ( user_id varchar(30) NOT NULL, lname varchar(30) NOT NULL, fname varchar(30) NOT NULL, mname varchar(30) NOT NULL, address varchar(50) NOT NULL, contact int(11) NOT NULL, email_add varchar(50) NOT NULL, username varchar(25) NOT NULL, password varchar(25) NOT NULL, conf_pass varchar(25) NOT NULL, image BLOB NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
试试这个...
答案 1 :(得分:0)
尝试$query = "INSERT INTO admin(user_id,lname,fname,mname,address,contact,email_add,username,password,conf_pass,image) VALUES('$acctid','$lname', '$fname', '$mname', '$address', $contact, '$email', '$user', '$pass', '$confpass', '$path' )";
$result = mysqli_query($conn,$query);
答案 2 :(得分:-1)
$ query =“INSERT INTO admin( user_id,lname,fname,mname,address,contact,email_add,username,password,conf_pass,image )VALUES(' $ acctid','$ lname','$ fname','$ mname','$ address',$ contact,'$ email','$ user','$ pass','$ confpass','$ path ')“;
检查您的数据类型以解决此问题。