Note that there are some explanatory texts on larger screens.

plurals
  1. POUnknown column 'Bob' in 'field list'... php or mysql problem
    primarykey
    data
    text
    <p>I have a curious problem that I hope is something stupid I overlooked.</p> <p>I am getting an error that usually occurs when there is a missing column in a mysql table, or a misspelled php variable: "Unknown column 'Bob' in 'field list'"...</p> <p>Except 'Bob' is not the name of a column, its the VALUE I am trying to assign to the row. Why would php be confusing the two??</p> <p>Here is my php function that I believe is the location of the error:</p> <pre><code>function recordGuest($id,$fname,$lname,$dinner){ $conn = connect("wedding"); $guest_query = "INSERT INTO guest (fname,lname,person_id) VALUES (".$fname.",".$lname.",".$id.");"; mysql_query($guest_query,$conn) or die(mysql_error()); $guest_id_query = "SELECT id FROM guest WHERE person_id = ".$id.";"; $guest_id_result = mysql_query($guest_id_query,$conn) or die(mysql_error()); $guest_id = ""; while($row = mysql_fetch_array($guest_id_result)){ $guest_id = $row["id"]; } $guest_dinner_query = " INSERT INTO guest_dinner (dinner_id,guest_id) VALUES (".$dinner.",".$guest_id.");"; mysql_query($guest_dinner_query,$conn) or die(mysql_error()); } </code></pre> <p>Here is the php code that processes the form and executes the above function:</p> <pre><code>&lt;?php include("functions.php"); $code = $_POST["code"]; $type = $_POST["type"]; $people = getPeople($code); $ids = $people["ids"]; $email= ""; for($i = 0; $i &lt; count($ids); $i++){ $response = $_POST["response_".$i]; $dinner = $_POST["dinner_".$i]; recordResponse($ids[$i],$response); if($dinner != "null"){ recordDinner($ids[$i],$dinner); } if($type == 3){ $guest_responses = $_POST["guest_response_".$i]; $guest_fname = $_POST["guest_fname_".$i]; $guest_lname = $_POST["guest_lname_".$i]; $guest_dinner_response = $_POST["guest_dinner_response_".$i]; if($guest_dinner_response != "null"){ recordGuest($ids[$i],$guest_fname,$guest_lname,$guest_dinner_response); } } } ?&gt; </code></pre> <p>Heres what my "guest" mysql table looks like:</p> <pre><code>guest id int auto inc (primary key) fname varchar lname varchar person_id int </code></pre> <p>Any help would be appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload