hi i have a database with prices descriptions and so on, and have a CSV file with reference and price. i want to up date the ref and price of only the product it finds in the data basethat match the ones from the CSV file i have used the below and now im stuck. i run it and it gives me a blank page and nothing changes.

<?php


$conn = mysql_connect("hose","user","password");
   $db = mysql_select_db("DB_name");

   $fh = fopen("pricefile.csv", "r");
   while ($line = fgetcsv($fh, 1000, ",")) {
      $ref = $line[1];
      $cost = $line[0];


      $query = "update ps_product SET Price='$cost' where reference='$ref' ";
      $result = mysql_query($query);
   }

   fclose($fh);
   mysql_close();
   
   ?>

echo yor $query to see if it contains the expected content.
If it does, run in from the mysql command line.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.