Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
running many queries always stops and never completes
Old 11-20-2008, 11:37 AM running many queries always stops and never completes
Extreme Talker

Posts: 177
Trades: 0
I have a nested for loop after doing a preg_replace() function. I have the preg_replace function return what was replaced and is in a 2d array.

So the preg_replace executes, I print_r($returnedValues) and it prints out fine. Then when I iterate through the $returnedValues, each iteration does a mysql_query("INSERT"); It should execute ~203 inserts, but stops after 70. I implemented a set_time_limit() into the iteration thinking that would keep it going, but it continues to stop after 70 inserts, and doesn't complete.


What would be the cause of this?

Heres the funciton if you really want to see it
PHP Code:
if(preg_match_all("([0-9]{6})"$explodePage[$i], $sections))
        {
            foreach(
$sections as $boo)
            {
                foreach(
$boo as $fun)
                {
                echo 
'query!<br>';
                
mysql_query("INSERT INTO $table (abbreviation, number, section) VALUES ('$courseName', '$number', '$fun')") or die(mysql_error());
                
//$sectionNumbers[$courseName][$number][$counter] = $fun;
                //$counter++;
                
}
            }
        } 
kbfirebreather is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-20-2008, 12:07 PM Re: running many queries always stops and never completes
Experienced Talker

Posts: 32
Trades: 0
any problems with your php memory limit? did you check that?
__________________

Please login or register to view this content. Registration is FREE
Professional PSD to XHTML coding services
tsiger is offline
Reply With Quote
View Public Profile
 
Old 11-20-2008, 12:12 PM Re: running many queries always stops and never completes
Extreme Talker

Posts: 177
Trades: 0
I've never really dealt with the memory limit, but I brought it up and is currently set to 64M. What's a safe value for that? Is that large enough to process the amount of requests I'm looking for?

edit:

I feel like this should be large enough. Assuming each query takes 100 bytes, looking at 200 queries, that's only 200,000 bytes. And 64M is well above that limit.

Last edited by kbfirebreather; 11-20-2008 at 12:15 PM..
kbfirebreather is offline
Reply With Quote
View Public Profile
 
Old 11-20-2008, 12:12 PM Re: running many queries always stops and never completes
maxxximus's Avatar
Extreme Talker

Posts: 219
Name: Rob
Location: UK
Trades: 0
You can do multiple inserts with just one query http://dev.mysql.com/doc/refman/5.0/en/insert.html.
INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9);
maxxximus is offline
Reply With Quote
View Public Profile
 
Old 11-20-2008, 12:25 PM Re: running many queries always stops and never completes
Extreme Talker

Posts: 177
Trades: 0
My query knowledge has never been very strong, but this is definitely something I'll look into, and probably the answer I need. Thank you for showing me this, I'll be playing around with it and let you know how it works out later on in the day.
kbfirebreather is offline
Reply With Quote
View Public Profile
 
Old 11-20-2008, 02:55 PM Re: running many queries always stops and never completes
Experienced Talker

Posts: 32
Trades: 0
Yes.. i thing this could work and 64M of memory is more than enough for an operation like this
__________________

Please login or register to view this content. Registration is FREE
Professional PSD to XHTML coding services
tsiger is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to running many queries always stops and never completes
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.71480 seconds with 12 queries