Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Newbie MySQl problem


paulm2003

Recommended Posts

Trying to write a contribution I was testing some MySQL,

when I make the following simple query (from a book example):

//connect to DB
$link = mysql_connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD) or die (mysql_error());
mysql_select_db(DB_DATABASE) or die (mysql_error());


$sql = 'SELECT manufacturers.*, products.*';
$sql .= 'FROM manufacturers, products';
$sql .= 'WHERE manufacturers.manufacturers_id = products.manufacturers_id';

$result = mysql_query($sql) or die(mysql_error());

it works fine using PHP MyAdmin, but using a PHP script I get the next error

Not unique table/alias: 'manufacturers'

:huh:

 

any suggestions?

Link to comment
Share on other sites

  • 2 weeks later...

Already found the answer at another board,

something like this:

//connect to DB
$link = mysql_connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD) or die (mysql_error());
mysql_select_db(DB_DATABASE) or die (mysql_error());

$sql = 
'SELECT manufacturers.*, products.* 
 FROM manufacturers, products 
 WHERE manufacturers.manufacturers_id = products.manufacturers_id';

$result = mysql_query($sql) or die(mysql_error());

should work fine.

 

I copy and pasted the code and didn't notice there where some spaces missing :rolleyes:

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...