
Copy link to clipboard
Copied
I have created a feedback form for our airshow website and it's working fine. I am now creating some review pages, which are also working fine, so
...I decided to improve one of the review pages and now it doesn't work...sigh.
We ask the responders to provide their zip code and I have a view showing the number of responses by zip code, this works fine and can be seen here http://www.hollisterairshow.com/feedback-results.php , so I decided to improve this by adding the city/ state based on zip code. I created a new table called 'zipcodes' and imported a list of zip codes and city/ state info - all 42,000+ of them.
The PHP/MySQL which works is shown below
<?php
// Make a MySQL Connection
$query = "SELECT zip, COUNT(zip) FROM feedback GROUP BY zip";
$result = mysql_query($query) or die(mysql_error());
// Print out result
while($row = mysql_fetch_array($result)){
echo $row['zip']. " ". $row['COUNT(zip)'];
echo "<br />";
}
?>
As I am now dealing with two tables I thought I needed to add the table name to any field so I added table names and the fields for the new table so
I changed the PHP/ MySQL as follows
<?php
// Make a MySQL Connection
$query = "SELECT feedback.zip, COUNT(feedback.zip), zipcodes.citystate FROM feedback zipcodes WHERE feedback.zip = zipcodes.zipcode GROUP BY feedback.zip";
$result = mysql_query($query) or die(mysql_error());
// Print out result
while($row = mysql_fetch_array($result)){
echo $row['feedback.zip']. " ". $row['COUNT(feedback.zip)']. " ". $row['zipcodes.citystate'];
echo "<br />";
}
?>
and it fails when I run it saying "Unknown column 'feedback.zip' in 'field list' "
I'd appreciate any suggestions on this, I'm new to this PHP/MySQL stuff.
Thanks,
Tony
1 Correct answer
Tables listed in the From clause need to be comma seperated. As it is, it is being evaluated as an alias.

Copy link to clipboard
Copied
Why do you use a dot in your tables names?. It could be that .zip is a reserved MySQL extension.
Try using underscores to name your tables.
Copy link to clipboard
Copied
>Why do you use a dot in your tables names?
The dot is the standard qualification seperator. It is required if you are qualifying the column with the table name.
Copy link to clipboard
Copied
Tables listed in the From clause need to be comma seperated. As it is, it is being evaluated as an alias.

