954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

PHP Update problem

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]'");
  ?>
moonwine
Newbie Poster
1 post since Oct 2009
Reputation Points: 10
Solved Threads: 0
 

It shouldnt be a problem. Try:

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

to see why the query fails.

pritaeas
Posting Expert
Moderator
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You