Translation:I will not buy a book that has only fifteen pages.
"mając" is an adverbial participle, which translates to "while having", so it implies that you only have 15 pages.
You need "mającej", the right grammatical form of the adjectival participle "mający", which corresponds to "having" here. "a book having XYZ" = "książka mająca XYZ".
This should actually be 'that', not 'which' - it's a mistake that's very common among English speakers but a mistake nonetheless. To explain: the information I wanted to gove about the mistake in the forst clause there was that it was common among English speakers, so I said it was "something THAT blah;" if I wanted to point out (emphasise) first that it was a mistake, then ADD that it was also common, I would say "it's a mistake, which is blah;" notice that I also added a comma: this wasnt necessary, but I think it makes it read more nicely, and every time you use 'which' instead of 'that' you should be able to add that comma and it should still make sense, or in other words the thing before the word 'which' should make your point on its own and the thing after it should be extra; if they need each other then you want 'that' instead. Conversely, if it does still mean the same thing with the comma then you have to use 'which': a comma before 'that' in this context doesn't work.
To return to the example in this question: "I will not buy a book, which has only fifteen pages" (the same with or without the comma) implies that you will not buy any book and that all books have fifteen pages (so actually if I wanted to say this I would rather go with "I will not buy books, which have only fifteen pages"). If you want to specify which book(s) you're talking about with the second part of the sentence, it should be 'that': "I will not buy a book that has only fifteen pages" means that if a book only has fifteen pages then you won't buy it.
A hopefully even clearer example I came up with: "I want you to knock on the doors of all the houses on this side of the street which/that don't have double-glazed windows": if you say, "Knock at all the houses on this side of the street that don't have double glazing," then you want your companion to go along that side of the street, and each time they come to a house without double glazing they have to kock on its door (and offer to sell it to them or whatever), and if it does then they can skip it, and they don't have to worry at all about the ones on the other side (because you'll do that or they're in a different zone or whatever). "Knock at the houses on this side which don't have double glazing," on the other hand, means that you've already checked on your register (or whatever) and found that none of the houses on that side have double-glazed windows (unfortunately, a lot of houses in Britain still don't, even though it's not a warm country) which is why you want your companion to knock on the doors of ALL the houses on that side of the street - but the ones on the other side do, so you don't need to worry about those ones. So with 'that' I'm classifying which ones I'm talking about, whereas with 'which' I'm supplying additional information or explanation. Hope this helps.
"książki co ma piętnaście stron" doesn't exactly sound 'wrong' to me, but I think it's colloquial. It also somehow suggests to me that there's only one book that has 15 pages. That may be just my personal impression, though.
A natural way of saying that without "mającej" would be "Nie kupię książki, która ma tylko piętnaście stron".