Jump to content

mysql_query - very strange results


snorky

Recommended Posts

Using an HTML form to input data. <form action='newa.php'>

 

The query in newa.php:

$result= mysql_query("insert into main (bldg,lname,title,fname) values ($bldg,$lname,$title,$fname)") or die('Oopsie! ' . mysql_error());

The result:

Record not posted. mysql_error():

Unknown column 'Warehouse' in 'field list'

"Warehouse" is the value input for bldg.

However, if I shuffle the order of the fields and values so that  (for example) fname comes before bldg

"insert into main (fname,bldg,lname,title) values ($fname,$bldg,$lname,$title)"

the the error is

Unknown column 'George' in 'field list'

and so on... Whichever field/value are first in the list, the "unknown column" is the value of the data in that column. there are several more fields - no matter what combinations I use, the result is the same.

 

As a sanity check, I added code to echo the values. Those are always correct, no matter which order is in the code.

 

No, I have not been self-medicating today.

Link to comment
https://forums.phpfreaks.com/topic/163821-mysql_query-very-strange-results/
Share on other sites

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.