I keep getting an error when i use this update query.
can someone help me please.
update `table` set `column1` = '$varvalue' WHERE `column2` = 'value1' AND `column1`='value2'
for some reason it doesnt work when I put the AND in there and the second column value.
looks okay to me
what error message did you get?
You have an error in your SQL syntax near 'date`= '1'' at line 1
you have a column called date? that's a reserved word, and you are right to enclose it in backticks
why are you looking for a string in it?
can we see the full query and also the CREATE TABLE statement?
the table is already created i just need it to update.
here is the query:
$getnewdate = "UPDATE `test_track` SET `date`='$date' WHERE `cat='$cat' AND `date`= '$mindate'";
Let me explain what I am trying to do.
I run a school for court reporters. I'm setting up this site as a way to stream their practice and testing materials.
I have the date column set as INT and a query that grabs the MIN(date) and updates it to todays date then the next page pulls the 2 rows where the value of the date column=$date (todays date) by date and by category.
you're missing the closing backtick here --> WHERE `cat='$cat'
tip: don't use backticks if you don't have to
tip: do use backticks where you do have to, like around reserved words used as column names
tip: don't assign strings to numeric columns
tip: use DATE datatype if you really want to store dates
its not so much that i needed to store the date itself I just need to update the lowest value everyday and pull the info from that updated field.