MySQL reads a data loop from a table in a database writes data to a table in one of the other libraries

Source: Internet
Author: User
MySQL reads a data loop from a table in a database writes data to a table in another library
MySQL reads a data loop from a table in a database writes data to a table in another library


Code does not error, read code test can pass, write data cannot write.

Read data from table content in test library
$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);


Start loop writing to the database in the Gzw_arctiny table
for ($count =0; $count <10; $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 Database Insert


------Solution--------------------
Insert INTO gzw_arctiny (' id ', ' typeid ', ' channel ', ' senddate ', ' Sortrank ', ' mid ', ' addurl ') values ...
You enclose the field names in single quotation marks, how can they be executed correctly?
------Solution--------------------
If it is a table of another library, it is connected with a different connection string when writing
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.