Forum Moderators: coopster

Message Too Old, No Replies

PHP / MySQL Equi-Join

syntex seems right, but wont work?

         

ryan_b83

5:47 pm on Sep 1, 2006 (gmt 0)

10+ Year Member



Hello everyone, i cannot figure out why this query will not work. I don't know if this is a PHP question, a MySQL question, or a combonation of the both. I think that my SQL syntex is right, but i think the quotes are wrong but i can't figure out why its not working. It keeps "Dieing" when i run the query. I have noticed that some servers require you to quote your variables in your MySQL statments differently and havn't found a standard way to write it, but here is the line of code that wont work.

$sql = "SELECT `shipping.weight`, `s_address.company` FROM `shipping`, `s_address` WHERE (`shipping.said` = `s_address.said`) AND `pid` = '".$_GET['pid']."'";
$shipping_result = mysql_query($sql) or die("SQL Error: ".__LINE__);

Thanks,
Ryan

barns101

6:16 pm on Sep 1, 2006 (gmt 0)

10+ Year Member



When specifying the table and field (e.g. shipping.weight) I believe that you must remove the backticks (`) from your query.

ryan_b83

6:59 pm on Sep 1, 2006 (gmt 0)

10+ Year Member



Hummm.. i tried that... and it still threw the error. But for example this query would work

$sql = "SELECT `weight` FROM `shipping` WHERE `weight` > '10'"

I'm not sure if that helps at all but for the format of the syntex thats what seems to work.

thanx,
Ryan

barns101

7:18 pm on Sep 1, 2006 (gmt 0)

10+ Year Member



Try this:


$sql = "SELECT shipping.weight, s_address.company FROM shipping, s_address WHERE (shipping.said = s_address.said) AND pid = '$_GET[pid]'";
$shipping_result = mysql_query($sql) or die(mysql_error());