I am fairly new to the concept of working wity mysql and php.  I am looping 
thru a text file full of county names and attempting to add these to a database.

Now the table exists and if I enter the SQL statement manually against the 
database it works.  The user also has read and write permissions to the table 
and the columns in the table.

Here is my php code:
 $lines = file("/tmp/new1.txt");
 foreach ($lines as $line_num => $line) {
  echo($line . '... ');
   $link = mysql_connect('naabe', 'naabe', 'xxxxxxxxx')
    or die('could not connect: ' . mysql_error());
    // I use substr to remove the space at the end of every line.
   $sql = "INSERT INTO countries (country) VALUES ('" . 
substr($line,0,strlen($line)-1) . "')";
   echo ($sql . ' ...<br>');
   mysql_query($sql);
   mysql_close();
  flush();
 }

This is how I configured php4.3.9
./configure --enable-so --with-mysql=/usr/local/mysql --enable-filepro 
--with-apx2=/usr/local/apache2/bin/apxs --with-jpg --with-png --with-xml

It will print to the screen the line and the SQL statement correctly.  The 
password is correct.  The database name is naabe, the user is naabe.

Anyone know what I could be doing wrong?

Trav

Reply via email to