Shematics: optocoupler controls a transistor and doesn't work as expected
The optocoupler needs a load resistor to ground over which it generates a voltage. The voltage is based on the current it can put out. That first schematic doesn't generate any/enough voltage to turn on the base of the transistor.