473,804 Members | 3,462 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

inserting data into mysql

I have a simple loop
include '../php_library/connect.php';
include '../php_library/opendb.php';

$conn=mysql_con nect($host,$dbu ser,$dbpass) or die ('Error');
mysql_select_db ($dbname);
//Open the file
$fp = fopen($src,"r") ;
//for each line in the file
while ($row=fgetcsv($ fp,10000,';')) { //Get line
$sql_insert="IN SERT INTO ...";
if (!mysql_query($ sql_insert,$con n)){
OutputError($sq l_insert,$mysql _error());
$FailedCount++;
}
else {$InsertCount++ ;}
}
It works fine for the first couple of hundred or so rows but the stops -
no errors, it just stops mid-loop.

I'm guessing some sort of buffer problem (needs flushing?) but it is a
guess.

I'm running this all locally - XP, Apache2, PHP5, mySQL 4.1

Keith
Sep 6 '05 #1
2 1678
On 2005-09-06, anom <an******@hotma il.co.uk> wrote:
I have a simple loop
include '../php_library/connect.php';
include '../php_library/opendb.php';

$conn=mysql_con nect($host,$dbu ser,$dbpass) or die ('Error');
mysql_select_db ($dbname);
//Open the file
$fp = fopen($src,"r") ;
//for each line in the file
while ($row=fgetcsv($ fp,10000,';')) { //Get line
$sql_insert="IN SERT INTO ...";
if (!mysql_query($ sql_insert,$con n)){
OutputError($sq l_insert,$mysql _error());
$FailedCount++;
}
else {$InsertCount++ ;}
}
It works fine for the first couple of hundred or so rows but the stops -
no errors, it just stops mid-loop.


Prepend the following to your script:

ini_set('error_ reporting', E_ALL);
ini_set('displa y_errors', TRUE);

I've got a feeling you will see a message like: max execution time has
been exceeded... http://www.php.net/set_time_limit
--
Met vriendelijke groeten,
Tim Van Wassenhove <http://timvw.madoka.be >
Sep 6 '05 #2
Tim Van Wassenhove wrote:
On 2005-09-06, anom <an******@hotma il.co.uk> wrote:
I have a simple loop
include '../php_library/connect.php';
include '../php_library/opendb.php';

$conn=mysql_con nect($host,$dbu ser,$dbpass) or die ('Error');
mysql_select_db ($dbname);
//Open the file
$fp = fopen($src,"r") ;
//for each line in the file
while ($row=fgetcsv($ fp,10000,';')) { //Get line
$sql_insert="IN SERT INTO ...";
if (!mysql_query($ sql_insert,$con n)){
OutputError($sq l_insert,$mysql _error());
$FailedCount++;
}
else {$InsertCount++ ;}
}
It works fine for the first couple of hundred or so rows but the stops -
no errors, it just stops mid-loop.

Prepend the following to your script:

ini_set('error_ reporting', E_ALL);
ini_set('displa y_errors', TRUE);

I've got a feeling you will see a message like: max execution time has
been exceeded... http://www.php.net/set_time_limit

Thank you - spot on
Sep 6 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2906
by: Frank Pryor | last post by:
Hello, I'd appreciate suggestions as I hash out my idea. Perhaps I'm going about this the wrong way. I have users using a third party windows application. They can export data from this application directly to a text file (CSV). So far as I know, there is no way to make this application talk directly to the MySQL server. We're talking thousands of records here - it's not practical to have an HTML
5
2272
by: Mechphisto | last post by:
I'm using a textarea to insert some notes into a database. It's inserting the complete result into the mySQL table including the linebreaks...and not as a visible symbol but an actual linebreak. If I select the fireld in mySQL at a command prompt, the results take an inordinate amount of space from all the linebreaks. I tried nl2br() before it goes into the INSERT, but all that does is ADD <br /> to the data but it still have linebreaks...
13
9310
by: perplexed | last post by:
How do you convert a user inputted date to a unix timestamp before insterting it into your database? I have a form, with a textfield for a date that the user inputs in the format mm-dd-yyyy and three dropdow boxes for hours, minutes, and AM/PM. All of these need to be considered together and converted to one Unix Timestamp and then inserted to the MYSQL date field. The type of field is INT (11) so that I can instead of the standard...
8
1716
by: news | last post by:
I'm building an e-commerce site, where the owner needs to be able to upload a CSV file of product that gets inserted into mySQL. Unfortunately, I think my Web host may have some functions turned off. Is there some other ways I can try to do the following? First, I'm using a form to upload a file. That works, but it sets the file permissions to 600, and the PHP command "exec()" is disabled so I can't chmod it as part of the script. But...
1
2525
by: Astra | last post by:
Hi All Could you please let me know how my ASP page can insert 1 row of data containing line breaks into a MySQL DB. To explain, I'm using ASP Classic > MyODBC 3.5x (Win) > MySQL 4 (Win) and my insert command is: INSERT INTO `WEBCONTENT` (CONTENTTEXT) VALUES ('Order Number: Account Number:
4
5869
by: FangQ | last post by:
hi I am very new to mysql. I have a question about using the "on duplicate update" clause with insert command. my table "data" has two columns, field1 and field2, where field1 is the index and is "unique". when I run
1
1671
Ajm113
by: Ajm113 | last post by:
Ok, when I was new to this I had this problem and I bet a lot of other people did when they where new to PHP and Mysql. So this mite be your question; "Ok, no errors or warnings in mysql and php so why isn't the script entering info into my row?". Well to awnser your question most servers that you pay for monthly or own will have a anti mysql injection attack. So it will not allow the injection to enter in your database for your protection...
3
2636
by: len | last post by:
Hi All I have started a little pet project to learn python and MySQL. The project involves figuring out all the combinations for a 5 number lottery and storing the data in a MySQL file. The file looks like this; +----------+---------------------+------+-----+--------- +----------------+ | Field | Type | Null | Key | Default |
0
1721
by: Edwin.Madari | last post by:
-----Original Message----- statement prepared first and executed many times with exectemany - db API http://www.python.org/dev/peps/pep-0249/ inline statemets can be exeucuted only. hope that helps Edwin
6
1899
by: Bunty | last post by:
I want to insert values in the database.If i insert values one by one then it works till 4 or 5 fields then after it gives error.In my database there are more than 20 field.Pls help me.
0
9588
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10589
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10085
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7625
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4302
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3828
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.