php mysql insert into while 不测终止
php mysql insert into while 意外终止
- PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->$result = mysql_query("SELECT uid , pid , cate FROM upcm");while($rows = mysql_fetch_row($result)){$arry = explode($sepr,$rows[2],5);$query = "INSERT INTO upcn(uid,pid,cate1,cate2,cate3,cate4,cate5) VALUES('$rows[0]','$rows[1]','$arry[0]','$arry[1]','$arry[2]','$arry[3]','$arry[4]')";$result1 = mysql_query($query);if(!$result1){echo "fail<br>";}}
mysql_fetch_row($result)获取查询的结果,逐条处理,处理后写进一个新的表里面,但是每次执行while循环总是还没执行完程序就终止了,没有处理完数据,把insert into 换成printf(“**”);代替插入操作,会将程序正确执行完毕,而且每次运行程序插入的条数不一,有时多有时少,请问大侠们什么情况这是,苦恼啊..
------解决方案--------------------
。。
像你这种问题,肯定是要在cli模式下跑单条sql处理才靠谱啊!!!
至不济也要先把数据导出,然后导入,而不是这样做啊
参见select into
------解决方案--------------------
有几个问题需要注意排除:
1、php超时
2、web服务器超时
3、特殊字符未转义
4、count($array)
算法上可考虑:
每千条组装成多个VALUE的INSERT语句后插入
以分页方式逐段插入
直接使用SQL指令完成,而不经php转手
$sql =INSERT INTO upcn(uid,pid,cate1,cate2,cate3,cate4,cate5)
SELECT uid , pid
, substring_index(substring_index(cate,'$sepr',1),'$sepr',-1)
, substring_index(substring_index(cate,'$sepr',2),'$sepr',-1)
, substring_index(substring_index(cate,'$sepr',3),'$sepr',-1)
, substring_index(substring_index(cate,'$sepr',4),'$sepr',-1)
, substring_index(substring_index(cate,'$sepr',5),'$sepr',-1)
FROM upcm
SQL;

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



index.html represents the home page file of the web page and is the default page of the website. When a user visits a website, the index.html page is usually loaded first. HTML (HypertextMarkupLanguage) is a markup language used to create web pages, and index.html is also an HTML file. It contains the structure and content of a web page, as well as tags and elements used for formatting and layout. Here is an example index.html code: <

How does Java use the substring() function of the StringBuilder class to intercept a substring of a string? In Java, we often need to process string operations. Java's StringBuilder class provides a series of methods to facilitate us to operate strings. Among them, the substring() function can be used to intercept substrings of strings. The substring() function has two overloaded forms, namely substring(intstar

How to get a substring using String.substring() method in Java? The String class in Java provides a very useful method substring(), which can be used to obtain the substring of a string. It allows us to select a portion of characters from a string and return it as a new string. This article will explain how to use the substring() method in Java and provide some code examples. Using the substring() method is very

PHP source code running problem: Index error resolution requires specific code examples. PHP is a widely used server-side scripting language that is often used to develop dynamic websites and web applications. However, sometimes you will encounter various problems when running PHP source code, among which "index error" is a common situation. This article will introduce some common causes and solutions of index errors, and provide specific code examples to help readers better deal with such problems. Problem Description: When running a PHP program

The index in MySQL means index. It is a data structure used to speed up the query of database tables. The index can be compared to the catalog of a book. It stores the values of specific columns in the table and the corresponding row positions, making the database more efficient. Locate and access data quickly. The function of the index is to improve query efficiency. Without an index, the database needs to scan the entire table row by row to find matching data. This method will be very time-consuming in large tables. With an index, the database can The required data rows are quickly located in the order, which greatly improves the query speed.

How to remove index.php from https: 1. Modify the server settings, find the .htaccess file on the server and open it, enter "RewriteEngine On...</IfModule>" and other contents in the file, and then save the file; 2 . Use the URL settings of the CMS system, select "Permalink" in the settings, select "Post Name" in the general settings, and then click "Save Changes"; 3. Use a plug-in to help you remove index.php.

A deadlock occurred in the background production environment. By checking the deadlock log, we saw that the deadlock was caused by two identical update statements (only the values in the where condition were different), as follows: UPDATEtest_tableSET`status`=1WHERE`trans_id`=' xxx1'AND`status`=0;UPDATEtest_tableSET`status`=1WHERE`trans_id`='xxx2'AND`status`=0; It was confusing at first, but after a lot of querying and learning, the deadlock was analyzed

Use the substring() method of the StringBuffer class to obtain a substring of part of a string. In Java programming, it is often necessary to process and operate strings. The StringBuffer class is a commonly used string class that provides a series of convenient methods to operate strings. Among them, the substring() method is a very commonly used method, which can be used to obtain part of the content of a string, that is, a substring. The following will introduce how to use the StringBuffer class
