Home > Backend Development > PHP Tutorial > MYSQL从一个数据库的表中读出数据 循环向除此以外一个库的表中写入数据

MYSQL从一个数据库的表中读出数据 循环向除此以外一个库的表中写入数据

WBOY
Release: 2016-06-13 12:53:11
Original
932 people have browsed it

MYSQL从一个数据库的表中读出数据 循环向另外一个库的表中写入数据
MYSQL从一个数据库的表中读出数据 循环向另外一个库的表中写入数据 


代码不报错,读取代码测试可以通过,写入数据不能写入。

从TEST库的表 content 读出数据
$conn=mysql_connect('localhost','root','');
mysql_select_db('test');
mysql_query("set names utf8");
$duqu="SELECT * FROM `content` ORDER BY RAND() LIMIT 0, 10";
$result=mysql_query($duqu,$conn);


开始循环写入数据库的gzw_arctiny表中 
for($count=0;$count {

mysql_select_db('dedecmsv57utf8sp1');

$xieru="insert into gzw_arctiny ('id','typeid','channel','senddate','sortrank','mid','addurl') values ('','3','1','1359092641','1359094741','1','1111')";
mysql_query($xieru,$conn);

mysql 数据库 insert
------解决方案--------------------
insert into gzw_arctiny ('id','typeid','channel','senddate','sortrank','mid','addurl') values ...
你把字段名都用单引号括住,如何能正确执行?
------解决方案--------------------
如果是另外一个库的表,写入时要用另外的连接串连接
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template