Jump to content

[SOLVED] Problem with LOAD DATA LOCAL INFILE: All records are not being added


flattened

Recommended Posts

:'( I am having a hard time trying to understand why this is messing up. :facewall:

 

What is is supposed to do is:

  • Create the table
  • Populate it by the file
  • Then show the titles of all the records

(There are 97 records by the way)

 

include 'config.php';
include 'opendb.php';
// Create a MySQL table in the selected database
mysql_query("CREATE TABLE tutorials(
accessKey INT(10) NOT NULL, 
PRIMARY KEY(AccessKey),
title VARCHAR(100), 
id INT(5), 
previewImage VARCHAR(100),
intro VARCHAR(500),
full_Tutorial VARCHAR(52),
keywords VARCHAR(100),
programsUsed VARCHAR(50))")
or die(mysql_error());  
echo "Table Created!";

$sql="LOAD DATA LOCAL INFILE 'tutorials.txt' INTO TABLE tutorials FIELDS TERMINATED BY ';' ENCLOSED BY '\"' LINES TERMINATED BY '\n'";
	$query = mysql_query($sql) or die(mysql_error());

echo "Data Added!";
$result = mysql_query("SELECT * FROM tutorials ORDER BY full_Tutorial ASC") 
or die(mysql_error()); 
echo "<ol>";
while($row = mysql_fetch_array( $result )) {
	echo "<li></li>";
}

 

 

So, what happens is it does everything it's supposed to BUT it doesn't load all the records (loaded up to #46) I have tried reducing the # of records (tried adding just 8 ) but it still only showed 5.

 

I don't know what to do.

 

PS. Is it wrong for me to hope this is a real problem as opposed to just a missing character somewhere :happy-04:

Link to comment
Share on other sites

Oh, I'm sorry!

 

The file is http://snookumz.com/tutorials.txt, that's the original file with all the records

I entered the records on Access 2007 and used the export feature. http://snookumz.com/Tutorials.accdb if that matters any.

 

The primary key is the first row with the 10 number (AccessKey).

The fields are (in order): AccessKey, Title, ID, ProgramsUsed, Intro, Full_tuto, Keywords, and Preview Image

 

When I run the query, I only get every other row except for the first (i.e. 1,2,4,6,8-96 in that manner [i deleted #97]) I haven't noticed any discrepancies in the records added and the ones not, other than the above mentioned.

 

Just a thought, would this have anything to do with the id number? :shrug: The only purpose of that is for the GET variable that will be used to call each tutorial, but it's not necessary elsewise. This is so frustrating because eveything else works, including the php aspect.  >:(

 

Thank you very much for the responses  :)

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.