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 ();

}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.