Jump to content

Saber

New Members
  • Posts

    3
  • Joined

  • Last visited

Saber's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. @ marius May I know the error????????????
  2. Hi, Please check the code below, I am able to insert the records in the database through CSV file but unable to update. No error is generating but not updating <?php //Upload File if (isset($_POST['submit'])) { if (is_uploaded_file($_FILES['filename']['tmp_name'])) { echo "<h1>" . "File ". $_FILES['filename']['name'] ." uploaded successfully." . "</h1>"; echo "<h2>Displaying contents:</h2>"; readfile($_FILES['filename']['tmp_name']); } //Import uploaded file to Database $handle = fopen($_FILES['filename']['tmp_name'], "r"); while (($data = fgetcsv($handle, 2000, ",")) !== FALSE){ $Sql=mysql_query("select * from test where id ='$id'"); if(mysql_num_rows($Sql) > 0) { $import="update test set `name`='$data[1]', `gender`='$data[2]', `designation`='$data[3]' where id='$data[0]'"; mysql_query($import) or die(mysql_error()); } else { $import="insert into test set `name`='$data[1]', `gender`='$data[2]', `designation`='$data[3]', `id`='$data[0]'"; mysql_query($import) or die(mysql_error()); } } fclose($handle); print "Update done";
×
×
  • 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.