Login    Forum    Search    FAQ   Blog

Board index » Server Side Development » PHP




 Page 1 of 1 [ 7 posts ] 



Author Message
 Post subject: INSERT aint inserting all the data
 Post Posted: Thu Nov 12, 2009 10:35 pm 
Offline

Joined: Sat Feb 21, 2009 1:13 pm
Posts: 63
Hello,

I had completed a confined or limited search hwoever i dun have
any idea of the search term so look 4 a quick pointer.

I m hvin a 200 rows of data. Wen i INSERT dis in 2 mysql db usin PHP only
184 rows were inserted.

I m havin a feeling dat this was bcoz there r "illegal" characters in wat
i am askin it 2 insert.

is there ne code dat i could put in 2 ma PHP r mysql so dat it could
ignore any illegal data?

It might not even be illegal data? In which case would it be Null data? As
you can see i m really unsure of ma terminology!

I welcome any help!

Thanks


Top 
 Post subject: Re: INSERT aint inserting all the data
 Post Posted: Thu Nov 12, 2009 10:35 pm 
Offline

Joined: Sat Feb 21, 2009 11:06 am
Posts: 1794
Is it a only insert query r 200 separate queries?
If the latter, try echoin mysql_error() 2 see why some f them fails.


Top 
 Post subject: Re: INSERT aint inserting all the data
 Post Posted: Thu Nov 12, 2009 10:36 pm 
Offline

Joined: Sat Feb 21, 2009 1:08 pm
Posts: 549
So, you are escapin string data usin da
mysql_real_escape_string() so dat special sql chars in it never gonna
break ur queries?


Top 
 Post subject: Re: INSERT aint inserting all the data
 Post Posted: Thu Nov 12, 2009 10:36 pm 
Offline

Joined: Sat Feb 21, 2009 1:13 pm
Posts: 63
This is wat i have...

Code:
$con = mysql_connect("localhost","xxxxx","xxxxx");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

// Create table
mysql_select_db("xxxxx_12345", $con);

$sqldelete = "DROP TABLE table1";
mysql_query($sqldelete,$con);

$sql = "CREATE TABLE table1
(
hotID int NOT NULL AUTO_INCREMENT,
PRIMARY KEY(hotID),
title text(10000),
deal_link text(10000),
mobile_deal_link text(10000),
submit_time text(10000),
hot_time text(10000),
temperature text(10000)
)";

// Execute query
mysql_query($sql,$con);

for ($i=0; $i<=199; $i=$i+1)
{
mysql_query("INSERT INTO tophotdeals (title, deal_link, mobile_deal_link, submit_time, hot_time, temperature)
VALUES ('{$title[1][$i]}', '{$deal_link[1][$i]}', '{$mobile_deal_link[1][$i]}', '{$submit_time[1][$i]}', '{$hot_time[1][$i]}', '{$temperature[1][$i]}')");
}

mysql_close($con);


As you could see... very basic. I hav changd it 2 text (10000) as i was
just trying 2 get it 2 work. I would try da suggestions above.


Top 
 Post subject: Re: INSERT aint inserting all the data
 Post Posted: Thu Nov 12, 2009 10:37 pm 
Offline

Joined: Sat Feb 21, 2009 1:08 pm
Posts: 549
I dun see an exception with da code. I usaully
suspect dat u might be runnin out of the execution time. Further more, for
a bulk query just like this, it was a lot more efficient 2 build one giant
insert rather than doin two hundred!! queries.

This is set in da php.ini via da max_execution_time = directive, nd
defaults 2 30 seconds.

You could try overridin da default wid

Code:
set_time_limit(120) ;


at da top of ur script, to see quickly if dat fixes ur issue.


Top 
 Post subject: Re: INSERT aint inserting all the data
 Post Posted: Thu Nov 12, 2009 10:37 pm 
Offline

Joined: Sat Feb 21, 2009 1:13 pm
Posts: 63
I did tried da set_time_limit(120); nd dis didnot worked at all.

Although der was 200 rows wid the 5 columns there isn't much data nd it takes
only abt 2 seconds 2 complete.


Top 
 Post subject: Re: INSERT aint inserting all the data
 Post Posted: Thu Nov 12, 2009 10:37 pm 
Offline

Joined: Sat Feb 21, 2009 11:06 am
Posts: 1794
verify ur error log then. The only otr thin I could think is dat
your array does not in fact have 200 elements.


Top 
Display posts from previous:  Sort by  
 
 Page 1 of 1 [ 7 posts ] 




Board index » Server Side Development » PHP


Who is online

Users browsing this forum: No registered users and 2 guests

 
 

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron