I try to update a mysql db using php.
I need to update the data in table "A" with the data from table "B" if the two table have 1 data in common.

Everithing works fine when the data in common (prod='$col[0]') are only 1 word but not work when the words are two or more.

I am not a expert and probably the solution is around the corner can anyone help me save a big headache.

This is the script:

<?php 
  $result = mysql_query("SELECT * FROM tableA");
  $row = mysql_fetch_array($result);
  
  $col=array ($row['Prod'],$row['a'],$row['b'],$row['c'],$row['d'],$row['e']);
  
  mysql_query("UPDATE tableB SET a=$col[1], b='$col[2]', c=$col[3], d=$col[4], e=$col[5]    
  WHERE Prod='$col[0]'");
  ?>

It shouldnt be a problem. Try:

mysql_query(...) or die(mysql_error());

to see why the query fails.

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.