How can I insert data into a specific row? I tried this but it didn't work: $queryone = "SELECT id, views FROM table ORDER BY RAND() LIMIT 1"; $id = $row['id']; $views = (int)$row['views'] + 1; $query = "INSERT INTO table (views) VALUES ('$views') WHERE id='" . $id . "'"; mysql_query($query) or die('Error, insert query failed'); $query = "FLUSH PRIVILEGES"; mysql_query($query) or die('Error, insert query failed'); Code (markup): I get 'Error, insert query failed'. Any help is greatly appreciated!
What you need is the UPDATE statement. INSERT is for inserting new rows in the table. UPDATE is for changing field values in existing rows.