movieprodw
asked on
SQL Column not found
Hello,
If I put this in my navicat app as a query it inserts it into the table, if I try to do it via php it says that the column can not be found. Any clue as to why?
Works in Navicat
Doesn't work in PHP ( Unknown column 'ListingType' in 'field list' )
If I put this in my navicat app as a query it inserts it into the table, if I try to do it via php it says that the column can not be found. Any clue as to why?
Works in Navicat
INSERT INTO properties (
ListingType,
ListingStatus,
StreetAddress,
UnitNumber,
City,
State,
Zip,
DisplayAddress,
Price,
MlsId,
VirtualTourUrl,
ShortSale,
BankOwned,
Availability,
LeaseTerm,
DepositFees,
UtilitiesIncluded,
PetsAllowed,
Title,
PropertyType,
Bedrooms,
Bathrooms,
LivingArea,
LotSize,
YearBuilt,
Description,
user_id,
PropertyImages
)
VALUES
(
'2',
'1',
'4857 E Lafayette Blvd',
'',
'Phoenix',
'AZ',
'85018',
'1',
'343',
'',
'',
'1',
'1',
'',
'',
'',
'',
'',
'',
'Townhouse',
'1',
'2.5',
'2953',
'23954',
'1964',
'',
'1',
''
)
Doesn't work in PHP ( Unknown column 'ListingType' in 'field list' )
$insert_query = mysqli_query($conn,"INSERT INTO properties (
ListingType,
ListingStatus,
StreetAddress,
UnitNumber,
City,
State,
Zip,
DisplayAddress,
Price,
MlsId,
VirtualTourUrl,
ShortSale,
BankOwned,
Availability,
LeaseTerm,
DepositFees,
UtilitiesIncluded,
PetsAllowed,
Title,
PropertyType,
Bedrooms,
Bathrooms,
LivingArea,
LotSize,
YearBuilt,
Description,
user_id,
PropertyImages
)
VALUES
(
'2',
'1',
'4857 E Lafayette Blvd',
'',
'Phoenix',
'AZ',
'85018',
'1',
'343',
'',
'',
'1',
'1',
'',
'',
'',
'',
'',
'',
'Townhouse',
'1',
'2.5',
'2953',
'23954',
'1964',
'',
'1',
'')");
ASKER
Please see attached.
Actual query in myphp
Actual PHP query copied from above and ran, does not work.
Actual query in myphp
INSERT INTO properties ( ListingType, ListingStatus, StreetAddress, UnitNumber, City, State, Zip, DisplayAddress, Price, MlsId, VirtualTourUrl, ShortSale, BankOwned, Availability, LeaseTerm, DepositFees, UtilitiesIncluded, PetsAllowed, Title, PropertyType, Bedrooms, Bathrooms, LivingArea, LotSize, YearBuilt, Description, user_id, PropertyImages) VALUES ('2','1','4857 E Lafayette Blvd','','Phoenix','AZ','85018','1','343','','','1','1','','','','','','','Townhouse','1','2.5','2953','23954','1964','','1','')
Actual PHP query copied from above and ran, does not work.
$insert_query = mysqli_query($conn,"INSERT INTO properties ( ListingType, ListingStatus, StreetAddress, UnitNumber, City, State, Zip, DisplayAddress, Price, MlsId, VirtualTourUrl, ShortSale, BankOwned, Availability, LeaseTerm, DepositFees, UtilitiesIncluded, PetsAllowed, Title, PropertyType, Bedrooms, Bathrooms, LivingArea, LotSize, YearBuilt, Description, user_id, PropertyImages) VALUES ('2','1','4857 E Lafayette Blvd','','Phoenix','AZ','85018','1','343','','','1','1','','','','','','','Townhouse','1','2.5','2953','23954','1964','','1','')");
Have you tried to omit column names as I suggested in my comment?
ASKER
Yes
' Column count doesn't match value count at row 1'
' Column count doesn't match value count at row 1'
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for working through it, it ended up a connection error, it is super strange that was the error it was giving.
Thank you so much for helping!
Thank you so much for helping!
Anyway, you could solve the issue just omitting to specify columns' names:
Open in new window