Jump to content

My page is stuck loading, is this because inefficient programming?


mike12255

Recommended Posts

So long story short im trying to read a text file line by line and do a cpl db tests agains that one line my file size is about 1300 lines long so I cut it down to 600 and the page is stil stuck loading, can anyone tell me why, my code is below.: (it was working fine I must have just changed something without knowing it)

 

<?php
include ("include/session.php");

$file_handle = fopen ( "To Do.txt", "rb" );

while ( ! feof ( $file_handle ) ) {

$line_of_text = fgets ( $file_handle );
$parts = explode ( '=', $line_of_text );

//get the course infomation
//Examples:
//$Course_info[0] = GEOL
//$Course_info[1] = 1002
//$title = Introduction To Geology 
$Course_info = explode ( ' ', $parts [0] );
$length = strlen ( $Course_info [0] ) + strlen ( $Course_info [1] ) + 2;
$title = substr ( $parts [0], $length );

//check to see if this course is already in the database
$sql = "SELECT * FROM courses WHERE course = '$Course_info[0]' AND code = '$Course_info[1]'";
$res = mysql_query ( $sql ) or die ( mysql_error () );

if (mysql_num_rows ( $res ) == 0) {
	//course doesnt exist
	//lets get the program ID for this course
	$id_sql = "SELECT id FROM catagories WHERE code = '$course_info[0]'";
	$res = mysql_query($id_sql) or die (mysql_error());
	$row = mysql_fetch_array ( $res );
	echo $row ['code'];

} else {
	//course is already in the database


}

exit ();

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.