This question isn’t as dumb as it sounds. It is something that can happen, especially to people from developing countries: often, to get a visa, you need plane and hotel reservations. So it’s a catch-22.
It even happens to people from western countries: like almost everybody else, every time I want to go to China, I need a visa. And for political reasons (a former French President mentioned Tibet while talking to Jiang Zemin, oopsies!), France is still on China’s shit-list, aka “undesirable countries”. So we have to go through major hoops. We don’t have access to the one-day express visa; we need to provide proof of insurance, hotel reservation, plane reservation. Which is not only inconvenient, if you’re walking to China – as a HK resident, my main destination in China is Shenzhen, and I walk across the border to Shenzhen… – it’s basically impossible!
I tried once to do it myself, and was denied, not even the visa: I was denied the application. I had year-round travel & medical insurance from my HSBC account: denied. Get another one, specific for this trip. I was going to Shenzhen: denied – get a plane ticket.
There’s a Shenzhen-specific visa, which you can get at Luohu. But until last year, French people were not on the list of eligible countries. So I was shit out of luck. So I went to a travel agency, Travel Expert. They’re mostly dumb robots trying to overcharge you at every corner, at least in the shops, but they have visa people who can work miracles – the visa office in the China Resources building has counters just for travel agencies. Makes a huge difference. The main advantage is that travel agencies write a nice fairy tale for you. They make real reservations, book an insurance, etc, print them out, and cancel them. With that, their visa people apply for the visas, well-documented, and the applications are more or less rubber-stamped. There is a cost, for sure, but it is a sure-fire way to get a visa.
So this is what people like the OP of the question here should have done. Go through a travel agency. They’ll do the fake-ish bookings, apply for the visa, and, if it is accepted, make real bookings. If not, oh well.
Now, about the question. What happens to the ticket? Most probably, you’re shit out of luck. If, as I suspect, you went for the cheapest ticket and no travel insurance, because, among other things, you’re on a budget, your ticket is probably of the non-refundable, non-modifiable kind. Which means, either you fly, or you loose it. As usual in such questions, the canonical answer to this specific question is:
Only you know, because you bought the ticket, you have the T&C [or should have, and should have read them] and you should check with the airline, not Quora. Idiot.
As for a generic question, it is mostly the same. As we say in the IT world, RTFM.