Hi, I working on a program to insert and pull information from a mysql database. Inserting information is easy, but when I pull the data back out, it always skips the first row of data. Why is this? can anyone help?
here's my code:
<body>
<?php
/ Connect to MySQL Server /
$db = @mysql_connect("142.176.153.212", "root");
if (!$db) { echo( "<P>Unable to connect to the " . "database server at this time.</P>" ); exit();}
/ Connect to Database /
mysql_select_db("Marketplace_International",$db);
if (! @mysql_select_db("Marketplace_International") ) { echo( "<P>Unable to locate the database " . "database at this time.</P>" ); exit();}
/Insert into database /
$sql="INSERT INTO Distributor values('','$Fname','$Mname','$Lname','$Email','$Street','$City','$State_Prov','$Postal','$Country','$Phone','$Fax','$Password','$Template','$Icq')";
if ( mysql_query($sql) ) { echo("<P align=center>Your information has been successfully entered into our database.<br></P>");} else { echo("<P>Error entering your information into our database: " . mysql_error() . "</P>");}
mysql_close();
?>
<?php
$db = @mysql_connect("142.176.153.212", "root");
if (!$db) { echo( "<P>Unable to connect to the " . "database server at this time.</P>" ); exit();}
mysql_select_db("Marketplace_International",$db);
if (! @mysql_select_db("Marketplace_International") ) { echo( "<P>Unable to locate the database " . "database at this time.</P>" ); exit();}
/Display First Names in the Database /
$result = mysql_query("SELECT * FROM Distributor",$db);
if (!$result) { echo("<P>Error performing query: " . mysql_error() . "</P>"); exit();}
$row = mysql_fetch_array($result);
while ( $row = mysql_fetch_array($result)) {
/ process the row.../
$Mpi_id = $row["Mpi_id"];
$Fname = $row["Fname"];
$Mname = $row["Mname"];
$Lname = $row["Lname"];
$Email = $row["Email"];
$Street = $row["Street"];
$City = $row["City"];
$State_Prov = $row["State_Prov"];
$Zip = $row["Zip"];
$Country = $row["Country"];
$Phone = $row["Phone"];
$Fax = $row["Fax"];
$Password = $row["Password"];
$Template = $row["Template"];
$Icq = $row["Icq"];
/ Display the row.../
echo("<P>" . "$Mpi_id " . "$Fname " . "$Lname " . "$Mname " . "$Email " . "$Street " . "$City " . "$State_Prov " . "$Zip " . "$Country " . "$Phone " . "$Fax " . "$Password " . "$Template " . "$Icq" . "</P>");
}
mysql_close();
?>
</body>