Jump to content

[SOLVED] Column 'fname' in field list is ambiguous


ballhogjoni

Recommended Posts

What does this mean? Column 'fname' in field list is ambiguous

 

this is my code:

 

<?php 
	if (isset($_POST['search_fname'])) {
		$search_fname = $_POST['search_fname'];
		$query = "SELECT fname FROM contact_n_questions, dispo_callBack, dispo_client, dispo_demoSetup, dispo_money, dispo_notContacted, dispo_notInterested, dispo_time, dispo_tooSmall WHERE fname = '{$search_fname}'";
		$result = mysql_query($query) or die(mysql_error());
		if (!mysql_num_rows == "") {
			while($row = mysql_fetch_array($result) or die(mysql_error())) {
				echo $row['fname'].'<br>';
			}
		} else {
			echo 'No Records';
		}
	}
	?>

SELECT fname FROM contact_n_questions, dispo_callBack, dispo_client, dispo_demoSetup, dispo_money, dispo_notContacted, dispo_notInterested, dispo_time, dispo_tooSmall WHERE fname = '{$search_fname}'

 

 

I don't think that is right, it looks like you are trying to select "fname" from a bunch of different tables, why would you want to do that? Can you tell me what you are trying to do?

I want to find a specific record in the db. The thing is, i don't know which table the record is in. I don't knwo because the records change from one table to next based on certain criteria and that criteria changes on a daily bases. As the criteria changes the record is passed and then deleted from one table to the next.

Ah, ok, well what about the curly brackets - {$search_fname} - are those needed? (I am obviously not an expert, just pointing out things that look out of place).

 

This might be your solution - http://sqlzoo.net/howto/source/z.dir/err918/mysql - looks like you might need to join the tables?

 

Let me know if that works.

 

 

 

 

 

 

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.