sangeetha Posted April 4, 2008 Share Posted April 4, 2008 When i import data into database , the number of lines i can insert is only 127. Even if i try to import the auto add reference number is not getting increased. The datas are inserted with the same number as 127 for all the other lines getting inserted I have assigned the auto add reference for the Stud_id values.The fields of the database are Stud_id,Stud_name,Stud_mark.How to rectify this.. This is the code that i have. $fileloc=$_POST['filename'];$path = $fileloc;$file = basename($path); // $file is set to "index.php"$databasehost = "localhost";$databasename = "test";$databaseusername ="test";$databasepassword = "";$fieldseparator = "\t";$lineseparator = "\n";$tsvfile = $fileloc;$addauto =1;if(!file_exists($tsvfile)) { echo "File not found. Make sure you specified the correct path.\n"; exit;}$file = fopen($tsvfile,"r");if(!$file) { echo "Error opening data file.\n"; exit;}//echo $file;$size = filesize($tsvfile);//echo $size;if(!$size) { echo "File is empty.\n"; exit;}$tsvcontent = fread($file,$size);fclose($file);$con = mysql_connect("$hostname","$user","$pass") or die("did'nt connect to mysql"); mysql_select_db("test") or die ("no database");$result = mysql_query("SELECT * FROM $exam order by count");$count=0;while($row = mysql_fetch_array($result)) { $count= $row['count']; }if($count==0) $count=0; else $count=$count; // echo $count."<br>"; @mysql_close($con); $con = mysql_connect("$hostname","$user","$pass") or die("did'nt connect to mysql"); mysql_select_db("test") or die ("no database"); $databasetable = "$file3";$lines = 0;$queries = "";$linearray = array();foreach(split($lineseparator,$tsvcontent) as $line) { $count = $count + 1; $lines++; $line = trim($line," \t"); $line = str_replace("\r","",$line); $line = str_replace("'","\'",$line); $linearray=array(); $linearray = explode($fieldseparator,$line); $linemysql = implode("','",$linearray); if($addauto) { $query = "insert into $databasetable VALUES('$count','$linemysql');"; $result1 = mysql_query($query) or die("didn't query for insert"); echo $query."<br>"; } else $query = "insert into $databasetable values('$linemysql');"; $queries .= $query . "\n"; @mysql_query($query); //echo $query ."<br>\n";}echo " TSV File imported to the database";@mysql_close($con); Link to comment Share on other sites More sharing options...
justsomeguy Posted April 4, 2008 Share Posted April 4, 2008 The integer field in your database is either an unsigned 7-bit int or a signed 8-bit int, both of which have a max value of 127. Increase the storage size of the field in the table. Link to comment Share on other sites More sharing options...
kv79 Posted April 4, 2008 Share Posted April 4, 2008 The integer field in your database is either an unsigned 7-bit int or a signed 8-bit int, both of which have a max value of 127. Increase the storage size of the field in the table.Do you want to said that mysql database , is limited ? with 8 bit ,what lines ? In the text or what , in phpcode ??or what ?When I go to PhpMyAdmin I got confuse where is unsigned or where is signed Integer .I sow only tinyint , smallint ,mediumint ,bigint , I hope that is a correct . Link to comment Share on other sites More sharing options...
justsomeguy Posted April 4, 2008 Share Posted April 4, 2008 Do you want to said that mysql database , is limited ? with 8 bit ,what lines ? In the text or what , in phpcode ??or what ?I don't know what you're asking, but there is an "UNSIGNED" attribute under the "Attributes" dropdown in phpMyAdmin. If you don't specify that it is unsigned, then it is signed. Since a tinyint is a 1-byte int, then a signed tinyint has a max value of 127. OP is probably using a signed tinyint as his data type.http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html Link to comment Share on other sites More sharing options...
kv79 Posted April 4, 2008 Share Posted April 4, 2008 Thanks ,very useful link . Link to comment Share on other sites More sharing options...
sangeetha Posted April 5, 2008 Author Share Posted April 5, 2008 Thanks.. Its working well now.. Link to comment Share on other sites More sharing options...
sangeetha Posted April 5, 2008 Author Share Posted April 5, 2008 Thanks.. Its working well now.. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.